Thursday, August 22, 2019

Minikube on VirtualBox Ubuntu


My primary goal was to try Kubernetes on VMs the simplest way. I have chosen minimal version of k8s called minikube and used a Virtualbox VM with Ubuntu 16.04. minikube creates a single-node cluster.

There is a problem with minikube on VirtualBox VM: minikube uses VirtualBox hypervisor for virtualization and thus requires VT-X support on host. However VirtualBox doesn’t support VT-X/AMD-v. That could be solved by using vm-driver=none option and Docker on host.

Firstly we need to install Docker following this guide. Install kubectl:


Make kubectl executable and move it to system path:

sudo chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

Now install minikube:
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.24.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

minikube version

Start minikube with vm-driver=none:
sudo minikube start -vm-driver=none

Here is an issue: root privileges are required to use minikube and kubectl (‘minikube start’ command outputs “When using the none driver, the kubectl config and credentials generated will be root owned and will appear in the root home directory”). To fix it run:

export CHANGE_MINIKUBE_NONE_USER=true
sudo -E minikube start -vm-driver=none

Let’s make the fix persistent so it will apply on system bootload:
echo ‘export CHANGE_MINIKUBE_NONE_USER=true’ >> ~/.bashrc

Check that everything works properly:
kubectl cluster-info