Welcome, fellow geek If you're impatient, just start here
Dive into Docker Swarm
The quickest way to get started, and to get your head around the basics.
Kick it with Kubernetes
Been around for a while? Got a high pain threshold? Jump in!
Geek out in Discord
Join the fun, chat with fellow geeks in realtime!
Fast-track with π Premix!
Life's too short? Fast-track your stack with Premix!
The "Geek Cookbook" is a collection of how-to guides for establishing your own container-based awesome selfhosted platform, using either Docker Swarm or Kubernetes.
Running such a platform enables you to run selfhosted services such as the AutoPirate (Radarr, Sonarr, NZBGet and friends) stack, Plex, NextCloud etc, and includes elements such as:
Recent updates and additions are posted on the CHANGELOG, and there's a friendly community of like-minded geeks in the Discord server.
You already have a familiarity with concepts such as virtual machines, Docker containers, LetsEncrypt SSL certificates, databases, and command-line interfaces.
You've probably played with self-hosting some mainstream apps yourself, like Plex, NextCloud, Wordpress or Ghost.
So if you're familiar enough with the concepts above, and you've done self-hosting before, why would you read any further?
...how useful the recipes are for people just getting started with containers...
"One of the surprising realizations from following Funky Penguins cookbooks for so long is how useful the recipes are for people just getting started with containers and how it gives them real, interesting usecases to attach to their learning" - DevOps Daniel (@DanielSHouston)
He unblocked me on all the technical hurdles to launching my SaaS in GKE!
By the time I had enlisted Funky Penguin's help, I'd architected myself into a bit of a nightmare with Kubernetes. I knew what I wanted to achieve, but I'd made a mess of it. Funky Penguin (David) was able to jump right in and offer a vital second-think on everything I'd done, pointing out where things could be simplified and streamlined, and better alternatives.
He unblocked me on all the technical hurdles to launching my SaaS in GKE!
With him delivering the container/Kubernetes architecture and helm CI/CD workflow, I was freed up to focus on coding and design, which fast-tracked me to launching on time. And now I have a simple deployment process that is easy for me to execute and maintain as a solo founder.
I have no hesitation in recommending him for your project, and I'll certainly be calling on him again in the future.
-- John McDowall, Founder, kiso.io
Iβve spent 20+ years working with technology. Iβm a solution architect, with a broad range of experience and skills. I'm a full-time AWS Certified Solution Architect (Professional), a CNCF-Certified Kubernetes Administrator, Application Developer and Security Specialist.
I want your support, either in the financial sense, or as a member of our friendly geek community (or both!)
The best way to support this work is to become a GitHub Sponsor / Patreon patron. You get:
.. and I get some pocket money every month to buy wine, cheese, and cryptocurrency! π· π°
Impulsively click here (NOW quick do it!) to sponsor me via GitHub, or patronize me via Patreon!
Need some Cloud / Microservices / DevOps / Infrastructure design work done? This stuff is my bread and butter!
Get in touch, and let's talk!
A sponsorship is too much commitment, and a book is TL;DR? Hit me up with a one-time caffine shot!
I'm supported and motivated by GitHub Sponsors and Patreon patrons who have generously sponsored me.
I regularly donate to / sponsor the following projects. Join me in supporting these geeks, and encouraging them to continue building the ingredients for your favourite recipes!
| Project | Donate via.. |
|---|---|
| Komga | GitHub Sponsors |
| Material for MKDocs | GitHub Sponsors |
| Calibre | Credit Card / Patreon / LibrePay |
| LinuxServer.io | PayPal |
| WidgetBot's Discord Widget | Patreon |
| Carl-bot | Patreon |
In the design described below, our "private cloud" platform is:
This means that:
Note
An exception to the 3-nodes decision is running a single-node configuration. If you only have one node, then obviously your swarm is only as resilient as that node. It's still a perfectly valid swarm configuration, ideal for starting your self-hosting journey. In fact, under the single-node configuration, you don't need ceph either, and you can simply use the local volume on your host for storage. You'll be able to migrate to ceph/more nodes if/when you expand.
Where multiple solutions to a requirement exist, preference will be given to the most portable solution.
This means that:
Under this design, the only inbound connections we're permitting to our docker swarm in a minimal configuration (you may add custom services later, like UniFi Controller) are:
Assuming a 3-node configuration, under normal circumstances the following is illustrated:

In the case of a failure (or scheduled maintenance) of one of the nodes, the following is illustrated:

When the failed (or upgraded) host is restored to service, the following is illustrated:

