Have you ever thought about turning those forgotten Raspberry Pi units gathering dust into a mini datacenter? In this blog post, I’ll walk you through my journey of building a Raspberry Pi cluster using Kubernetes (K3s) and Azure, focusing on practical steps and the lessons learned along the way.
Step 1: Gathering Your Raspberry Pis
The first step is to find some Raspberry Pis. I managed to dig up several Raspberry Pi 3 models from an old warehouse. While they’re a bit outdated, they still have plenty of potential for a cluster setup.
Step 2: Assembling Your Mini Datacenter
Choosing a Case
After some extensive research, I decided on the GeeekPi Raspberry Pi Cluster Case, which accommodates eight Raspberry Pis and includes two 120mm cooling fans. I found it on Amazon for 188 AED, which was cheaper than local options.
You can check it out here.
Powering the Raspberry Pis
Powering the Pis can be tricky. Initially, I used a family USB charging hub (Anker 6-port, 63W), but it couldn’t consistently handle the power needs of all the Pis, resulting in voltage fluctuations. For the Raspberry Pi 3, you’ll need about 2.4A at 5V, totaling around 12A for five devices.
There are three primary power options:
- Standard Mini USB: This is preferred due to voltage control but can complicate cabling.
- Power Pins: Requires careful connections.
- PoE (Power over Ethernet): A bit complex and requires additional hardware.
Ultimately, I opted for the USB option. The Anker hub wasn’t sufficient, so I found a reliable USB multi-hub, which supports up to 3.4A across its ports. You can find it here.
Networking: Choosing a Switch
For networking, I needed a compact gigabit switch that could fit inside the cluster case. I settled on a D-Link 5-port unmanaged switch. While it fits perfectly, it limits me to five devices. If I want to expand later, I may need to relocate the switch outside the case.
Additional Components
- USB Type A Cables: I selected short cables for cleaner cabling.
- Ethernet Cables: I opted for Cat 7 cables as they were under $1 each.
- USB Ethernet Adapter: This will provide an additional interface for the firewall.
Step 3: Setting Up the Cluster
Initial Setup
Now that I had everything, it was time to set up the Raspberry Pis. Here’s what I planned:
- One firewall with two Ethernet ports (trusted/untrusted).
- One master node for the Kubernetes cluster.
- Three worker nodes for Kubernetes.
Choosing an Operating System
I decided to go with a lightweight Linux distribution for the Kubernetes cluster and firewall.
Installing Azure CLI
Installing the Azure CLI was a bit of a challenge. Although Microsoft provides detailed instructions, I faced an issue related to Python compatibility.
After some troubleshooting, I found that renaming the bundled Python executable and linking it to the system Python solved the issue:
bashCopy codesudo ln -s /usr/bin/python3 /opt/az/bin/python3
Then, I completed the installation:
bashCopy codesudo python3 -m pip install azure.cli
Finally, I tested it with:
bashCopy codeaz --version
Installing Helm
For deploying applications on Kubernetes, I also needed Helm. I downloaded the appropriate version for ARM architecture and followed the installation instructions.
Conclusion
Setting up a Raspberry Pi cluster with K3s on Azure was an exciting project that involved creativity and problem-solving. Despite the challenges, the journey was rewarding. With this guide, I hope you feel inspired to dig out your old Raspberry Pis and give them a new purpose in your own mini datacenter!
Stay tuned for future posts where I’ll share more about deploying applications using K3s and integrating with Azure. Happy clustering!