Skip to content

Infrastructure

Overview

Gateway

A single host is configured as the gateway to the local network (handles all incoming traffic). It runs the following Docker Compose–managed services:

  • HAProxy — load-balances incoming external HTTP/HTTPS (ports 80 & 443) onto the K3s ingress controller, and the K3s api-server traffic (port 6443) onto the master nodes.
  • PiHole (optional) — network-level DNS sinkhole for ad / tracker filtering.
  • WireGuard (optional) — VPN access to the local network from the internet. Clients are managed via the web UI.
  • CrowdSec (optional) — open-source security engine that analyses logs (HAProxy, sshd, syslog) and blocks malicious IPs via an nftables firewall bouncer. Enrolled in the CrowdSec console for community threat intelligence.

Auto-generated secrets (PiHole password, WireGuard password) are written back as dot-files under inventory/group_vars/ and should be added to vault.yml after the first run.

K3s cluster

The cluster runs k3s (lightweight Kubernetes) with the following roles:

  • 3 master nodes — control plane, fronted by HAProxy on port 6443 for HA.
  • n worker nodes — application workloads. Workers tagged additional_disk: true in inventory/hosts.yml are enrolled into Longhorn for distributed block storage.

The integrated klipper-lb load balancer is used; the bundled Traefik ingress controller is disabled and replaced manually by ingress-nginx (deployed via GitOps).

system-upgrade-controller is deployed cluster-wide to perform automatic K3s upgrades through two plans (one for masters, one for workers).

Longhorn provides distributed block storage on top of the disks of the worker nodes flagged additional_disk: true.

Ansible roles

All Ansible roles live under ansible/roles/ and follow a consistent structure (tasks/, defaults/, meta/, templates/, handlers/).

ScopeRoleDescription
commonhostnameSet hostname and update /etc/hosts.
commonlocalesConfigure system locales.
commonsshHarden SSH via drop-in config, deploy authorized keys.
commonhardeningDisable unnecessary services, kernel sysctl hardening, /etc/hosts.
commondockerInstall Docker CE from the official apt repository.
commonupgradeDist-upgrade all packages, reboot if required.
gatewayhaproxyDeploy HAProxy via Docker Compose.
gatewaypiholeDeploy PiHole via Docker Compose (optional).
gatewaywireguardDeploy WireGuard-Easy via Docker Compose (optional).
gatewaycrowdsecDeploy CrowdSec engine + firewall bouncer (optional).
k3sprereqK3s prerequisites — IP forwarding, cgroups, utility packages.
k3sdownloadDownload the K3s binary matching the target architecture.
k3sstorageInstall iSCSI/NFS packages and mount additional storage disks.
k3sdeploy/mastersDeploy K3s server (master) nodes with HA cluster-init.
k3sdeploy/workersDeploy K3s agent (worker) nodes.
k3sdestroyCleanly destroy a K3s installation and restore system state.
k3sregistryConfigure private container registry (Harbor) on K3s nodes.
k3susersCreate Kubernetes users with x509 certificates and RBAC.