Skip to content

haraldkoch/kochhaus-home

Repository files navigation

kochhaus-home - a mono-repo for my homelab

... automated via Flux, Renovate and GitHub Actions 🐟

DiscordΒ Β  KubernetesΒ Β  Renovate

Age-DaysΒ Β  Uptime-DaysΒ Β  Node-CountΒ Β  Pod-CountΒ Β  CPU-UsageΒ Β  Memory-UsageΒ Β  Power-UsageΒ Β  Alerts

volkswagen status


Overview

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:

  1. migrate many of the services that I currently run on Linode to my HomeLab.
  2. 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.

β›΅ Kubernetes

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.

Installation

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.

Core Components

  • 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

GitOps

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.

Wow

Yes, this is a lot of infrastructure and heavy lifting - the point is to experiment with Kubernetes and GitOps in a safe space.

dexhorthy

Directories

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

☁️ Cloud Dependencies

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

🌐 DNS

Home DNS

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.

Public DNS

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.


πŸ”§ Hardware

Main Kubernetes Cluster

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
libvirtd VM AMD Ryzen 5 1600T 16GB 256GB HDD 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

Registry Kubernetes Cluster

Node CPU RAM Storage Function OS
libvirtd VM AMD Ryzen 5 1600T 8GB 128GB HDD single-node cluster Arch Linux

Infrastructure Kubernetes Cluster (coming soon)

Node CPU RAM Storage Function OS
Raspberry Pi 4 Cortex A72 4GB 240GB SSD control-plane Debian
Raspberry Pi 4 Cortex A72 8GB 240GB SSD control-plane Debian
Raspberry Pi 4 Cortex A72 8GB 240GB SSD control-plane Debian

⭐ Stargazers

Star History Chart


🀝 Thanks

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.

About

Experimental homelab configuration for running things on kubernetes

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •