Skip to content

Installing a Kubernetes Cluster using minikube

Photo by Eva Elijas from Pexels

minikube is the easiest method to deploy a Kubernetes cluster for testing purpose. You can simply spin up a cluster in minutes on your laptop or workstation and can use it for your testing purpose, PoC or whatever local environment setup.

minikube will need a hypervisor (VirtualBox or KVM) to work, but if you are already inside a virtual machine (and Nested Virtualization is NOT possible), then it is possible to skip the creation of an additional VM layer by using the none driver. But please note, you need to install and setup docker environment in that vm.

Only need to do some tests ?

There is a simple lab to experience and test minikube; use itย here.

Installing minikube

In this case, we will use a VM in Google Cloud (you can use local VM using VirtualBox or VMWare workstation).

Setup Docker or Virtualization

Here we are using docker instead of Virtualization (VirtualBox etc.). Hence we need to install docker for the same. Below steps are for Debian and you can refer documentation for other operating systems.(or Install Docker on Debian)

## remove any existing package
$ sudo apt-get remove docker docker-engine containerd runc

## Update the apt package index and install packages 
## to allow apt to use a repository over HTTPS:
$ sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \

## Add Dockerโ€™s official GPG key:
$ curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg  

$  echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

## Install docker and tools
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli

Install and Configure kubectl

You need kubectl to manage your cluster resources.

## Download kubectl
curl -LO "$(curl -L -s"

## Download the kubectl checksum file and Validate
$ curl -LO "$(curl -L -s"
$ echo "$(<kubectl.sha256) kubectl" | sha256sum --check

## Install 
$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Note: if you have issue with sudo access or other blockers, try below.

# Make the kubectl binary executable.
chmod +x ./kubectl
# Move the binary in to your PATH.
sudo mv ./kubectl /usr/local/bin/kubectl

Test to ensure the version you installed is up-to-date.

$ kubectl version --client

Download and Install minikube

# download and install package
$ curl -LO
$ sudo install minikube-linux-amd64 /usr/local/bin/minikube

# check version
$ minikube version
minikube version: v1.21.0
commit: 76d74191d82c47883dc7e1319ef7cebd3e00ee11

Configure to Run docker without sudo

Add your user to the docker group.

$ sudo usermod -aG docker $USER && newgrp docker

Start minikube

One command, and you will get a kubernetes cluster.

$ sudo minikube start --vm-driver=none --wait=false
๐Ÿ˜„  minikube v1.5.2 on Debian 9.11
๐Ÿคน  Running on localhost (CPUs=2, Memory=7483MB, Disk=10013MB) ...
โ„น๏ธ   OS release is Debian GNU/Linux 9 (stretch)
โš ๏ธ  VM may be unable to resolve external DNS records
๐Ÿณ  Preparing Kubernetes v1.16.2 on Docker '19.03.5' ...
๐Ÿ’พ  Downloading kubelet v1.16.2
๐Ÿ’พ  Downloading kubeadm v1.16.2
๐Ÿšœ  Pulling images ...
๐Ÿš€  Launching Kubernetes ... 
๐Ÿคน  Configuring local host environment ...

โš ๏ธ  The 'none' driver provides limited isolation and may reduce system security and reliability.
โš ๏ธ  For more information, see:

โš ๏ธ  kubectl and minikube configuration will be stored in /root
โš ๏ธ  To use kubectl or minikube commands as your own user, you may need to relocate them. For example, to overwrite your own settings, run:

    โ–ช sudo mv /root/.kube /root/.minikube $HOME
    โ–ช sudo chown -R $USER $HOME/.kube $HOME/.minikube

๐Ÿ’ก  This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true
โŒ›  Waiting for: apiserver
๐Ÿ„  Done! kubectl is now configured to use "minikube"
๐Ÿ’ก  For best results, install kubectl:

Now we have a running kubernetes cluster and let us see the status.

Verify cluster information

$ kubectl cluster-info

$ kubectl get nodes
NAME       STATUS   ROLES                  AGE   VERSION
minikube   Ready    control-plane,master   15m   v1.20.7

