Creating a MicroK8s Cluster and Adding a Node

Cluster Setup:

sudo apt update && sudo apt install nfs-common -y
sudo snap install microk8s 
sudo usermod -a -G microk8s $USER
sudo su - $USER
microk8s.status --wait-ready
microk8s.disable ha-cluster
  • Configure MicroK8s:
sudo mkdir -p /var/snap/microk8s/current/args
sudo echo "--allow-privileged=true" >> /var/snap/microk8s/current/args/kube-apiserver
microk8s.status --wait-ready
microk8s.enable dns storage ingress
microk8s.status --wait-ready
  • Restart MicroK8s:
microk8s.stop
microk8s.start
microk8s.status --wait-ready
  • Export kubeconfig:
microk8s.config > ~/.kube/config

Adding a Node:

  • Install MicroK8s on new machine.
  • Generate join command on main node:
microk8s add-node
  • Execute join command on new node:
microk8s join <main_node_ip>:25000/<token>/<hash> --worker

Enhance Convenience:

  • Enable MicroK8s dashboard addon.
  • Configure kubectl:
microk8s enable dashboard
microk8s config > ~/.kube/config

By following these steps, you'll swiftly create a MicroK8s cluster, add a new node, and optimize your setup for efficient management.