Part 1: K3s, ZeroTier, DigitalOcean, and more...Oh my!
For a while, I’ve wanted to figure out some ways to bridge the gap with homelabbing and professional cloud environments. Generally it’s expensive, complicated, or both to get it all working. What I’m hoping to help folks understand is that you can do it well, cheap, and keep it all maintained and up to date with modern practices like GitOps.
I am hopeful that I can build this as a living document, with more updates and content to be added as time progresses.
There’s so much to cover here, so let’s start with a brief overview of ALL of the different components in play here:
Software
- K3s - Lightweight Kubernetes, by Rancher
- Lens - The Kubernetes IDE for DevOps
- Traefik - Cloud-Native Networking Stack
- FluxCD - The GitOps operator for Kubernetes
- GitHub (specifically GitHub Actions)
- Docker BuildX - Docker CLI plugin for extended build capabilities with BuildKit
- Docker Hub - Docker’s Container Repository
- HypriotOS - container OS that takes you from Zero to Docker within 5 Minutes
- ZeroTier - Virtual Ethernet switch for planet Earth
- Ansible - Agentless IT Automation
- A domain name you own and can host with DigitalOcean
Hardware (Physical & Virtual)
- Turing Pi - Raspberry Pi Compute Cluster Board
- Raspberry Pi Compute Module 3+
- DigitalOcean - IMO, the homelab-friendly Cloud Provider
What’s the end goal here and why would I even do this?
TL;DR - We’ll have a combined architecture cluster (arm/linux/7
and amd64
) of k3s nodes that will host a website and will update itself according to the repos for your website and infrastructure.
We’re going to be spinning up a cluster of Raspberry Pi’s (arm/linux/7
architecture), a single $5 Ubuntu VM (amd64
architecture) in Digital Ocean, and a $10 Load Balancer1. The remote host in DO will dial home with ZeroTier, and we’ll get a pipeline functional where your Kubernetes Manifests will be automatically applied to the cluster using (primarily) FluxCD.
Assumptions
This entire document is assuming that you are already familiar with the following things:
- DigitalOcean’s Web Management UI
- Linux BASH/ZSH shell (Debian/Raspbian based distros preferred)
- Basic networking
- Physical and Virtual Ethernet Interfaces
- IP Addressing
- Subnetting
- An existing system to flash your Raspberry Pi Compute Nodes
- BalenaEtcher is the absolute correct tool to use for flashing your Pi nodes with the OS of your choosing.
- How to purchase a domain name and migrate it to DigitalOcean, or follow this guide on how to do so.
- Basic knowledge of setting up a Github Account and creating repositories
Requirements
Homelab
For hardware in my homelab, here’s what I would recommend for Hardware and Networking:
- One Turing Pi
- Four (or more) CM3+/8GB units;
- My storage needs are limited, so the 8GB units are fine for me. Jeff Gerrling did a fantastic YouTube video on how much faster eMMC storage is over MicroSD storage. I’d recommend going the eMMC route.
- ZeroTier Router VM (or an additional Pi that will not be on your K8s Cluster)
- 2 vCPU
- 4 GB Memory
- 10GB Disk
- Static Route on primary home/homelab router
- Gateway should be set to
eth0
IP address on ZeroTier Router VM - Destination Address should match the subnet of the configured ZeroTier network
- Gateway should be set to
DigitalOcean
For objects in DigitalOcean, I recommend creating the following:
- One Basic $5/mo Droplet. This should be more than enough compute for what we’re doing.
- One Load Balancer
- Ensure this is created in the same datacenter region, otherwise you will not be able to reference your Droplet.
What’s coming up
In part 2, I’ll be covering:
- Building the Pi Cluster
- Prepping the Pi’s with HypriotOS
- Spinning up the Digital Ocean Droplet
- ZeroTier
- Creating the ZeroTier Network
- Associating the DO Node
- Creating a ZeroTier ‘Router’ in the Homelab
- Validating Network Connectivity between local Pi’s and the DO Node
References
1 You don’t need the Load Balancer, but it’ll ensure that if you want to add additional nodes in the cloud you can add them significantly more seamlessly.
Helpful Links
- K3s Homelab Repo for Flux
- Personal Website Repo (with GitHub Actions)
- Docker Hub Account hosting container image
Questions? Thoughts?
Feel free to ping me at daniel.a.manners@gmail.com. If something I wrote isn’t clear, feel free to ask me a question or tell me to update it!