A day after writing this, my environment suffered a fault whereby all 3 VMs were unexpectedly and simultaneously powered off.
Upon restore, docker failed to start on one of the VMs due to local disk space issue1. However, the other two VMs started, established the swarm, mounted their shared storage, and started up all the containers (services) which were managed by the swarm.
In summary, although I suffered an unplanned power outage to all of my infrastructure, followed by a failure of a third of my hosts... all my platforms are 100% available1 with absolutely no manual intervention.
In the design described below, our "private cloud" platform is:
This means that:
Note
An exception to the 3-nodes decision is running a single-node configuration. If you only have one node, then obviously your swarm is only as resilient as that node. It's still a perfectly valid swarm configuration, ideal for starting your self-hosting journey. In fact, under the single-node configuration, you don't need ceph either, and you can simply use the local volume on your host for storage. You'll be able to migrate to ceph/more nodes if/when you expand.
Where multiple solutions to a requirement exist, preference will be given to the most portable solution.
This means that:
Under this design, the only inbound connections we're permitting to our docker swarm in a minimal configuration (you may add custom services later, like UniFi Controller) are:
Assuming a 3-node configuration, under normal circumstances the following is illustrated:

In the case of a failure (or scheduled maintenance) of one of the nodes, the following is illustrated:

When the failed (or upgraded) host is restored to service, the following is illustrated:

A day after writing this, my environment suffered a fault whereby all 3 VMs were unexpectedly and simultaneously powered off.
Upon restore, docker failed to start on one of the VMs due to local disk space issue1. However, the other two VMs started, established the swarm, mounted their shared storage, and started up all the containers (services) which were managed by the swarm.
In summary, although I suffered an unplanned power outage to all of my infrastructure, followed by a failure of a third of my hosts... all my platforms are 100% available1 with absolutely no manual intervention.
Let's start building our cluster. You can use either bare-metal machines or virtual machines - the configuration would be the same. To avoid confusion, I'll be referring to these as "nodes" from now on.
Note
In 2017, I initially chose the "Atomic" CentOS/Fedora image for the swarm hosts, but later found its outdated version of Docker to be problematic with advanced features like GPU transcoding (in Plex), Swarmprom, etc. In the end, I went mainstream and simply preferred a modern Ubuntu installation.
Ingredients
New in this recipe:
Most modern Linux distributions include firewall rules which only only permit minimal required incoming connections (like SSH). We'll want to allow all traffic between our nodes. The steps to achieve this in CentOS/Ubuntu are a little different...
Add something like this to /etc/sysconfig/iptables:
# Allow all inter-node communication
-A INPUT -s 192.168.31.0/24 -j ACCEPT
And restart iptables with systemctl restart iptables
Install the (non-default) persistent iptables tools, by running apt-get install iptables-persistent, establishing some default rules (dkpg will prompt you to save current ruleset), and then add something like this to /etc/iptables/rules.v4:
# Allow all inter-node communication
-A INPUT -s 192.168.31.0/24 -j ACCEPT
And refresh your running iptables rules with iptables-restore < /etc/iptables/rules.v4
Depending on your hosting environment, you may have DNS automatically setup for your VMs. If not, it's useful to set up static entries in /etc/hosts for the nodes. For example, I setup the following:
Set your local timezone, by running:
ln -sf /usr/share/zoneinfo/<your timezone> /etc/localtime
After completing the above, you should have:
Summary
Deployed in this recipe:
My first introduction to Kubernetes was a children's story:
Why would you want to Kubernetes for your self-hosted recipes, over simple Docker Swarm? Here's my personal take..
Sorry to say, but from where I sit, there's no innovation or development happening in docker swarm.
Yes, I know, after Docker Inc sold its platform business to Mirantis in Nov 2019, in Feb 2020 Mirantis back-tracked on their original plan to sunset swarm after 2 years, and stated that they'd continue to invest in swarm. But seriously, look around. Nobody is interested in swarm right now...
... Not even Mirantis! As of Nov 2021, the Mirantis blog tag "kubernetes" had 8 posts within the past month. The tag "docker" has 8 posts in the past 2 years, the 8th being the original announcement of the Docker aquisition. The tag "docker swarm" has only 2 posts, ever.
Dead. Extinct. Like the doodoo.
For years now, I've provided Kubernetes design consulting to small clients and large enterprises. The implementation details in each case vary widely, but there are some primitives which I've come to take for granted, and I wouldn't easily do without. A few examples:
Yes, it's more complex than Docker Swarm. And that complexity can definately be a barrier, although with improved tooling, it's continually becoming less-so. However, you don't need to be a mechanic to drive a car or to use a chainsaw. You just need a basic understanding of some core primitives, and then you get on with using the tool to achieve your goals, without needing to know every detail about how it works!
Your end-goal is probably "I want to reliably self-host services I care about", and not "I want to fully understand a complex, scalable, and highly sophisticated container orchestrator". 1
So let's get on with learning how to use the tool...
Primarily you need 2 things:
Practically, you need some extras too, but you can mix-and-match these.
Of course, if you do enjoy understanding the intricacies of how your tools work, you're in good company!Β β©