Engineer Dino Fizzotti has written a guide to setting up a Kubernetes-based cluster using low-cost Raspberry Pi single-board computers, from initial provisioning with Ansible through to running a to-do application programming interface (API) — complete with monitoring and reporting.
Learning cluster computing concepts is a great way to add a seriously useful tool to your arsenal, and today the ready availability of low-cost single-board computers like the Raspberry Pi family means it's easier than ever. Earlier this year Canonical's Rhys Davies waxed lyrical on building Raspberry Pi clusters using the MicroK8s implementation of Kubernetes — and now Fizzotti is following in his footsteps.
"I decided to build a Raspberry Pi cluster to give me a platform with which I can practice distributed computing technologies without needing to rely on a cloud provider," Fizzotti writes of his project, which combines four Raspberry Pi 4 Model B 4GB single board computers with a cluster-focused Pi Rack case with an Anker PowerPort 5 charger, Netgear N600 gigabit router, and a selection of cables and microSD cards.
Unlike Davies' version, Fizzotti's cluster runs Raspbian Lite rather than Ubuntu Linux as its operating system — but uses many of the same core concepts. "I chose the popular combination of Prometheus for metrics collection and Grafana for dashboard visualization as my monitoring suite," Fizzotti writes. "To provide the Prometheus server with measurements I am using the popular node_exporter package, which makes a multitude of system resources available for metrics collection. Raspberry Pi CPU temperature measurements are supplied by another Prometheus exporter tool aptly named RPi exporter."
Installation and updating tasks are handled across the cluster with Ansible, while Kubernetes itself is provided using the k3s implementation — another shift from MicroK8s used in Canonical's guide. "k3s is a lightweight, certified Kubernetes distribution by Rancher Labs targeting Internet of Things (IoT) and edge computing," Fizzotti explains. "It provides all the core features and functionality that is required by Kubernetes, but has stripped out alpha features and certain storage drivers and swapped out the cluster etcd key-value store for a SQLite database. This results in the entire distribution being available as single 40 MB download (although some container images will be pulled during set-up), requiring just 512 MB of RAM to run."
Finally, Fizzotti adds a 240GB SSD in a USB 3.0 housing for high-speed storage, and then configures MetalLB as a load balancer and installs the target application - a to-do API, written in Go, as an example workload - via package manager Helm. Fizzotti then goes into various ways to "play with Kubernetes," including scaling the ReplicaSet and running the "Ellis-Hanselman Test" — literally pulling the network cable from the node currently being accessed.