Kubernetes Dashboard

You can enable the dashboard as below. (Take another console to run it)

$ sudo minikube dashboard
๐Ÿค”  Verifying dashboard health ...
๐Ÿš€  Launching proxy ...
๐Ÿค”  Verifying proxy health ...

Usually minikube will open the browser with the dashboard URL if you are with GUI. Access the url and check access to the kubernetes cluster.

If you are running minikube inside a VM

Then accessing Dashboard from host machine (or from your laptop) is bit tricky. By default minikube dashboard will exposed as localhost:PORT. In above example, I have deployed the minikube inside a GCP (Google Cloud Platform) instance and see below how I am accessing the Dashboard.

on minikube VM

$ minikube dashboard
๐Ÿค”  Verifying dashboard health ...
๐Ÿš€  Launching proxy ...
๐Ÿค”  Verifying proxy health ...
๐ŸŽ‰  Opening in your default browser...

On my Laptop/Workstation

## Open an SSH tunnel 
## eg: ssh -L LOCAL_PORT:localhost:REMOTE_PORT [email protected]_VM_IP
$ ssh -L 36959:localhost:36959 [email protected]
[email protected]:~$ 

Now, open a browser on your laptop and access the same url (from the output of earlier minikube dashboard command)

Bingo !

Explore Kubernetes and get your hands dirty !

Letโ€™s test some application.

## Deploy an app
$ kubectl create deployment hello-minikube
$ kubectl expose deployment hello-minikube --type=NodePort --port=8080

$ kubectl get services hello-minikube

## let minikube open the browser
$ minikube service hello-minikube

## Alternatively, use kubectl to forward the port:
kubectl port-forward service/hello-minikube 7080:8080

For accessing the application, you can again use the ssh port forwarding method I have explained earlier.

LoadBalancer deployments

To access a LoadBalancer deployment, use the โ€œminikube tunnelโ€ command. Here is an example deployment:

$ kubectl create deployment balanced  
$ kubectl expose deployment balanced --type=LoadBalancer --port=8080

## In another window, start the tunnel to create a routable IP for the โ€˜balancedโ€™ deployment:

$ minikube tunnel

## To find the routable IP, run this command and examine the EXTERNAL-IP column:

$ kubectl get services balanced

## Your deployment is now available at :8080

Finished Testing ?

Once finished, if you do not need the cluster, simply pause or destroy the cluster.

## Pause Kubernetes without impacting deployed applications
$ minikube pause

## Halt the cluster:
$ minikube stop


  1. minikube startย exits with error onย GUEST_MISSING_CONNTRACK

Errorย โŒ Exiting due to GUEST_MISSING_CONNTRACK: Sorry, Kubernetes 1.20.7 requires conntrack to be installed in rootโ€™s path.


sudo apt-get install -y conntrack

Disclaimer: The views expressed and the content shared are those of the author and do not reflect the views of the author’s employer or techbeatly platform.

Gineesh Madapparambath is the author of the book - ๐—”๐—ป๐˜€๐—ถ๐—ฏ๐—น๐—ฒ ๐—ณ๐—ผ๐—ฟ ๐—ฅ๐—ฒ๐—ฎ๐—น-๐—Ÿ๐—ถ๐—ณ๐—ฒ ๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป. He has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (aka Gini Gangadharan -


4 Responses

  1. […] Installing a Kubernetes Cluster using minikube – July 1, 2021 […]

  2. Thanks very much for this, very informative!

    Quick note: for local workstation (i.e. not VM), should use –vm-driver=docker. This also allows non-administrator use. Not sure how new this is, but seems to have been introduced since your article.

  3. Yes, good point.

    Thank you for sharing.

  4. […] minikube is the most simple way to spin-up and use a Kubernetes cluster for your quick needs. You can install and use minikube clusters on Linux, Windows and Mac workstations without much knowledge about setting up a Kubernetes cluster. minikube will create a single VM cluster (by default) and you can adjust CPU and memory resources if you need more capacity for your Kubernetes cluster.  […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: