๐ Overview
This is a mono repository for my home infrastructure and Kubernetes cluster. I try to adhere to Infrastructure as Code (IaC) and GitOps practices using the tools like Ansible, Kubernetes, Flux, Renovate and GitHub Actions.
โต Kubernetes
There is a template over at onedr0p/flux-cluster-template if you wanted to try and follow along with some of the practices I use here.
Installation
My cluster is k3s provisioned overtop bare-metal Debian Servers using the Ansible galaxy role ansible-role-k3s. This is a semi hyper-converged cluster, workloads and block storage are sharing the same available resources on my nodes while I have a separate server for (NFS) file storage.
๐ธ Click here to see my Ansible playbooks and roles.
Core Components
- cilium: Internal Kubernetes networking plugin.
- cloudflared: Tunneling daemon that proxies traffic from the Cloudflare network to my cluster
- cert-manager: Creates SSL certificates for services in my Kubernetes cluster.
- external-dns: Automatically manages DNS records from my cluster in a cloud DNS provider.
- ingress-nginx: Ingress controller to expose HTTP traffic to pods over DNS.
- rook: Distributed block storage for peristent storage.
- sops: Managed secrets for Kubernetes, Ansible and Terraform which are commited to Git.
- teleport: Manage some network resources remotely
- tf-controller: Additional Flux component used to run Terraform from within a Kubernetes cluster.
- volsync and snapscheduler: Backup and recovery of persistent volume claims.
GitOps
Flux watches my kubernetes folder (see Directories below) and makes the changes to my cluster based on the YAML manifests.
The way Flux works for me here is it will recursively search the kubernetes/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.
Directories
This Git repository contains the following directories under kubernetes.
๐ kubernetes # Kubernetes cluster defined as code
โโ๐ apps # Apps deployed into my cluster grouped by namespace (see below)
โโ๐ bootstrap # Flux installation
โโ๐ flux # Main Flux configuration of repository
๐ก Networking
Name | CIDR |
---|---|
Server VLAN | 10.0.30.0/24 |
Kubernetes pods | 10.42.0.0/16 |
Kubernetes services | 10.43.0.0/16 |
โ๏ธ Cloud Dependencies
While most of my infrastructure and workloads are selfhosted 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.
Service | Use | Cost |
---|---|---|
GitHub | Hosting this repository and continuous integration/deployments | Free |
Cloudflare | Domain, DNS and proxy management | Free |
UptimeRobot | Monitoring internet connectivity and external facing applications | Free |
NextDNS Pro | DNS with some ad-blocking and other features | ~$1.65.mo |
Azure Key Vault | Secrets with External Secrets | ~$0.10/mo |
Total: ~$1.75/mo |
๐ DNS
Home DNS
On my Vyos router I have CoreDNS deployed as a container. I have a split-dns setup so I can access certain pods on my network but not expose them to the public internet.
You can see more about this setup in my VyOS repo: VyosConfig
Public DNS
Outside the external-dns
instance mentioned above another instance is deployed in my cluster and configure to sync DNS records to Cloudflare. The only ingresses 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 an ingress annotation of external-dns.alpha.kubernetes.io/target
.
๐ง Hardware
Model | RAM | OS Disk Size | Data Disk Size | Operating System | Purpose | Rack Location |
---|---|---|---|---|---|---|
HUNSN Micro Firewall Appliance | 8 GB | 64GB (SSD) | VyOS | Router | 18U (Right) | |
Dell Optiplex 7050 Micro | 16 GB | 500GB (SSD) | 1TB (NVMe) | Debian | Node 1 (K8s Control Plane) | 15U (Left) |
Dell Optiplex 7050 Micro | 16 GB | 500GB (SSD) | 1TB (NVMe) | Debian | Node 2 (K8s Control Plane) | 15U (Right) |
Dell Optiplex 7050 Micro | 16 GB | 500GB (NVMe) | 1TB (SSD) | Debian | Node 3 (K8s Worker) | 16U (Left) |
HP ProDesk 600 G3 Mini | 16 GB | 500GB (SSD) | 1TB (NVMe) | Debian | Node 4 (K8s Worker) | 17U (Right) |
HP ProDesk 600 G3 Mini | 16 GB | 500GB (SSD) | 1TB (NVMe) | Debian | Node 5 (K8s Control Plane) | 17U (Left) |
Dell Optiplex 3060 Micro | 16 GB | 500GB (SSD) | 1TB (NVMe) | Debian | Node 6 (K8s Worker) | 16U (Right) |
Click to see the Full Home Ops Rack!
Rack U | Hardware | Power Rail |
---|---|---|
22 | 16 Port KVM Switch | Pending Assignment |
21 | CAT6 Patch Panel | Pending Assignment |
20 | 24 Port Unifi Network Switch | Pending Assignment |
19 | Unifi CloudKey Gen 2 | Pending Assignment |
18 |
Linux Desktop - Intel Skull Canyon NUC
VyOS Router - HUNSN Micro Firewall Appliance |
Pending Assignment |
17 |
Node 4 - HP ProDesk 600 G3 Mini
Node 5 - HP ProDesk 600 G3 Mini |
Pending Assignment |
16 |
Node 3 - Dell Optiplex 7050 Micro
Node 6 - Dell Optiplex 3060 Micro |
Pending Assignment |
15 |
Node 1 - Dell Optiplex 7050 Micro
Node 2 - Dell Optiplex 7050 Micro |
Pending Assignment |
14 | Custom Build Server | Pending Assignment |
13 | ||
12 | ||
11 | ||
10 | BLANK | Pending Assignment |
9 | Raspberry Pi Mount | Pending Assignment |
8 | Synology DS1819+ | Pending Assignment |
7 | ||
6 | ||
5 | ||
4 | Dell PowerEdge 2950 | Pending Assignment |
3 | ||
2 | APC Battery Backup | Pending Assignment |
1 |
๐ค Gratitude and Thanks
Big shout out to all the authors and contributors to the flux-cluster-template projects that we are using in this repository.
Community member onedr0p for initially creating this amazing template and providing me with additional help.
๐ Changelog
See awful commit history
๐ License
See LICENSE