diff --git a/README.md b/README.md index f3ab23e..f234f43 100644 --- a/README.md +++ b/README.md @@ -1,136 +1,140 @@ # HomeK8s -A three-node Kubernetes cluster: two machines on a home network and one cloud -VPS, joined with kubeadm and reconciled from this repository by Flux CD. The -manifests here run the public sites listed below, plus the git server and CI -that build them. +Kubeadm cluster ("Sirius DevOps" homelab), delivered by Flux CD from this repo. +All manifests, components and pod placements below were read from the live cluster +on 2026-10-28 (`kubectl` and `curl`, not from memory). -## Architecture +Deeper write-up: [`docs/cluster-overview.md`](docs/cluster-overview.md) (current-state +snapshot — when it disagrees with `kubectl`, `kubectl` wins). -```mermaid -flowchart LR - net([Internet]) --> cf["Cloudflare TLS"] - cf --> t["cloudflared
rpi, host service"] - t --> gw["Cilium Gateway
gateway-system/public
10.10.0.2:8080"] - gw --> rt["HTTPRoute"] - rt --> svc["Service"] - svc --> pod["Pods
siriussec"] +## Cluster + +| Node | WireGuard IP | Arch | Roles | Notes | +|------|--------------|------|-------|-------| +| `siriussec` | `10.10.0.2` | amd64 | control-plane, gateway, worker | API server (`https://10.10.0.2:6443`). No taints — default scheduling. Labelled `node-role.kubernetes.io/gateway=true`. Every public workload and every `local-path` PVC lives here. | +| `rpi` | `10.10.0.1` | arm64 | traffic, worker | WG hub + cloudflared + dnsmasq. Labelled `dedicated=network`, taint `dedicated=network:PreferNoSchedule`. arm64: amd64 images cannot run here. | +| `linode` | `10.10.0.5` | amd64 | none | Linode VPS, remote WG hub (`10.20.0.1`) reached through the Pi. Same `dedicated=network` label/taint as `rpi`. **Volatile** — retired once, rejoined 2026-10-26; confirm with `kubectl get nodes` before relying on it. | + +Kubernetes `v1.36.4`, containerd. `siriussec` boots `linux-lts` (the Cilium BPF probe +fails on the rolling 7.x kernel). + +## Networking + +- **CNI: Cilium**, native routing over WireGuard — `routing-mode=native`, + `ipv4-native-routing-cidr=10.244.0.0/16`, `auto-direct-node-routes=true`, no VXLAN, + kube-proxy replaced (`kube-proxy-replacement=true`). Pod traffic between nodes is + routed by WireGuard `AllowedIPs`, so a pod CIDR must be in some peer's AllowedIPs. +- **Public ingress** (only path): + `Internet -> CF TLS -> cloudflared on rpi -> http://10.10.0.2:8080 -> Gateway gateway-system/public -> HTTPRoute -> Service`. + The origin is **`http://10.10.0.2:8080`** and nothing else. `127.0.0.1:8080` on the Pi + has no listener; the Pi's own Envoy answers 503 after 5 s. Envoy is a hostNetwork + DaemonSet selecting `node-role.kubernetes.io/gateway=true`, and **`siriussec` is the + only node allowed to carry that label** (two labelled nodes = random 5 s 503s). The + Gateway listener must sit on the node running the backend pods, which is why all + public workloads are pinned to `siriussec`. +- **Internal (WireGuard-only) services**: `Gateway internal/internal` on port 8081 + (Grafana) and `Gateway internal/hubble-ui` on 8084 (Hubble UI). Reached on the bare + IP, no `Host` header, no hosts file: `http://10.10.0.2:8081/` and + `http://10.10.0.2:8084/`. Each bare-IP service needs its own Gateway object + (Cilium merges hostname-less routes per Gateway). Host firewall (`nftables` on + siriussec) is the real boundary, not the Gateway. +- **Internal DNS**: dnsmasq on `rpi`, `10.10.0.1:53` — authoritative for + `lab.internal`; `grafana.lab.internal` and `hubble.lab.internal` both resolve to + `10.10.0.2`. +- **Storage**: `local-path` (default, siriussec `/opt/local-path-provisioner`) plus + `local-static` for hostPath PVs pinned to the Pi (the arm64 runner dind volumes). + +## Services running + +| What | Namespace | Reachable at | Node | +|------|-----------|--------------|------| +| Forgejo (git + registry UI) | `forgejo` | `https://forgejo.siriusdevops.com` | siriussec | +| Forgejo Postgres (CNPG `pg`) | `forgejo` | in-cluster `pg-rw:5432` | siriussec | +| Runner `forgejo-runner-amd64` (dind) | `forgejo` | labels `docker-amd64`, `amd64` | siriussec | +| Runner `forgejo-runner-arm64` (dind) | `forgejo` | labels `docker-arm64`, `arm64`, `docker` | rpi | +| Runner `forgejo-runner-deploy-arm64` (dind) | `forgejo` | label `deploy-arm64` | rpi | +| CronJob `forgejo-runner-prune` | `forgejo` | `17 4 * * *`, prunes every dind | rpi | +| Site + contact API `siriusdevops-*` | `siriusdevops` | `https://siriusdevops.com`, `www.` | siriussec | +| Site + contact API `piedmont-*` | `piedmont` | `https://piedmonthomesvc.com`, `www.` | siriussec | +| Site + contact API + portal `sirius-growth-*` | `sirius-growth` | `https://siriusgrowthsolutions.com`, `www.` (`/api/portal` to the portal) | siriussec | +| Portal Postgres (CNPG `portal`) | `sirius-growth` | in-cluster `portal-rw:5432` | siriussec | +| Prometheus | `monitoring` | in-cluster `kube-prometheus-stack-prometheus:9090` | siriussec | +| Grafana | `monitoring` | WG-only `http://10.10.0.2:8081/` (`grafana.lab.internal`) | siriussec | +| kube-state-metrics, blackbox-exporter, node-exporter (3 nodes) | `monitoring` | in-cluster / scrape targets | mixed | +| Cilium agent + `cilium-envoy` + operator, CoreDNS, Hubble relay/UI | `kube-system` | Hubble UI WG-only `http://10.10.0.2:8084/` | siriussec (+ agents on all) | +| CNPG operator | `cnpg-system` | cluster-internal | siriussec | +| Flux controllers + `etcd-io-guard` (I/O guard DaemonSet) | `flux-system`, `node-io` | cluster-internal | siriussec | +| local-path provisioner | `local-path-storage` | cluster-internal | siriussec | + +Also in the tunnel ingress but **not** backed by a route: `paaas.siriusdevops.com` +returns 404 (a hostname in the tunnel with no HTTPRoute is 404, not a broken tunnel). + +**On the Pi as Docker containers, not in the cluster** (`docker ps` on rpi): + +| Container | Port | +|-----------|------| +| `registry` (`registry:2`) | `10.10.0.1:5000` + `127.0.0.1:5000` — CI image pushes | +| `garage` (`dxflrs/garage`) | S3 API `10.10.0.1:3900` (unsigned GET = 403, i.e. alive) | + +No site/app containers live on the Pi — the sites run in the cluster. The +pre-cluster `handyman-site` (`127.0.0.1:8082`) and `sirius-growth-site` +containers, their `*/2` minute `pull-deploy*.sh` cron redeploys and the compose +service were removed on 2026-10-28 (backups in +`/opt/retired-containers-2026-10-28/` on rpi). Site CI now only pushes the +registry image and rolls the k8s Deployment. + +wgportal is installed on the Pi but **not running**; WG peers are edited in +`/etc/wireguard/*.conf` and `wg set` when it is down. + +## Workload placement rules + +- amd64 images and **every public workload** -> `siriussec` + (`nodeSelector: {kubernetes.io/hostname: siriussec}`). On `rpi` they die with + `exec format error`. +- Traffic / light pods -> `nodeSelector: {dedicated: network}` (rpi or linode, + `PreferNoSchedule` so it is a preference, not a pin). +- Storage: `local-path` only provisions on **siriussec**. A PVC consumed by a pod on + another node must use a static `local-static` PV (see + `apps/base/forgejo/runner-dind-storage.yaml`). +- Cluster DBs: CloudNativePG, 1 instance, `local-path`, `siriussec`. + +## Adding an app + +1. `apps/base//`: namespace, workload, Service, HTTPRoute. +2. HTTPRoute `parentRefs` -> `gateway-system/public`; add a `ReferenceGrant` if the + route lives in another namespace. Add the Deployment/Service in the **same commit** + as the route (a route with no backend returns 503). +3. One line in `apps/home/kustomization.yaml`. +4. Commit, push to `master`, then force Flux to fetch before assuming it applied: + +```bash +kubectl -n flux-system annotate gitrepository flux-system reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite +kubectl -n flux-system annotate kustomization apps reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite ``` -Public requests terminate at Cloudflare and are carried by a cloudflared tunnel -on `rpi` to the Cilium Gateway on `siriussec` at `http://10.10.0.2:8080`, where a -Gateway API HTTPRoute selects the Service. The tunnel is the only public ingress. +A new public hostname also needs one entry in the existing Cloudflare tunnel +(`sirius home`) — do not create a second tunnel. -Nodes and pods reach each other over a WireGuard mesh in `10.10.0.0/24`. Cilium -routes pod traffic natively across that tunnel — `10.244.0.0/16`, no VXLAN -overlay, and kube-proxy is replaced by Cilium's BPF data path. +## Flux layout -## Nodes - -| Node | Roles | WireGuard IP | Architecture | OS, kernel | Runtime | -|------|-------|--------------|--------------|------------|---------| -| `siriussec` | control-plane, gateway, worker | `10.10.0.2` | amd64 | Arch Linux, 6.18.50-2-lts | containerd 2.3.5 | -| `rpi` | traffic, worker | `10.10.0.1` | arm64 | Debian 13, 6.18.39+rpt-rpi-2712 | containerd 2.3.4 | -| `linode` | none | `10.10.0.5` | amd64 | Debian 13, 6.12.113+deb13-amd64 | containerd 2.3.5 | - -`siriussec` is the only node carrying the `gateway` role: Cilium's host-network -Envoy must run on the same node as the backends, so every public workload is -pinned there along with the default `local-path` volume. `rpi` is the WireGuard -hub and runs the cloudflared tunnel host service; it is arm64 and carries -network-adjacent pods, marked with a `dedicated=network:PreferNoSchedule` -preference so the application nodes are used first. - -`linode` is a cloud worker and is the least permanent node of the three — -confirm the current node list with `kubectl get nodes` rather than relying on -this table. - -## Stack - -| Layer | Component | Version | -|-------|-----------|---------| -| Cluster | Kubernetes (kubeadm) | v1.36.4 | -| CNI and data path | Cilium | chart 1.20.1 | -| GitOps | Flux CD | six Kustomizations, watching `master` | -| Ingress | Cloudflare Tunnel into Cilium Gateway API | — | -| Monitoring | kube-prometheus-stack | chart 92.14.0 | -| Databases | CloudNativePG | operator 1.30.0, `postgresql:16` | -| Container runtime | containerd | 2.3.5 (2.3.4 on `rpi`) | - -Storage is the Rancher `local-path` provisioner, the default StorageClass, backed -by `/opt/local-path-provisioner` on `siriussec`. Host-path volumes that must stay -on the Pi use a second, static `local-static` StorageClass with `Retain`. - -## Services - -Public hostnames, all terminating on the Gateway above: - -| Hostname | Route | What it serves | -|----------|-------|----------------| -| `forgejo.siriusdevops.com` | `forgejo/forgejo` | Forgejo git server and container registry | -| `siriusdevops.com`, `www.siriusdevops.com` | `siriusdevops/siriusdevops` | Static site and contact API | -| `siriusgrowthsolutions.com`, `www.siriusgrowthsolutions.com` | `sirius-growth/sirius-growth` | Static site, contact API, client portal | -| `piedmonthomesvc.com`, `www.piedmonthomesvc.com` | `piedmont/piedmont` | Static site and contact API | - -The git server and the client portal each run a single-instance CloudNativePG -cluster (`forgejo/pg`, `sirius-growth/portal`). CI runs on the cluster itself: -three Forgejo Actions runners execute jobs inside their own Docker-in-Docker -sidecars, covering both arm64 and amd64. - -Two services are deliberately not public. They answer on the bare WireGuard -address, with no hostname and no `Host` header, and are reachable only from -inside the tunnel: - -| Service | Route | Address | Response | -|---------|-------|---------|----------| -| Grafana | `monitoring/grafana` → `internal` | `http://10.10.0.2:8081/` | 302 to `/login` | -| Hubble UI | `kube-system/hubble-ui` → `hubble-ui` | `http://10.10.0.2:8084/` | 200 | - -Each needs its own Gateway object: Cilium renders one route table per Gateway, -so two hostname-less routes sharing a Gateway would answer for either backend. -The host firewall, not the Gateway, is the access boundary. - -## Repository layout - -Flux watches `master` and runs six Kustomizations from these paths: - -| Path | Kustomization | Contents | -|------|---------------|----------| -| `clusters/homek8s` | `flux-system` | Bootstrap and the top-level Kustomization list | -| `infrastructure/home` | `infrastructure` | Storage, Cilium, internal gateways, node tuning | -| `infrastructure/networking/gateway-api` | `gateway-api-crds` | Gateway API CRDs | -| `infrastructure/databases/base` | `databases` | CloudNativePG operator, vendored and patched | -| `apps/home` | `apps` | The workloads this cluster runs | -| `monitoring/controllers/home` | `monitoring` | Prometheus, Grafana, dashboards, alert rules | - -A new app is a directory under `apps/base//` holding its namespace, workload, -Service and HTTPRoute, plus one line in `apps/home/kustomization.yaml`. Push to -`master` and Flux applies it. - -## Reference - -[`docs/cluster-overview.md`](docs/cluster-overview.md) is the longer operator -write-up. It is a snapshot and will drift; where it disagrees with `kubectl`, -`kubectl` wins. - -## Audit - -Read live on 2026-10-29 01:21 America/New_York, at commit -`aa0f67fe33394bd565b1f07813ed4355fa926934` on `master`. - -Commands behind the tables above: +Flux watches `master` every 1m and runs six Kustomizations, all `Ready=True`: +`flux-system` (`./clusters/homek8s`), `infrastructure` (`./infrastructure/home`), +`apps` (`./apps/home`), `databases` (`./infrastructure/databases/base`), +`monitoring` (`./monitoring/controllers/home`), `gateway-api-crds` +(`./infrastructure/networking/gateway-api`). ``` -kubectl get nodes -o wide -kubectl version -o json -kubectl -n flux-system get kustomizations -kubectl get hr -A -kubectl get httproute -A -kubectl get cluster -A -kubectl get deploy -A -kubectl get storageclass -curl -H 'Host: ' http://10.10.0.2:8080/ # 200 for all seven -curl http://10.10.0.2:8081/ # 302 → /login -curl http://10.10.0.2:8084/ # 200 +apps/{base,home}/ # workloads + the list of apps this cluster runs +clusters/homek8s/ # THE live Flux tree (kustomizations + gotk-sync) +clusters/home/ # DEAD CODE: not bootstrapped, nothing applies it +infrastructure/{home,networking,storage,controllers,databases,node-io}/ +monitoring/controllers/home/ ``` -If this file disagrees with `kubectl`, `kubectl` wins. +**`clusters/home/` is dead code.** The bootstrapped path is `./clusters/homek8s` +(`clusters/homek8s/flux-system/gotk-sync.yaml`), and `clusters/home` has no +`kustomization.yaml`. A Kustomization declared there never reaches the cluster — put +new Flux Kustomizations under `clusters/homek8s/`. + +Do not `kubectl apply` these paths by hand: Flux owns them. Cilium and +kube-prometheus-stack are HelmReleases, so a manual `helm`/`kubectl apply` is reverted.