Create a Simple Kubernetes Cluster with MicroK8s


Kubernetes is a container orchestration tool for managing containerized workloads and services. For creating a Kubernetes cluster, you should set up a container runtime and other configurations to initialize it. With MicroK8s, you can initialize a Kubernetes cluster in a simple way for learning Kubernetes.


Two or more virtual machines for 1 master node and 1 or more worker node(s) with:

  • Ubuntu 20.04 or newer

  • 2 GB memory or more

  • 20GB storage or more

  • Internet access


  1. Installing MicroK8s on the master node and worker node(s)

    On the master node and worker node(s)

     sudo snap install microk8s --classic
     sudo usermod -aG microk8s $USER
     sudo chown -fR $USER ~/.kube
     su - $USER
  2. Joining worker node(s) to master node

    On master node

     microk8s add-node
     ---output omitted---
     Use the '--worker' flag to join a node as a worker not running the control
     plane, eg: microk8s join [master-node-ip]:25000/[some_value]/[some_value]--worker
     ---output omitted-

    On worker node(s)

     microk8s join [master-node-ip]:25000/[some_value]/[some_value] --worker
     ---output omitted---
     Currently, this worker node is configured with the following kubernetes API server endpoints:
     - [master-node-ip] and port 16443, this is the cluster node contacted during the join operation.
     ---output omitted---
  3. Enable add-on

    On master node

     microk8s.enable dns dashboard metrics-server rbac
  4. Setup kubectl

    On master node

     sudo apt install apt-transport-https --yes
     sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg
     echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
     sudo apt update
     sudo apt install kubectl -y
     microk8s.config > ~/.kube/config
     echo 'source <(kubectl completion bash)' >>~/.bashrc
  5. Labeling and tainting node(s)

     kubectl label [master-node-hostname]""
     kubectl label [worker-node-hostname1]""
     kubectl taint [master-node-hostname1]
     kubectl label [worker-node-hostname(n)]""
     kubectl taint [master-node-hostname(n)]