Notes on Building a Raspberry Pi Kubernetes Cluster (Part 1: The Hardware)

Late last year I started thinking about building a Raspberry Pi cluster. For years I’d read about people running Kubernetes on Raspberry Pis and thought that the experience of building a Pi cluster would be a great learning exercise, but didn’t want to build a cluster to just run toy projects. But when the Pi 4 appeared, I felt that the time had come to try to build something useful (and fun).

The Hardware

Early this year I started gathering parts; first a couple of Pi 4 boards from Adafruit, and then after looking at lots of cluster racks I found a hardware setup that I liked: the UCTRONICS Pi 4 rack mount, which lets me mount four Pi 4s in a 1U rack mount and includes adapters to bring the Pi’s HDMI ports to the front of the rack. Since I didn’t already have a rack (and didn’t want a big one), I got the StarTech 8U Desktop Rack which gives me a nice light assembly that I can easily carry back and forth between my garage workbench and my desk. It’s bigger than most Pi cluster racks but sturdy and has plenty of room for growth and change.

Power over Ethernet was another factor that made it easy to commit to this. With PoE, each Pi would only need one connection (a CAT-6 cable), and I wouldn’t have to deal with a pile of power adapters and tangled cords. Although I found several different PoE adapters available, I decided to play it safe and chose the Official Raspberry Pi PoE Hat and ordered a Netgear 16-Port PoE switch to power everything. Advertised as supporting 183W, and with the Raspberry Pi 4 spec recommending 15W per Pi 4, this seemed enough to support a dozen Pi 4s, though eight seemed like a good target for now.

Here’s the full parts list:

Parts and price list for an 8–way Raspberry Pi 4 cluster, Feb 2021

I didn’t order everything at once. I started with a couple of Pi 4s, then got the rack, mounts, PoE switch, and some patch cables, then a shelf for the switch and the MicroSD cards. Also, because I was wanting to order from Adafruit, I could only get one 8GB Pi 4 per order so I wound up getting a mix of 8GB (three), 4GB (two), and 2GB (one) Pis until I eventually broke down and ordered three 8GB Pi 4s from Newark, which had no per-order quantity limits.

Currently I have four Pi 4s in my rack with two on the way from Adafruit and 3 coming from Newark — I’ll probably drop the 2GB from the cluster when the others arrive and have six 8GB and two 4GB Pi 4s… though I’m curious to see if the memory differences noticeably affect performance of my nodes. I’m also still waiting for the PoE hats, so you’ll see power adapters in some of the early photos below.

The shelf is on top for easy access to the switch, but this rack just takes minutes to rearrange!
The PoE hats aren’t here yet, but when they are, CAT-6 cables will be the only connections to most of the Pis.
Messy but working, here I have 2 8GB, one 4GB, and one 2GB Pi 4s, all USB-powered (no PoE hats yet), and a portable hard drive.

Update (Feb 22): Five PoE hats arrived today and two more Pis. Here are some photos.

The bottom side of a PoE hat
One rail filled with Pis, with PoE hats installed on the top three. Note how the screws mounting the boards to the rail prevent use of two of the standoffs that came with the PoE hats.

Update (March 6): I had a SmartiPi Touch 2 case and touchscreen that I’d ordered before I decided to build this cluster and a 1U spacer that I’d been thinking of using to mount my switch. Yesterday I spent Friday evening mounting the case to the spacer and my cluster got a head:

Unfortunately the screen only pivots down (and not back), but it’s still at a decent viewing angle. I tried flipping it to hang downward but didn’t have great results reconfiguring the Pi behind the touchscreen for upside down display — it’s a bit harder using Ubuntu instead of Raspbian, but the Kubernetes support on Ubuntu makes that worth it. I’ll post more on that later, but now my cluster is nine Pi 4s (six 8GB, two 4GB, one 2GB) and running smoothly.

Next: The Nodes and Network.

Software developer in the SF Bay area. Electronic Design Automation, iOS apps, and now API tools for the world’s largest computer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store