How I set up a simple Raspberry Pi cluster using microk8s

12th July 2024

After endlessly surfing through docs and youtube videos I was able to set up my pis to build a cluster! This is exactly how I did it

Requirements

  • At least 2 raspberry pis with an OS and ssh enabled connected on the same network
    • I strongly recommend raspberrypi lite, it's simple and made for the pi
    • I used 1 raspberry pi 5 8gb and 2 raspberry pi 3b+
  • that's it.

Why microk8s?

  • Light-weight: 40% the amount of memory usage when compared to standard kubernetes
  • Supports ARM by default(the architecture all pis run)
  • Easy to use, and extremely convenient to connect worker nodes

On each node

  • Install snapd
    $ sudo apt update
    $ sudo apt upgrade -y
    $ sudo apt install snapd -y
  • Install microk8s via snapd
    $ sudo snap install microk8s --classic --channel=1.23/stable
  • Run microk8s as sudo by default
    $ sudo usermod -a -G microk8s $USER
    $ sudo chown -f -R $USER ~/.kube
    $ newgrp microk8s

On the master node

$ microk8s status --wait-ready
$ microk8s enable dns dashboard storage
$ microk8s add-node

This command will then proceed to output a command that looks like this

microk8s join <master-ip>:25000/<token>

On the worker node/(s)

Simply run

microk8s join <master-ip>:25000/<token>

Note: do not use the same command for more than one worker node

Done!

That's it, you now have your very own pi cluster! This is mine: My Pi server