This is a monorepository for my home Kubernetes clusters. I try to adhere to Infrastructure as Code (IaC) and GitOps practices using tools like Ansible, Terraform, Kubernetes, Flux, Renovate, and GitHub Actions.
The purpose here is to learn Kubernetes, while practicing GitOps. I have two longer-term goals:
- migrate many of the services that I currently run on Linode to my HomeLab.
- Build a small Raspberry Pi cluster at home to run a infrastructure, with the intent of being able to run critical components from a UPS during power outages.
There is a template over at onedr0p/flux-cluster-template if you want to try and follow along with some of the practices I use here.
My cluster is built using k3s, provisioned on bare-metal Arch Linux using the Ansible galaxy role ansible-role-k3s. This is a hyper-converged cluster, workloads and block storage are sharing the same available resources on my nodes. I also have a separate NAS server with ZFS for NFS/SMB shares, bulk file storage and backups.
- actions-runner-controller: self-hosted Github runners
- calico: container networking with IPv6 support and policy enforcement.
- cert-manager: Configured to create TLS certs for all ingress services automatically using LetsEncrypt.
- external-dns: monitors service and ingress resources, and automatically generates DNS updates for them. This lets me maintain DNS mappings and LetsEncrypt certificates without a cloudflare account or domain.
- external-secrets: managed Kubernetes secrets using 1Password.
- ingress-nginx: ingress controller for Kubernetes using NGINX as a reverse proxy and load balancer
- rook-ceph: Cloud native distributed block storage for Kubernetes
- sops: managed secrets for Kubernetes, Ansible, and Terraform which are committed to Git
- volsync: backup and recovery of persistent volume claims
Flux watches the clusters in my kubernetes folder (see Directories below) and makes the changes to my clusters based on the state of my Git repository.
The way Flux works for me here is it will recursively search the kubernetes/${cluster}/apps
folder until it finds the most top level kustomization.yaml
per directory and then apply all the resources listed in it. That aforementioned kustomization.yaml
will generally only have a namespace resource and one or many Flux kustomizations. Those Flux kustomizations will generally have a HelmRelease
or other resources related to the application underneath it which will be applied.
Renovate watches my entire repository looking for dependency updates, when they are found a PR is automatically created. When some PRs are merged Flux applies the changes to my cluster.
Yes, this is a lot of infrastructure and heavy lifting - the point is to experiment with Kubernetes and GitOps in a safe space.
This Git repository contains the following directories under Kubernetes.
π kubernetes
βββ π main # main cluster
β βββ π apps # applications
β βββ π bootstrap # bootstrap procedures
β βββ π flux # core flux configuration
β βββ π templates # re-useable components
βββ π registry # registry cluster (running harbor)
βββ π apps # applications
βββ π bootstrap # bootstrap procedures
βββ π flux # core flux configuration
While most of my infrastructure and workloads are self-hosted I do rely upon the cloud for certain key parts of my setup. This saves me from having to worry about two things. (1) Dealing with chicken/egg scenarios and (2) services I critically need whether my cluster is online or not.
The alternative solution to these two problems would be to host a Kubernetes cluster in the cloud and deploy applications like HCVault, Vaultwarden, ntfy, and Gatus. However, maintaining another cluster and monitoring another group of workloads is a lot more time and effort than I am willing to put in.
Service | Use | Cost |
---|---|---|
1Password | Secrets with External Secrets | ~$60/yr |
Cloudflare | Domain and S3 | Free |
GitHub | Hosting this repository and continuous integration/deployments | Free |
Linode | servers hosting my email and public web | Free |
Pushover | Kubernetes Alerts and application notifications | $5 OTP |
healthchecks.io | Monitoring internet connectivity and Prometheus status | Free |
Total: ~$5/mo |
On a pair of Raspberry Pi 3s, I have Bind9 and blocky deployed. In my cluster external-dns
is deployed with the RFC2136
provider which syncs DNS records to bind9
. blocky
is used by non-servers as ad-blocking and caching proxy, using bind9
for local lookups.
Outside the external-dns
instance mentioned above another instance is deployed in my cluster and configured to sync DNS records to Cloudflare. The only ingress this external-dns
instance looks at to gather DNS records to put in Cloudflare
are ones that have an ingress class name of external
and contain an ingress annotation external-dns.alpha.kubernetes.io/target
.
Node | CPU | RAM | Storage | Function | OS |
---|---|---|---|---|---|
HP EliteDesk 800 G2 | Intel i5-6500T | 16GB | 240GB SSD | control-plane | Arch Linux |
HP EliteDesk 800 G2 | Intel i5-6500T | 16GB | 240GB SSD | control-plane | Arch Linux |
HP EliteDesk 800 G2 | Intel i5-6500T | 16GB | 240GB SSD | control-plane | Arch Linux |
Lenovo M910q tiny | Intel i5-6500T | 16GB | 512GB NVMe | worker, ceph storage | Arch Linux |
Lenovo M900q tiny | Intel i5-6500T | 16GB | 512GB SSD | worker, ceph storage | Arch Linux |
Lenovo M910q tiny | Intel i5-6500T | 16GB | 512GB NVMe | worker, ceph storage | Arch Linux |
Node | CPU | RAM | Storage | Function | OS |
---|---|---|---|---|---|
libvirtd VM | AMD Ryzen 5 1600T | 8GB | 128GB HDD | single-node cluster | Arch Linux |
Node | CPU | RAM | Storage | Function | OS |
---|---|---|---|---|---|
Turing RK1 | Cortex A76/A55 | 16GB | 1TB NVMe | control-plane | Debian |
Turing RK1 | Cortex A76/A55 | 16GB | 1TB NVMe | control-plane | Debian |
Turing RK1 | Cortex A76/A55 | 16GB | 1TB NVMe | control-plane | Debian |
Big shout out to original flux-cluster-template, and the Home Operations Discord community.
Be sure to check out kubesearch.dev for ideas on how to deploy applications or get ideas on what you may deploy.