Notes on Building a Raspberry Pi Kubernetes Cluster (Part 2: The Nodes and Network)
For the first post in this series, see Part 1: the Hardware.
The Nodes and Network
Setting up my nodes and network was straightforward, but I’ll describe it here for completeness. The first thing that I had to do for each Pi was get it to boot and attach to my network, where I could then assign it an IP address.
I’m using Ubuntu Server 20.10 64-bit (arm64). This has a few disadvantages: There’s no raspbi-config, so it’s harder to configure WiFi and GPIO settings (which I don’t plan to use), and graphics support isn’t as good — when I tried installing Ubuntu Desktop on a Pi with an attached touchscreen, the screen resolution was too low to display the install dialogs, putting important buttons off-screen (but getting video out of my nodes isn’t a priority for me). Ubuntu’s advantages made it my choice: a mature 64-bit OS, sshd enabled by default, and as I later discovered, Canonical publishes a packaged version of Kubernetes called Microk8s that can be easily installed with the snap package manager. After some brief early experiments, Microk8s has been my Kubernetes of choice and seems to work well.
My desktop is also an Ubuntu (amd64) system and is one of the platforms that runs the convenient Raspberry Pi Imager, which will download and install a user-selected OS image to an SD card (my SD card writer is this SanDisk MobileMate USB 3.0 microSD Card Reader, but anything that you have will probably work).
At larger scales, you might want to automate customization of your Ubuntu images, but I’ve just been setting mine up manually.
After writing the card, I install it in the Pi, connect the Pi to my local network (with a cable), and turn it on. I use a Google WiFi at home, so my next step is to look in the Google WiFi app for a new “Raspberry Pi” device (it’s a good idea to add devices one at a time), and then assign this device a name and an IP address. I planned ahead and chose a block of 8 IP addresses near the top of my local address range and have been assigning these to my nodes. My Google WiFi DHCP server associates these addresses with the Pi MAC addresses (as one does), so these addresses won’t change even if the OS is replaced.
Once I’ve restarted the Pi, I can log into it at its assigned address, which I also add to /etc/hosts on my Ubuntu desktop. Ubuntu Server installs with a default user named “ubuntu” with password “ubuntu” and forces you to change that when you first login. Once I’ve done that, I log out and use scp to copy some SSH configuration to the node (authorized_keys, id_rsa, and id_rsa.pub to the ubuntu user’s .ssh directory). Then I can more easily manage my node remotely — for example, shutting it down with
ssh ubuntu@fury “sudo shutdown -h now”
Next: Installing Kubernetes