I came accross a video on Youtube, where Jeff Geerling was introducing his Kubernetes cluster thats was built on a bunch of Raspberry Pis. At that moment I decided I want one, too. I had a couple of old Raspberry Pis lying around, but I knew I had to buy more to get a cluster working decently. The first version that was later on upgraded a bit, was put together from these components:

  • Raspberry Pi 2 1GB RAM with 16GB SD Card
  • Raspberry Pi 4 8GB RAM with Western Digital 500GB USB3 HDD
  • Raspberry Pi 4 8GB RAM with Wester Digital 2TB USB3 HDD

Since my Raspberry Pi 2 couldn’t boot from USB, I decided to use log2ram, which saves SD card from wearing and writes logs to RAM instead.

K3s is a lightweight Kubernetes distribution. Therefore it was an obvious candidate for my tiny cluster considering that master node would be Rpi2, while the two Rpi4s would be in worker roles. To simplify the installation even further, I used k3s-ansible, which takes care of all the mundane tasks, after you have setup a couple of variables.

It took me about an hour to get a working cluster. Here are the steps.

  • I installed rpi-imager from AUR to my Arch Linux laptop.
  • Followed the instructions to create a SD card, with which you can change the boot mode to USB. Once both Rpi4s were booting from USB, I used rpi-imager to “burn” Raspberry Pi OS Lite 64-bit to my USB HDD drives.
  • Last thing before booting the RPis was to “burn” the Raspberry Pi OS Lite 32-bit (not 64-bit, mind you) with rpi-imager to SD card and insert it to Rpi2.

Once the hardware was in place, it was time to take look at network. Nodes need static IP addresses. From the two options (configure OS to use static address or set DHCP server to give the same address based on MAC address), I chose the latter.

Operating system preparations where quickly done. I had two steps:

  • Change hostname.
  • Configure SSH keys for logins without password.

The actual installation is, thanks to Ansible, the most boring part. Following the repository instructions you just change the settings in hosts.ini and all.yml and run the playbook. Once it is finished, fetch the configuration file and install kubectl on your workstation. Those steps are optional, but I assume most of us want to manage the cluster remotely and don’t want to login to master node to do the changes.

I have already some plans for the second version of this cluster. I will replace the Rpi2 master node with a third Rpi4 and SATA SSD with SATA-to-USB3 cable with UASP support. With three more capable nodes I can also take advantage of the HA mode with embedded etcd database.

In this post I only showed, how to setup the cluster. This is intentional, because I don’t want to create a monster post, which describes everything at once. I will later write about the applications I run on this cluster (Nextcloud, Pi-hole, Hugo etc.)