Skip to content
nerdily edited this page May 24, 2021 · 15 revisions

Intro

I wanted to set up a Docker Swarm to containerize the services I currently run on a single Raspberry Pi 3B+. The single Pi is a point of failure and I wanted some redundancy, particularly for my network controller.

Services to implement

  • Docker Swarm - For container orchestration I looked at Kubernetes but it is considerable overkill for my needs. The learning curve is also basically vertical, particularly around the networking piece. My head exploded on more than one occasion. Docker Swarm is a bit more "pro-sumer" level and fits my needs exactly. The networking piece is considerably more simple and easier to handle on Swarm - both a pro and con, but a pro for me. Docker's documentation is also incredibly good.
  • Portainer - Frontend UI for managing the Docker Swarm. I would encourage anyone setting out on containers to first work on the command line so that you understand the fundamentals of what the UI would be doing. There are also benefits of the UI such as a complete overview of the Swarm that some of the commands do not give. (Example: The docker volume command only sees volumes on the current node you are logged into, not across the swarm. Portainer congregates all volumes across the Swarm.) Portainer will replace Webmin which I used on the standalone Raspberry Pi, though in all honesty I rarely used it.
  • Pihole - Network-wide ad blocking. Highly effective and basically an essential with the crap-laden web these days.
  • Deluge - A way to gather things that fall off the back of internet-based trucks.
  • Samba - Tried and true file sharing. I have the VLC app on my AppleTV and use it to watch media from the server. Or, same app on the iPad. Works quite well when I'm away from home and I VPN into the network on the iPad.
  • Ubiquiti UniFi Network Controller - This was the main driver for containerizing my services. Ubiquiti sells a standalone "Cloud Key" network controller, but they also release the controller software for Windows, Mac, and Linux. It is very common to run the controller on a Raspberry Pi, as is running it in a container.

Storage

Underneath the Docker layer and all of the containers, I have storage. A big consideration is that if a running container fails for whatever reason, its replacement container may come up on a different node. How would it have access to the bits of persistent storage that it needs? Things like configuration files for the services, media being served up, etc. I'm using Gluster for that. Think RAID but instead of across disks in a single system, it's across disks in a cluster of systems. I am using two 4TB USB disks, one connected to each node and replicating each other bi-directionally. As I add nodes, I can simply point them at the Gluster storage pool. Adding more storage or replacing disks that fail is trivial.

Hardware

I have 2 Raspberry Pi 4 (4GB) models configured in a physical stack. I would not recommend a Raspberry Pi with less than 4GB of RAM. This gives you plenty of head space for adding containers. I don't think I'll need anything more than my 2 nodes given that I was previously running everything on a single 3B+, but who knows. Adding new Docker Swarm nodes is as trivial as adding more Gluster storage.

Network

I have hung a small switch off of my main switch that the Raspberry Pis connect to via Gigabit ethernet.

References

When making yaml files for docker stack this is a critical reference.

Clone this wiki locally