Install k8s Minikube on top of KVM on Debian 9

You want to do some Kubernetes on your laptop? You probably know that the solution is named Minikube.

Last time I tried to have minikube running on a debian, I had hard time finding the right way to do it, there’s so many outdated documentations out there that it’s easy to get lost.

My goal is to make Jenkins 2 running on Kubernetes and make use of Kubernetes scalability features to start as many containers our builds need so that we stop waiting for builds forever. I’ll write another article about that later.

My workmates now need to work on this Jenkins + k8s stuff and they probably don’t want to struggle as much as I did last time.

So I decided to make the Web messier and even more outdated by writing my own “it works today” article about the Debian 9 + k8s + KVM combo.

Enjoy (and feel free to contribute if there are things that could be enhanced).

Install KVM

The first step is to make KVM and libvirt to work. It’s quite simple, the first step is to install the right packages and put your user in the right groups (remember that you needed a new session for new group membership to apply) :

$ apt install qemu-kvm libvirt-clients libvirt-daemon-system
$ adduser myuser libvirt
$ adduser myuser libvirt-qemu

Then, as myuser

$ virsh — connect qemu:///system list — allId Name State
— — — — — — — — — — — — — — — — — — — — — — — — —

It returns an empty list and no error. That was easy. The hardest part was to find that documentation, right?

Install Minikube

Next step is to make use of Minikube. Minikube is a tool to bootstrap dev environments easily.

It first requires to install kubectl, the command for managing a k8s instance.

Did I already said I hate curling random binary from the internet? So, I searched for a more distribution-friendly solution and found this way :

$ apt install -y apt-transport-https
$ curl -s | apt-key add -
$ cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main
$ apt update
$ apt install -y kubectl

Now you can install minikube :

$ curl -LO
$ dpkg — force-depends -i minikube_0.25–0.deb

You probably noticed the —force-dependsoption? minikube documentation states that you can use it either on top of virtualbox or kvm. But the package manifest forces virtualbox dependency. I don’t like being forced to install virtualbox so I tell dpkg that I don’t want to honor this package’s dependencies.

You probably share my opinion, right? Then, just do the same.

Now, we unfortunately reach the random curl point, sorry. We need to install the right driver for docker-machine to use kvm and I didn’t found any workaround. I’m glad I install all that on a laptop dedicated to these tests !

$ curl -LO && chmod +x docker-machine-driver-kvm2 && sudo mv docker-machine-driver-kvm2 /usr/bin/

Starting k8s

Well, for some reason, minikube requires default libvirt network to be activated, so let’s do that :

$ virsh — connect qemu:///system net-start default

Finally, we can launch k8s :

$ minikube start — vm-driver kvm2

After some time, it says it’s ready. At this point, k8s is running on top of kvm and you can access the web dashboard.

$ minikube dashboard

If everything goes well, you should have the k8s opened in your browser now, ready to deploy services at scale.

But wait, a howto is not finished without a hello-world of some kind, right?

Here is how you do hello-world on k8s :

$ kubectl run hello-minikube — — port=8080
$ kubectl expose deployment hello-minikube — type=NodePort
$ curl $(minikube service hello-minikube — url) -d hello world

It runs a container with an http server echoing input request data as a response, then it exposes the service and finally you curl it.

That’s amazing, isn’t it?

You can find more information regarding minikube on .




We are Open Source Engineers, Hacking Awesome Stuff

Recommended from Medium

How to establish a Developer Student Club at your campus

A New and Improved Time to SLA for Jira Cloud

Slang — notes


Introducing Beacon Support in Thanos Wallet

Catch Leak If You Can!

Talk to Me App, Part 3

Mobile Development Weekly Issue 23

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium

GKE Ingress redirect http to https

Heterogeneous Storage Monitoring for Kubernetes

Know the Role of K8S Service Account in Granting Access

Kubernetes Audit Logs: Who created or deleted a namespace?