Steve mitchell in Kubernetes 5 minutes

Running Kubernetes on a Raspberry Pi Cluster

I loved trains as a boy, which may explain why I am running Kubernetes on Raspberry Pis for my home lab instead of in the cloud. Think of it like model railroading for computer geeks! In my earlier post, How to Configure Raspbian Linux, we installed and configured Raspbian Linux on all the Raspberry Pis. Now it’s time to add Kubernetes.

Kubernetes and Raspbian Locomotives
Kubernetes and Raspbian Locomotives

Choosing a Kubernetes Distribution

You have choices when it comes to a Kubernetes distribution for your Raspberry Pis. Here are just a few.

  • Canonical Micro8s
  • Minimal Kubernetes via kubeadm
  • Rancher Labs K3s
Rancher Labs k3s
Rancher Labs k3s

I selected Rancher for its popularity in the Raspberry Pi community. K3s is a highly available, certified Kubernetes distribution, yet the k3s binary is less than 40MB. The sweet spot for k3s is IoT (Internet of Things) and Edge devices. For instance, many national retailers put k3s in every store to run point-of-sale and other operational systems. Most importantly for our Raspberry Pi cluster is that K3S works great on ARM processors!

One of the differences in k3s is that Rancher replaced the etcd Kubernetes database with SQLite, allowing packaging of k3s as a single binary. It also allows you to run in HA (high availability) mode with a single master node using an external SQLite database cluster. K8s can’t do that. You can also achieve HA with multiple k3s master nodes, the same as k8s.

Installing K3s

If you decide to install k3s on your own Raspberry Pi’s, follow these tips that walk you through the process.

Installing a Kubernetes Dashboard

Kubernetes includes a dashboard, but you have options if you want something different.

Centralized Logging

Things can go wrong with your Raspberry Pi nodes. Trust me; I have some first-hand experience; that is why I set up my cluster to send the logs off-node, enabling me to examine them separately if the node goes down.

If you installed Rander k3s, use the “kill all” command to drain your nodes before shutting down. While writing this post the batteries in my UPS went bad it began blaring its alarm. I issued the “kill all” to all the worker nodes and shut them down, then I did the same on the primary node. After removing the failing UPS power supply I powered the cluster back on and everything started normally.

1
/usr/local/bin/k3s-killall.sh

That’s it for now. In my next post, I will begin deploying a workload to my new cluster.

Before I sign off, here is a peek at my current eight-node cluster as of Thanksgiving, 2020:

Raspberry Pi Cluster
Raspberry Pi Cluster

References