Minikube is a simple tool that enables running Kubernetes cluster locally on a single host without having to utilize a lot of resources. With minikube, Kubernetes is installed with a single command, making it easy to deploy. The created cluster is used for learning Kubernetes as well as carrying out tests and personal developments. In order to run Minikube, one requires a container or a virtual machine manager such as Docker, Hyper-V, KVM, Podman, Hyperkit, Parallels or VMware.

In this guide, we are going to look at the installation of Minikube to use VirtualBox as a diver. Virtualbox is Minikube’s original driver. In my set up, I am running Linux Mint 20. We need to also install VirtualBox locally for Minikube to use it as a driver. If you are running Linux mint, follow the following steps to install VirtualBox.

Install VirtualBox 6.x on Linux Mint 20

To install VirtualBox on Linux Mint 20, first add VirtualBox repository to your system using the below command.

echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian focal contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

Next, import VirtualBox repository public to your Ubuntu 20.04 by running the below command.

wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -

Now install virtualbox on Linux Mint 20 as below:

sudo apt update
sudo apt install -y virtualbox-6.1

Having installed VirtualBox, we are then going to install Minikube on our Linux Mint 20.

Install Minikube on Linux Mint 20

To install Minikube on Linux Mint 20 run the following commands:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_1.7.2-0_amd64.deb
sudo apt install ./minikube_1.7.2-0_amd64.deb

Now start Minikube with VirtualBox driver by running the below command:

$ minikube start –vm-driver=virtualbox
🔥  Creating virtualbox VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.17.2 on Docker 19.03.5 ...
💾  Downloading kubectl v1.17.2
💾  Downloading kubelet v1.17.2
💾  Downloading kubeadm v1.17.2
🚀  Launching Kubernetes ... 
🌟  Enabling addons: default-storageclass, storage-provisioner
⌛  Waiting for cluster to come online ...
🏄  Done! kubectl is now configured to use "minikube"

You will notice that a minikube VM will be created on your VirtualBox as shown below:

You can login with a user root as below:

You can also ssh into the minikube VM from your local machine as below:

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

Once you have accessed through ssh, you can check the vm hostname

$ hostname:
minikube

You can also check running containers:

$ docker ps -a
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS               NAMES
df0e8a92f7a0        70f311871ae1           "/coredns -conf /etc…"   13 minutes ago      Up 13 minutes                           k8s_coredns_coredns-6955765f44-gm894_kube-system_ca84c2c5-2fcb-462c-b5a9-20991700aef3_0
f68b032a8a17        70f311871ae1           "/coredns -conf /etc…"   13 minutes ago      Up 13 minutes                           k8s_coredns_coredns-6955765f44-tr5wl_kube-system_d39d2005-7644-421e-b23e-acc1f18ef1fd_0
4089c0259bd6        k8s.gcr.io/pause:3.1   "/pause"                 13 minutes ago      Up 13 minutes                           k8s_POD_coredns-6955765f44-gm894_kube-system_ca84c2c5-2fcb-462c-b5a9-20991700aef3_0
414b943db578        k8s.gcr.io/pause:3.1   "/pause"                 13 minutes ago      Up 13 minutes                           k8s_POD_coredns-6955765f44-tr5wl_kube-system_d39d2005-7644-421e-b23e-acc1f18ef1fd_0
0e1a3321f877        4689081edb10           "/storage-provisioner"   13 minutes ago      Up 13 minutes                           k8s_storage-provisioner_storage-provisioner_kube-system_4998c511-9825-4636-8c4d-d8a433b9e055_0
61e6cd43952a        k8s.gcr.io/pause:3.1   "/pause"                 13 minutes ago      Up 13 minutes                           k8s_POD_storage-provisioner_kube-system_4998c511-9825-4636-8c4d-d8a433b9e055_0
31f9340fa0ba        cba2a99699bd           "/usr/local/bin/kube…"   13 minutes ago      Up 13 minutes                           k8s_kube-proxy_kube-proxy-24qz7_kube-system_dcd2550d-686f-4edf-9f83-19e7b084d101_0
fa7842b0a53c        k8s.gcr.io/pause:3.1   "/pause"                 13 minutes ago      Up 13 minutes                           k8s_POD_kube-proxy-24qz7_kube-system_dcd2550d-686f-4edf-9f83-19e7b084d101_0
f4d8c83ccaaa        303ce5db0e90           "etcd --advertise-cl…"   13 minutes ago      Up 13 minutes                           k8s_etcd_etcd-minikube_kube-system_11cfaccf78867c0c4ee4e888308b0a1d_0
b3242e5c2b66        f52d4c527ef2           "kube-scheduler --au…"   13 minutes ago      Up 13 minutes                           k8s_kube-scheduler_kube-scheduler-minikube_kube-system_9c994ea62a2d8d6f1bb7498f10aa6fcf_0
a9136aeb3fe3        da5fd66c4068           "kube-controller-man…"   13 minutes ago      Up 13 minutes                           k8s_kube-controller-manager_kube-controller-manager-minikube_kube-system_0ae6cf402f641e9b795a3aebca394220_0
49f51789a30e        41ef50a5f06a           "kube-apiserver --ad…"   13 minutes ago      Up 13 minutes                           k8s_kube-apiserver_kube-apiserver-minikube_kube-system_bcfa63252833e5b041a29d7485a74d90_0
f7edac0397b8        k8s.gcr.io/pause:3.1   "/pause"                 13 minutes ago      Up 13 minutes                           k8s_POD_etcd-minikube_kube-system_11cfaccf78867c0c4ee4e888308b0a1d_0
c6f550e39bd1        k8s.gcr.io/pause:3.1   "/pause"                 13 minutes ago      Up 13 minutes                           k8s_POD_kube-scheduler-minikube_kube-system_9c994ea62a2d8d6f1bb7498f10aa6fcf_0
8e415ee42816        k8s.gcr.io/pause:3.1   "/pause"                 13 minutes ago      Up 13 minutes                           k8s_POD_kube-controller-manager-minikube_kube-system_0ae6cf402f641e9b795a3aebca394220_0
f17c3266f96b        k8s.gcr.io/pause:3.1   "/pause"                 13 minutes ago      Up 13 minutes k8s_POD_kube-apiserver-minikube_kube-system_bcfa63252833e5b041a29d7485a74d90_0
Get out of the VM by running exit command:

