Kubernetes on your workstation? Yes, with minikube!!

Godfrey Menezes
4 min readOct 3, 2020

It would be an understatement to say that Kubernetes has changed DevOps and how we deploy our code. If Docker helped with containerization of what is required for your code to run, Kubernetes took it forward with managing those containers in orchestration and management.

While running a Kubernetes cluster would mean several machines functioning as nodes and setting them up as a cluster, the question always is, how can I demo it on my laptop? The answer is minikube. It allows one to run kubernetes in a single node-your laptop or workstation- just like it would run on multiple machines. So lets get the ball rolling!

Installing minikube

I used a CentOS Laptop for this exercise. First thing you want to do is, make sure that virtualization is enabled on your machine and you have Hypervisor-VirtualBox- installed on your machine. I used the following directive.

After the installation is done, there may be a requirement to load the kernel modules, do so using the following command -

sudo /sbin/vboxconfig

Next install Docker and the simple command for that would be -

sudo yum install docker

Finally, install minikube and then install kubectl to run the commands

minikube installed!

Fingers crossed, lets start minikube and see how it goes!

minikube start

Check the status

minikube status

Congratulations! We have minikube running on our laptop. The detailed instructions are available from here.

Deploying your first application

So we have our minikube cluster setup, lets deploy an app to that and see it it action. First start the kubectl proxy. Kubectl proxy is the service which provides the access to Kubernetes API. Let this command run in a command window -

kubectl proxy

Next I’m using a simple deployment that runs the NGINX. The yaml file and details are available here. In another command window, I downloaded the yaml file to my laptop, renamed it to nginx.yaml. Run the command to create the deployment -

kubectl apply -f nginx.yaml

The output should be as

deployment.apps/nginx-deployment created

Check the status of the deployment by issuing the following command. It may take some time to move from ContainerCreating, Pending to Running-

kubectl get deployment

kubectl get pods

kubectl run deployment

The details of the deployment can be accessed by issuing the following command -

kubectl describe deployment nginx-deployment

The output should be something like this -

kubectl describe deployment

We have our deployment running but to access it we need to expose it as a service and to access the service we would need to tunnel the request. To do that open another command window and issue the command

minikube tunnel

minikube tunnel

So we have everything set, lets expose our service and see if we can access the running nginx server by issuing the expose deployment command -

kubectl expose deployment nginx-deployment. — type=LoadBalancer — name=nginx-service

describe service

If all’s well, it will list an External IP address on which I can access the nginx deployment. This can be noted from the command window where minikube tunnel command is running. It will show the services that are exposed,

service exponsed

Open a browser and check if we can access the nginx web server. The IP address and the port -the output from kubectl describe service nginx-service- command

service running

Congratulations! We have Kubernetes deployed on our personal machine!

As an end note, I’d suggest reading the book Kubernetes:Up and Running and for more reading — https://kubernetes.io/docs/home/

--

--