Raspberry Pi Docker: Open-Source Management/Config Tool

Raspberry Pi Docker: Open-Source Management/Config Tool

Tiny Cluster Raspberry Pi Config Management with Kubernetes and Docker

Anybody who’s set up more than a single Raspberry Pi knows how frustrating it can be to keep them all up-to-date and working correctly. The slightest configuration change can require copying files and/or repeating steps between devices.

When I first built my Magic Spellbooks for home automation, I quickly ran in to the Raspberry Pi config management problem. Each “spellbook” acts as a kiosk, connecting to my Home Assistant server, while also running a number of other background tasks. For example, they all act as beacons, determining which room of the house I am in by detecting my phone.

To keep all the spellbooks working together properly, I built a Raspberry Pi config management tool, which I call Tiny Cluster.

Check out Tiny Cluster on Github, which includes setup and quick start instructions.

Why Another Raspberry Pi Config Tool?

There are a number of tools available for Raspberry Pi configuration management. Puppet, in particular, is a popular way to keep multiple devices all working as-expected. Although they are excellent and I would highly recommend them, there are good reasons to take a different approach.

Kubernetes (and Docker) are industry-standard tools that solve much the same problem, except with the following advantages:

  1. The community of developers using Docker and Kubernetes gives you access to a wide variety of features and support. You can deploy anything: PiHole, Home-Assistant, WordPress, or even sophisticated cluster monitoring like Prometheus and Grafana (see the end of this post for screenshots).
  2. They are familiar to any modern system administrator. For the hobbyist, using these tools for configuration management means learning valuable skills applicable to jobs at large technology companies.
  3. Docker images deployed via Kubernetes are “hermetically sealed.” Instead of attempting to coordinate and sync many different files, each “feature” (like the “beacon” ability I mentioned above) can be encapsulated into a single Docker container. Kubernetes can then schedule the features on the desired devices, without risk of conflict. In a word, container deployment is idempotent.

These days, it’s pretty easy to install Kubernetes with tools like kubeadm. Still, there are a lot of steps which I found repetitive and annoying.

Config Management as Code

At first, it seemed enough to simply install kubeadm on each of my Raspberry Pis and call it a day. This quickly became untenable, as not everything can be entirely encapsulated by Kubernetes. Boot configurations, for example, must necessarily live on the host machine (and not in a Raspberry Pi Docker container).

Enter Tiny Cluster, my open-source solution to managing a Kubernetes fleet of Raspberry Pis. It takes a simple configuration file and provides a variety of management commands. It allows you to set up a new Raspberry Pi, or deploy updates to a RPi with minimal effort.

YAML has been called the “world’s most popular” programming language. Hairsplitting about what constitutes a programming language, and the many faults of YAML aside… it has indisputably become the de-facto tool of system administrators. This is in no small part due that Kubernetes itself uses to define resources.

A simple tiny cluster configuration file is as follows:

kubernetes:
  master:
    address: 192.168.0.1
    connect: ssh
    username: pi

nodes:
  192.168.0.1:
    name: main

  192.168.0.2:
    name: spellbook

Raspberry Pi + Kubernetes = Tiny Cluster

Some of the other key features are as follows:

  • Set up a brand new Raspberry Pi + docker with a single command.
  • Provide “Kiosk Mode” (turn a Raspberry Pi into a dedicated web browser).
  • Avoid of one-off scripts and backups.
  • Easy to integrate with Home Assistant
  • Easy to deploy any Docker image

As I said in the introduction, I use this tool to manage my Magic Spellbooks. I have two different clusters: one at home, and one in my vanlife van.

magic spellbook home automation (interior)
Each Spellbook acts as a kiosk for Home Assistant

In the background, each Spellbook is also running a number of Docker containers. At home, node-pi-beacon uses BTLE to detect which room I am in based upon the proximity of my phone to one of the Spellbooks.

ha internet
In the van, Node Red pipes internet connectivity statistics to Home Assistant.

Both clusters can also be easily monitored with Grafana:

Monitoring Tiny Cluster Kubernetes Raspberry Pi with Grafana
Prometheus and Grafana are deployed to the cluster with a Kubernetes dashboard. In the dropdown on the top left, I am able to select from the different nodes in the Tiny Cluster.

The possibilities are pretty much endless. I’ve provided a detailed setup guide in the README for Tiny Cluster, as well as examples for deploying a number of different containers like you see above. If you happen to try it out, I’d love to hear how it goes! Drop me a line in the comments below or on Github.

Build Guides

Looking for even more detail?

Drop your email in the form below and you'll receive links to the individual build-guides and projects on this site, as well as updates with the newest projects.

... but this site has no paywalls. If you do choose to sign up for this mailing list I promise I'll keep the content worth your time.

Written by
(zane) / Technically Wizardry
Join the discussion

Menu