Kubernetes with Docker and Minikube

Kubernetes is getting more popular every day. Kubenertes is an open source system for automating deployments, scaling and managing containerized applications. Created by Google on 2014 and also know as k8s. Why? Because there are 8 letters between k and s :-).

K8s has many features such as Automatic bin-packing which is the capability of placing containers based on resources and constraints.  K8s also has horizontal scaling, storage orchestration using local storage or cloud storage such as AWS or GCP.

K8s has important Cloud native capabilities such as Self Healing, Service Discovery and Load Balancing and secret and dynamic config management. For this blog post, we will see how to bake a simple docker image using node js application and deploy this docker image on hibernates using minikube in order to run locally.

There are other cloud-native solutions such as NetflixOSS Stack. Also Spring Cloud, which uses NetflixOSS too. However, on this post, we will be focusing on Docker and Kuerbenete .

Running Minikube on Ubuntu Linux 17.04

You can do it with other Linux distributions such as 16.04 LTS for instance, however, I will show in Ubuntu Linux 17.04 because of thats the distro I'm currently using. In theory, it should be very straight forward to get Minikube up and running on Linux. However is not that easy. If you search on the internet you will see lots of people complaining about:

Some people spend days to figure this out, lots of open issues on GitHub and threads on stack overflow. Las t night I spent 3hours to figure out what was going on.

There are also sorts of trying this, try that. Some folks said Minikube is not stable on Ubuntu Linux 17.04 but actually that all wrong. The issue is Virtualbox. Every time I update VirtualBox something stop working like Vagrant, Docker or Kubernetes. So the fix is pretty simple but you need to keep in mind that every time you update VirtualBox you need do this.

Installing Minikube and kubectl

Alright! Let's get down to business and install Minikube and kubecetl on our Linux. First commands will wipe out all previous installations this works well for the first time installs and also for upgrade scenarios. The beauty of minikube is you can continue working normally with kubectl console tool. So there is no difference if you running minikube locally or running k8s on GKE or AWS with Kops.It all works in the same way.

Baking NodeJS Docker image 

So let's build a simple node js application and also bake a docker image with this application. Let's get to the Javascript code. The main reason I'm showing this code in JavaScript is that is some small and concise. We could do it in other languages but for sake of simplicity and focus on Kubernets and minikube let's go with JS.

We also need to have a Dockerfile in order to bake the image. Ther we go.

Deploying to Kubernetes

Now it's time. Let's start minikube and push this docker image to minikube dockers registry and see this app running on our local Kubernetes.

There are some important things to keep in mind such eval $(minikube docker-envwhich does the trick to integrate our local docker with minikube. Otherwise, the kubernetes registry will try to download images from public docker hub.


You also can take a look on the kubernetes dashboard and check our app if you want. To do it so you do $ minikube dashboard and go to!/workload?namespace=default As you can see your image is there. This dashboard is very useful you can use it to check information about your containers and also deploy new containers.

All right that's it. Have fun!

Diego Pacheco

Popular posts from this blog

Podman in Linux

Java Agents

Manage Work not People