(Last Updated On: May 27, 2018)

Minikube is a tool developed to help you run a single cluster of Kubernetes on your local machine. Minikube works by starting a single node kubernetes cluster locally for purposes of development and testing. It packages and configures a Linux VM, Docker and all Kubernetes components, optimized for local development.

Minikube supports Kubernetes features such as:

  • DNS
  • NodePorts
  • ConfigMaps and Secrets
  • Dashboards

As of this writing, Minikube does not yet support Cloud Provider specific features such as:

  • LoadBalancers
  • PersistentVolumes
  • Ingress

Most Minikube setups available online are for VirtualBox as a hypervisor for the VM. If you’re a frequent visitor of my blog, you must have noticed I’m a big fan of KVM. So this guide is for those who want to run Minikube but on KVM.

Setup Requirements

To run Minikube on KVM, you need to install some libraries and drivers required for communication with the Virtualization layer. These are:

  • Docker machine – This is a tool that lets you install Docker Engine on virtual hosts, and manage the hosts with docker-machine commands
  • Docker Machine KVM2:  This is a plugin driver for docker machine on KVM.
  • Qemu and Libvirt – Hypervisor and Virtualization API Library
  • Minikube and kubectl

Step 1: Installing KVM – Libvirt and Qemu

I already wrote an article on Installing and Configuring KVM on Various Linux distributions. Below is the link:

Install KVM on CentOS 7 / Ubuntu 16.04 / Debian 9 / SLES 12 / Arch Linux

Step 2: Install Docker-machine

Installation of docker machine will vary from one distribution to another. But when you have docker community repository added to your System, you can install docker-machine from OS package manager. Our guide on installing Docker has a step of adding the repository:

How to install Docker CE on Ubuntu / Debian / Fedora / Arch / CentOS

You can also take a look at Official Docker machine page.

Step 3: Download minikube

You need to download the minikube binary. I will put the binary under /usr/local/bin directory since it is inside $PATH.

# wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O  /usr/local/bin/minikube
--2018-05-27 21:55:35--  https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Resolving storage.googleapis.com (storage.googleapis.com)... 216.58.223.112, 2a00:1450:401a:805::2010
Connecting to storage.googleapis.com (storage.googleapis.com)|216.58.223.112|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 42763827 (41M) [application/octet-stream]
Saving to: ‘/usr/local/bin/minikube’

/usr/local/bin/minikube                    100%[======================================================================================>]  40.78M  15.6MB/s    in 2.6s    

2018-05-27 21:55:38 (15.6 MB/s) - ‘/usr/local/bin/minikube’ saved [42763827/42763827]

Make the file executable:

# chmod +x /usr/local/bin/minikube
# minikube version
minikube version: v0.27.0

For Arch Linux users, you can install minikube from AUR:

$ yaourt -Sy minikube-bin

Step 4: Install kubectl

We need kubectl which is a command line tool used to deploy and manage applications on Kubernetes.

$ curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
$ chmod +x kubectl
$ sudo mv kubectl  /usr/local/bin/
 
$ kubectl version -o json 
{
  "clientVersion": {
    "major": "1",
    "minor": "10",
    "gitVersion": "v1.10.2",
    "gitCommit": "81753b10df112992bf51bbc2c2f85208aad78335",
    "gitTreeState": "clean",
    "buildDate": "2018-04-27T09:22:21Z",
    "goVersion": "go1.9.3",
    "compiler": "gc",
    "platform": "linux/amd64"
  }
}

For Arch Linux users, you can also install this from AUR:

$ yaourt -Sy kubectl-bin
$ kubectl version

Step 5: Install Docker Machine KVM driver

The last item to install is the Docker machine driver for KVM. Download the binary and make it executable.

$ curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2
$ chmod +x docker-machine-driver-kvm2
$ sudo mv docker-machine-driver-kvm2 /usr/local/bin/

The package is available from AUR for Arch Linux users:

$ yaourt -Sy docker-machine-driver-kvm2

Step 6: Starting minikube

With all components installed, you should be ready to start minikube with KVM driver. It will download VM image and configure Kubernetes single node cluster for you. Easy work!!..

$ minikube start --vm-driver kvm2

Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Downloading Minikube ISO
150.53 MB / 150.53 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Downloading kubeadm v1.10.0
Downloading kubelet v1.10.0
Finished Downloading kubeadm v1.10.0
Finished Downloading kubelet v1.10.0
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

Wait for the download and setup to finish then confirm that everything is working fine. You should see a running VM with a domain named minikube.

$ sudo virsh list
 Id    Name                           State
----------------------------------------------------
 2     minikube                       running

Minikube Basic operations

Check cluster status:

$ kubectl cluster-info

Kubernetes master is running at https://192.168.39.117:8443
KubeDNS is running at https://192.168.39.117:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Minikube configuration file is located on:

~/.minikube/machines/minikube/config.json

To View Config, use:

$ kubectl config view

apiVersion: v1
clusters:
- cluster:
    certificate-authority: /home/jmutai/.minikube/ca.crt
    server: https://192.168.39.117:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /home/jmutai/.minikube/client.crt
    client-key: /home/jmutai/.minikube/client.key

Check nodes:

 $ kubectl get nodes

NAME       STATUS    ROLES     AGE       VERSION
minikube   Ready     master    13m       v1.10.0

Access minikube VM using ssh:

$ minikube ssh

                         _             _            
            _         _ ( )           ( )           
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __  
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ sudo su -

To stop a running local kubernetes cluster, run:

$ minikube stop

To delete a local kubernetes cluster, use:

$ minikube delete

Step 7: Enable Kubernetes Dashboard

Kubernete ships with a web dashboard which allows you to manage your cluster without interacting with a command line. The dashboard addon is installed and enabled by default on minikube.

$ minikube addons list

- addon-manager: enabled
- coredns: disabled
- dashboard: enabled
- default-storageclass: enabled
- efk: disabled
- freshpod: disabled
- heapster: disabled
- ingress: disabled
- kube-dns: enabled
- metrics-server: disabled
- registry: disabled
- registry-creds: disabled
- storage-provisioner: enabled

To open directly on your default browser, use:

$ minikube dashboard

To get the URL of the dashboard

$ minikube dashboard --url
http://192.168.39.117:30000

Open the link on the browser to access the Dashboard.

The next thing to do is check getting started with Minikube guides like: