DEV Community

Cover image for Easy Home Lab Setup of KIND & MicroK8s

Posted on • Originally published at

Easy Home Lab Setup of KIND & MicroK8s

After installing minikube on my Ubuntu VM which is running in Vagrant, on top of my windows 10 desktop. I started to notice some performance issues which ended up with frequent minikube restarts and constant VM reboots. Then on the internet, I found another way or actually two ways to run my k8s cluster lab setup on my local virtual environment using KIND & MicroK8s, which i would like to share with the community. So the steps are as follows,

So, what is KIND ?

KIND is a tool that allows you to run local Kubernetes clusters using Docker container “nodes”. It is primarily designed for testing Kubernetes itself, but it can also be used for local development or continuous integration (CI). With KIND, you can create a Kubernetes cluster within minutes. It supports multi-node (including high availability) clusters and building Kubernetes release builds from source.

First lets build our VM using Vagrant and Virtualbox, you can get the steps from here.

Setting up the Vagrant directory & file

Open your Powershell terminal, create a directory and initiate vagrant to generate boilerplate file called Vagrantfile, which will be the config file for your vagrant ubuntu VM.

> mkdir Ubuntu_20_04; cd Ubuntu_20_04; mkdir data

> vagrant init
Enter fullscreen mode Exit fullscreen mode

Init setup

Init setup

Vagrant init

Modify the Vagrantfile to get Ubuntu 20.04 and other necessary configurations as below

Vagrant.configure("2") do |config| #start of the config = "generic/ubuntu2004" #get ubuntu 20.04 generic image

    config.vm.synced_folder "./data", "/vagrant_data" #make a dir to share files between host & VM "private_network", ip: "" #set the ip as private

    config.vm.provider "virtualbox" do |vb| #use virtualbox to provision the VM

        vb.gui = true #set GUI while starting the VM

        vb.memory = "8192" #set RAM for VM

        vb.cpus = 4 #set CPU count for VM



Enter fullscreen mode Exit fullscreen mode

Now start the vagrant VM

> vagrant up

Vagrant up

Login to the ubuntu VM as vagrant user

> vagrant ssh

Vagrant ssh
Lets get the requirements to run KIND (Kubernetes in Docker)
We need 2 components to run Kind in our virtual environment, as per official documentation. first its golang & second is container engine (Docker or Podman)

To install golang, you can follow below steps

$ wget

$ sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz

$ export PATH=$PATH:/usr/local/go/bin
Enter fullscreen mode Exit fullscreen mode

get go1

get go2
Now, lets install Docker using below commands

$ curl -fsSL | sudo apt-key add 

$ sudo add-apt-repository "deb [arch=amd64] focal stable"

$ sudo apt update

$ sudo apt install docker-ce docker-ce-cli

$ sudo systemctl status docker

$ sudo usermod -aG docker $USER && newgrp docker
Enter fullscreen mode Exit fullscreen mode

get docker1

get docker2

get docker3

Now get Kind packages to create our K8s cluster

$ [ $(uname -m) = x86_64 ] && curl -Lo ./kind

$ chmod +x ./kind

$ sudo mv ./kind /usr/local/bin/kind

$ kind create cluster
Enter fullscreen mode Exit fullscreen mode

get kind1

get kind2

Now, we need Kubectl to interact with our cluster setup.

$ sudo apt-get install -y apt-transport-https ca-certificates curl

$ curl -LO "$(curl -L -s"

$ curl -LO "$(curl -L -s"

$ echo "$(cat kubectl.sha256)  kubectl" | sha256sum --check

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

$ kubectl cluster-info --context kind-kind 
Enter fullscreen mode Exit fullscreen mode




Now we have our lab K8s setup using Kind, which we can use to test & learn K8s. To delete the setup we can use the below command.

$ kind delete cluster


If you are bored with single node cluster, we have provision to create a multinode cluster in Kind using a config.yaml file, like below example

$ vim kind-config.yaml

kind: Cluster



- role: control-plane

- role: worker

- role: worker

Enter fullscreen mode Exit fullscreen mode

$ kind create cluster --config kind-config.yaml



So, This is how you can setup your local K8s cluster using Kind.

If you are lazy like me and don't want to perform such monotonous steps to get things work, we have alternate solution as well.

Say hello to MicroK8s

MicroK8s is a lightweight, pure-upstream Kubernetes distribution that aims to reduce entry barriers for Kubernetes and cloud-native application development. It is designed to provide a full Kubernetes experience for devices with limited computing power and memory. With MicroK8s, you can install a single-node (standalone) Kubernetes cluster in under 60 seconds. It comes in a single package that installs a barebones upstream Kubernetes. Additional services like DNS and the Kubernetes dashboard can be enabled using the "microk8s enable" command.

MicroK8s supports multi-node clusters, high availability, and distributed storage. It also provides self-healing high availability, transactional over-the-air updates, and secure sandboxed kubelet environments.

Lets see how we can install MicroK8s in our Ubuntu VM

$ sudo snap install microk8s --classic

$ sudo usermod -a -G microk8s $USER && newgrp microk8s

$ microk8s status --wait-ready

$ microk8s kubectl get all --all-namespaces

Enter fullscreen mode Exit fullscreen mode



We can enable a dashboard to view and manage our K8s cluster running in MicroK8s, using

$ microk8s dashboard-proxy

Supply the generated login token on your localhost URL in our case its ""



And this is how the GUI dashboard will look like,

$ microk8s stop


So, that's all folks. Do try to setup your local K8s environment and let me know your thoughts. As always, Thanks for reading...!

Top comments (0)