InfrastructureCompleted2024

Homelab Kubernetes Cluster

4-node k3s cluster on Raspberry Pi, driven by OpenTofu, with observability (VictoriaMetrics, Loki, OpenTelemetry, Grafana), Let's Encrypt and self-hosted services.

Homelab Kubernetes Cluster
Kubernetesk3sOpenTofuVictoriaMetricsLokiOpenTelemetryRaspberry Pi
Source code ↗

Context

I wanted to push my homelab beyond a simple NAS or single server. The goal: a resilient, reproducible infrastructure close to a real production environment, but on low-power ARM hardware.

Architecture

The cluster runs on 4 Raspberry Pi 4 (8 GB RAM each) connected over Gigabit Ethernet:

  • 1 dedicated control plane
  • 3 worker nodes with Longhorn distributed storage
  • Pi-hole for DNS/DHCP and network filtering
  • Traefik as ingress controller with automatic TLS certificates

Self-Hosted Services

  • Immich: photo management, Google Photos style
  • Gitea: private Git repository
  • Docker Registry: private image registry
  • Joplin: note synchronization
  • Radicale: CalDAV/CardDAV

Infrastructure as Code and observability

In 2026 the cluster moved under OpenTofu: existing resources were imported without redeployment, and every new layer is enabled by a flag with a known RAM budget. An observability stack sized for Raspberry Pi (VictoriaMetrics, Loki, OpenTelemetry Collector, Grafana) finally gives a view of what is running, and cert-manager provides Let’s Encrypt certificates. Details, pitfalls and choices in the dedicated chapter.

Challenges

Longhorn recovery after reinstallation was the most complex challenge: I had to manually recreate volume mappings to preserve existing data without proprietary formats.

What I Learned

  • Fine-grained resource management on constrained ARM nodes
  • Deep network debugging (CNI, kube-proxy, CoreDNS)
  • Backup strategies without vendor lock-in
  • Bringing an existing cluster under infrastructure as code with no service interruption