Get out of the VM by running exit command:

exit

Check minikube cluster info

$ kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443
KubeDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

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

Checking Minikube cluster nodes:

kubectl get nodes
NAME       STATUS   ROLES    AGE   VERSION
minikube   Ready    master   64s   v1.17.2

Managing Minikube on Linux Mint 20

The following commands are used to manage minikube installation

Check Minikube status:

$ minikube status
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

Stop minikube

$ minikube stop
✋  Stopping "minikube" in virtualbox ...
🛑  "minikube" stopped.

Start Minikube

$ minikube start
😄  minikube v1.7.2 on Linux mint 20
✨  Using the virtualbox driver based on existing profile
⌛  Reconfiguring existing host ...
🔄  Starting existing virtualbox VM for "minikube" ...
🐳  Preparing Kubernetes v1.17.2 on Docker 19.03.5 ...
🚀  Launching Kubernetes ... 
🌟  Enabling addons: default-storageclass, storage-provisioner
🏄  Done! kubectl is now configured to use "minikube"

Remove minikube

$ minikube delete

Check services

$ minikube service list
|-------------|------------|--------------|-----|
|  NAMESPACE  |    NAME    | TARGET PORT  | URL |
|-------------|------------|--------------|-----|
| default     | kubernetes | No node port |
| kube-system | kube-dns   | No node port |
|-------------|------------|--------------|-----|

Minikube enable Add-ons

Lets first check the supported add-ons by running the below command:

$ minikube addons list
|-----------------------------|----------|--------------|
|         ADDON NAME          | PROFILE  |    STATUS    |
|-----------------------------|----------|--------------|
| dashboard                   | minikube | disabled     |
| default-storageclass        | minikube | enabled ✅   |
| efk                         | minikube | disabled     |
| freshpod                    | minikube | disabled     |
| gvisor                      | minikube | disabled     |
| helm-tiller                 | minikube | disabled     |
| ingress                     | minikube | disabled     |
| ingress-dns                 | minikube | disabled     |
| istio                       | minikube | disabled     |
| istio-provisioner           | minikube | disabled     |
| logviewer                   | minikube | disabled     |
| metrics-server              | minikube | disabled     |
| nvidia-driver-installer     | minikube | disabled     |
| nvidia-gpu-device-plugin    | minikube | disabled     |
| registry                    | minikube | disabled     |
| registry-creds              | minikube | disabled     |
| storage-provisioner         | minikube | enabled ✅   |
| storage-provisioner-gluster | minikube | disabled     |
|-----------------------------|----------|--------------|

We can do ahead to enable one add-on, for example ‘metrics-server’

$ minikube addons enable metrics-server
🌟  The 'metrics-server' addon is enabled

To disable an enabled add-on, run the below command:

minikube addons disable metrics-server

How To deploy Applications with Minikube

Let’s deploy an Nginx app to a node using ‘create deployment’ command. A Kubernetes deployment checks on the health of a pod and restart’s a pod container in case it terminates. If a pod has an issue, it also moves the container to another pod. A pod is a group of one or more containers. Deployment is the recommended way for managing the creation and scaling of pods.

$ kubectl create deployment my-nginx --image=nginx --port=80
deployment.apps/my-nginx created
$ kubectl expose deployment my-nginx --port=80 --type=LoadBalancer
service/my-nginx exposed

Confirm the created deployment as below:

$ kubectl get deployments
NAME       READY   UP-TO-DATE   AVAILABLE   AGE
my-nginx   1/1     1            1           8s

View pod

$ kubectl get pods
NAME                        READY   STATUS    RESTARTS   AGE
my-nginx-5f49d7cfbf-4htrl   1/1     Running   0          12m

Minikube Scaling

To create more than one deployment and run multiple instances of your application, specify the number of instances as below:

$ kubectl scale --replicas 3 deployment/my-nginx
deployment.apps/my-nginx scaled

To access the shell of the pod, run the command below:

$ kubectl exec --stdin --tty my-nginx -- bin/bash
[email protected]:/#

In this guide, we have looked at how to install Minikube with Virtualbox. As explained earlier, Minikube works with a container or a virtual machine manager. The default driver for Minikube is Virtualbox. I hope this guide will be of assistance to you as you work into learning Kubernetes. Do not to check below more informative guides:

LEAVE A REPLY

Please enter your comment!
Please enter your name here

1 + 10 =