Using Kubernetes for Local Development — Minikube

If you ops team are using Docker and Kubernetes, it is recommended to adopt the same or similar technologies in development. This will reduce the number of incompatibility and portability problems and makes everyone consider the application container a common responsibility of both Dev and Ops teams.

This blog post introduces the usage of Kubernetes in development mode and it is inspired from a screencast that you can find in Painless Docker Course.

Minikube is a tool that makes developers’ life easy by allowing them to use and run a Kubernetes cluster in a local machine.

In this blog post, for the examples that I tested, I am using Linux Mint 18, but it doesn’t change nothing apart the installation part.

cat /etc/lsb-release 
DISTRIB_DESCRIPTION=”Linux Mint 18.1 Serena”


In order to work with Minikube, we should have Kubectl and Minikube installed + some virtualization drivers.

curl -LO$(curl -s
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
curl -Lo minikube && chmod +x minikube && sudo mv minikube /usr/local/bin/
curl -LO

Add the binary to your PATH (This article explains how to modify the PATH)

Download the minikube-windows-amd64.exe file, rename it to minikube.exe and add it to your path.

Find the last release here.

curl -LO$(curl -s
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
curl -Lo minikube && chmod +x minikube && sudo mv minikube /usr/local/bin/

Using Minikube

Let’s start by creating an image from this Dockerfile:

FROM busybox
ADD index.html /www/index.html
CMD httpd -p 8000 -h /www; tail -f /dev/null

Add something you’d like to see in the index.html page.

Build the image:

docker build -t eon01/hello-world-web-server .

Let’s run the container to test it:

docker run -d --name webserver -p 8000:8000 eon01/hello-world-web-server

This is the output of docker ps:

docker ps

2ad8d688d812 eon01/hello-world-web-server "/bin/sh -c 'httpd..." 3 seconds ago Up 2 seconds>8000/tcp webserver

Let’s commit the image and upload it to the public Docker Hub. You can use your own private registry:

docker commit webserver
docker push eon01/hello-world-web-server

Remove the container since we will use it with Minikube

docker rm -f webserver

Time to start Minikube:

minikube start

Check the status:

minikube status

We are running a single node:

kubectl get node

Run the webserver:

kubectl run webserver --image=eon01/hello-world-web-server --port=8000

A webserver should have it’s port exposed:

kubectl expose deployment webserver --type=NodePort

In order to get the service url type:

minikube service webserver --url

We can see the content of the web page using :

curl $(minikube service webserver --url)

To show a summary of the running cluster run:

kubectl cluster-info

For more details:

kubectl cluster-info dump

We can also list the pods using:

kubectl get pods

And to access to the dashboard use:

minikube dashboard

If you would like to access the frontend of the web application type:

kubectl proxy

If we want to execute a command inside the container, get the pod id using:

kubetctl get pods

Then use it like :

kubectl exec webserver-2022867364-0v1p9 -it -- /bin/sh

To finish, delete all deployments:

kubectl delete deployments --all

Delete all pods:

kubectl delete pods --all

And stop Minikube

minikube stop

I hope you enjoyed this introduction.

Connect Deeper

If you resonated with this article, you can find more interesting contents in Painless Docker Course.

You can also follow my free course, 10 Great Tips To Learn Docker.

We, Eralabs, will be happy to help you on your Docker and Cloud Computing projects, contact us and we will be happy to hear about your projects.

Please subscribe to DevOpsLinks (An Online Community Of Thousands Of IT Experts & DevOps Enthusiast From All Over The World) and if you are interested in getting only news and tutorials about Kubernetes, you can join Kaptain (A #Kubernetes Community Hub, Hand Curated Newsletter, Team Chat, Training & More).

You may be also interested in joining our newsletter Shipped, a newsletter focused on containers, orchestration and serverless technologies.

You can find me on Twitter, Clarity or my website and you can also check my books: SaltStack For DevOps.

Don’t forget to join my last project Jobs For DevOps !

If you liked this post, please recommend it and share it with your followers.