Multi-node Kubernetes cluster setup using Multipass/k3s (up-to-date)
I used microk8s to setup local Kubernetes. However, it is single-node. Can you setup multi-node Kubernetes cluster locally? The answer is yes and it is pretty simple.
This article is inspired by the following one, with some minor fixes:
I tested with Azure, so I need to enable nested virtualization on Ubuntu. Also you have to choose v3 series that has nested virtualization capability.
Enable kvm
sudo apt update
sudo apt install cpu-checker
# check if virtualization is enabled
kvm-oksudo apt install qemu-kvm libvirt-bin bridge-utils virtinst virt-manager
sudo usermod -aG kvm,libvirt $USER
sudo systemctl is-active libvirtd
Install multipass
sudo apt update
sudo apt install snapd
sudo snap install multipass
Install k3sup
curl -sLS https://get.k3sup.dev | sh
sudo install k3sup /usr/local/bin/
k3sup --help
Create 3 Ubuntu VMs
multipass launch — cpus 1 — mem 2G — disk 16G — name master-node — cloud-init multipass.yaml
multipass launch — cpus 1 — mem 2G — disk 16G — name agent-master — cloud-init multipass.yaml
multipass launch — cpus 1 — mem 2G — disk 16G — name agent-worker — cloud-init multipass.yaml
multipass ls
Install master node
k3sup install — ip 10.97.129.175 — user ubuntu — k3s-extra-args “ — cluster-init”
This command prints out kubeconfig file path.
Join agent/worker node (notice you need to use k3sup).
export KUBECONFIG=<kubeconfig path>
k3sup join — ip 10.97.129.67 — user ubuntu — server-ip 10.97.129.175 — server-user ubuntu
k3sup join — ip 10.97.129.200 — user ubuntu — server-ip 10.97.129.175 — server-user ubuntu
Voila! You have a multi-node Kubernetes cluster now.
Bonus
Apache flink/Apache Spark on Kubernetes
Kafka on Kubernetes
Airflow on Kubernetes