raspberry-pi-leaf-nodes-for-microk8s-cluster

Adding few low-cost Raspberry Pi nodes to improve your MicroK8s performance


MicroK8s Cluster on Raspberry Pi 4 Model B 8GB (Part II)

(Total Setup Time: 45 mins)

Following up from the previous post, for this second part, I will be adding new Raspberry Pi nodes to the MicroK8s Cluster. However, other than Raspberry Pi, you can also re-purpose some of your older unused laptop or PC and add them to your MicroK8s cluster.

Creating new Pi nodes

(40 mins)

I will be using 2 of my older Pi 3B and using the same Ubuntu Server (64-bit) as my OS. The default username is ubuntu and password is ubuntu. Update the OS to the latest and perform all of the following steps:

sudo apt update
sudo apt upgrade

sudo snap install microk8s --classic
sudo usermod -a -G microk8s ubuntu
sudo chown -f -R ubuntu ~/.kube

sudo sed -i '$ s/$/ cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 swapaccount=1/' /boot/firmware/cmdline.txt

Finally, change its hostname by running:

sudo nano /etc/hostname
sudo nano /etc/hosts

For now, I will repeat the above process for the 2nd raspberry pi. Will plan to use Cluster SSH when I am ready to grow my cluster.

Master and Leaf nodes for your MicroK8s cluster

(5 mins)

On the appointed master node (typically the one which is more powerful in terms of processing power), run the following command for each node to be added:

sudo microk8s add-node

For each of the 2 newly created nodes, copy the output from the master node. The command will be similar to this:

microk8s join 192.168.xx.xx:25000/HWvrBvNWjIcOYAoSMfpxpwSbMkNHIfAX

To check if the nodes are joined successfully, from the master node run this command:

microk8s kubectl get node

That’s it! With this MicroK8s Cluster on Raspberry Pi 4 Model B 8GB in place, I am able to try out some of the cool things Kubernetes has to offer, and at the same time, to slowly offload our CI/CP pipelines to the cluster. Stay tuned on the next few topics on the different use cases of this lightweight cluster!

Troubleshooting

Joining as a node on the master node itself

If you have accidentally added as a node on the master node itself, simply leave the cluster:

sudo microk8s add-node
microk8s join 192.168.xx.xx:25000/HWvrBvNWjIcOYAoSMfpxpwSbMkNHIfAX # joining as a leaf node to ownself
microk8s leave # just leave!