DEV Community

Bruno
Bruno

Posted on

Creating a local dev environment for Kubernetes with $0 cost

Embracing any new technology stack can certainly be a journey. No matter if this is your first time using Kubernetes or you have been on the Google Borg Team.

This post will show you how to create a Kubernetes cluster, add it an application platform (Shipa), and start deploying applications with $0 cost.

We will leverage minikube and a free Shipa Cloud account.

Kubernetes Pre-Reqs

The first part is for us to create a local Kubernetes Cluster, where you can deploy applications to. A quick and free option we will use is minikube on your local machine.

If you are using a Mac, installing minikube can be accomplished by leveraging Homebrew.

Once Homebrew is installed, run:

brew install minikube

If using a new variant of Mac OS, an easy hypervisor to use for minikube is HyperKit. You can set minikube to leverage HyperKit. If you have not installed HyperKit before, Homebrew can take care of that also for you. Potentially you might have to install the machine driver if the brew formulae does not have it as a dependency.

brew install docker-machine-driver-hyperkit #optional
brew install hyperkit
Enter fullscreen mode Exit fullscreen mode

Once HyperKit is installed, you can wire minikube to leverage HyperKit.

minikube config set driver hyperkit

Lastly, depending on your machine size you can make dedicate more resources to minikube. For example I would like 8 gigs of memory dedicated to minikube.

minikube config set memory 8128

Now you are all set to start your minukube cluster.

minikube start

With minukube up and running, you can run a kubectl command to validate. Homebrew would have also laid down kubectl for you if installing minkube from Hoembrew.

kubectl get nodes

Kubernetes cluster setup

Now you are all set to create your Shipa Cloud account.

Getting Started with Shipa Cloud

Our goal is to deploy and manage our applications without dealing with the underlying complexities that Kubernetes impose, so we will use Shipa Cloud for that.

You can sign up for a free account here

Shipa Cloud

There are a few core concepts to work through. The first item that you will need to define is a Framework. A Shipa Framework is the lifeblood of your Shipa Configuration housing all the controls and policies.

Shipa Cloud -> Frameworks + Create Framework -> Basic

Creating Shipa Framework

Creating a basic Framework for the example, just name your Framework “myfirstframework”. By default, you have access to a Plan and Team. The defaults for the example are fine.

Creating Shipa Framework

Once you click Create, your Framework will be available.

Creating Shipa Framework

Wiring Your Kubernetes Cluster to Shipa Cloud

You will need a few pieces of authentication from your minikube instance to connect it to Shipa Cloud.

Shipa Cloud will need an accessible address to your cluster, a Kubernetes authentication token, and CA Certificate.

Public URL – ngrok

If you run the cluster-info command on your local minukube instance, you will get a local to your network address.

kubectl cluster-info | grep 'Kubernetes' | awk '/http/ {print $NF}'

Leveraging a service like ngrok, you can expose your local instance, more specifically the Kubernetes API. This guide on ITNEXT is really good for getting started. For evaluation purposes only, you can also expose the Kubernetes API. We will be doing that for this example.

Sign up and Install ngrok

You can sign up for a free account with ngrok. Installing the ngrok client is easy with homebrew by running:

brew install –cask ngrok

Once installed, you can head to the ngrok setup page and run the authorization command e.g “Connect your account:”

ngrok

Then: ngrok authtoken <your_token>

ngrok

Once that is connected, you can leverage an HTTP proxy for the Kubernetes API

kubectl proxy --disable-filter=true

Then can fire up ngrok to front the traffic over your localhost and the default Kubernetes API Port e.g 8001.

ngrok http 8001

ngrok

Grab the HTTP forwarding address and can save that for the Shipa Cloud Cluster configuration.

Kubernetes Auth Token

Creating an authorization token based off a Kubernetes role is straightforward. The Shipa Documentation for connecting a cluster gives the needed manifest to create the role and base the token off of.

Create the shipa-admin-service-account.yaml file with the following content:

Shipa service account creation file

Then apply the manifest.

kubectl apply -f shipa-admin-service-account.yaml

With the service account created, you can grab the authorization token. Can re-run the below command when it is time to copy and paste into Shipa Cloud.

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep shipa-admin | awk '{print $1}')

Required Cluster Information

You can also grab the CA Certificate for service account by running the following command. Similarly can re-run when needed to copy and paste into Shipa Cloud.

kubectl get secret $(kubectl get secret | grep default-token | awk ‘{print $1}’) -o jsonpath='{.data.ca\.crt}’ | base64 –decode

Adding the Cluster

Once you have the three needed pieces, you can add the cluster to Shipa Cloud.

Shipa Cloud -> Clusters + Add Cluster

Can name the cluster “myminikube” and leverage your framework you created earlier e.g “myfirstframework”.

Adding Cluster Information

Click Next and fill out the the connectivity information [HTTP address, token, and certificate] that was just created.

Adding Cluster Information

Once you click Next, your Cluster will be available!

Cluster available on Shipa Cloud

Once your cluster is available, the world is your oyster and you are ready to start deploying your apps without all the Kubernetes related complexity.

Leveraging Shipa Cloud to help drive engineering efficiency across the application stack is now possible. With the wide paintbrush that Shipa Cloud offers, the art of the possible is great.

Top comments (0)