diff --git a/README.md b/README.md index 999dac5..86b0e9b 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,133 @@ # HomeK8s -Home Kubernetes cluster (kubeadm), same GitOps layout as `lab/`. +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). -Flux CD will take over once Forgejo is back. Until then apply with kustomize: - -```bash -kubectl apply -k infrastructure/home -``` +Deeper write-up: [`docs/cluster-overview.md`](docs/cluster-overview.md) (current-state +snapshot — when it disagrees with `kubectl`, `kubectl` wins). ## Cluster -| Node | WG IP | Roles | Notes | -|-------------|------------|--------------------------|--------------------------------------------| -| siriussec | 10.10.0.2 | control-plane, worker | default scheduling | -| rpi | 10.10.0.1 | traffic, worker | `dedicated=network:PreferNoSchedule` | +| 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. | -- CNI: Cilium 1.18.13, kube-proxy replacement, Gateway API hostNetwork on `dedicated=network` -- Overlay: WireGuard `10.10.0.0/24` (API only on WG) -- Ingress: Cloudflare tunnel → `127.0.0.1:8080` on rpi → Gateway `gateway-system/public` -- Storage: local-path on siriussec (`/opt/local-path-provisioner`) +Kubernetes `v1.36.4`, containerd. `siriussec` boots `linux-lts` (the Cilium BPF probe +fails on the rolling 7.x kernel). -Pin traffic / light workloads to the Pi: +## Networking -```yaml -nodeSelector: - dedicated: network -``` +- **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). -## Layout +## Services running -``` -homek8s/ -├── apps/ -│ ├── base/ # app definitions -│ └── home/ # overlay applied to this cluster -├── clusters/ -│ └── home/ # Flux Kustomizations (bootstrap later) -│ ├── flux-system/ # flux bootstrap (after Forgejo) -│ ├── apps.yaml -│ ├── infrastructure.yaml -│ └── monitoring.yaml -├── infrastructure/ -│ ├── home/ # kubectl apply -k target (no HelmRelease) -│ ├── networking/ -│ │ ├── cilium/ # HelmRelease for Flux -│ │ └── gateway/ # Cilium Gateway API -│ ├── storage/ # local-path provisioner -│ ├── controllers/ -│ └── databases/ -└── monitoring/ -``` +| 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 | -## Apply (now) +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) | + +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 apply -k infrastructure/home +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 ``` -That installs storage + the public Gateway. Cilium is already running; its HelmRelease is only for Flux. +A new public hostname also needs one entry in the existing Cloudflare tunnel +(`sirius home`) — do not create a second tunnel. -## Flux (later) +## Flux layout -When Forgejo is up: +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`). -```bash -flux bootstrap git \ - --url=ssh://git@forgejo.siriusdevops.com:222/sirius/homek8s.git \ - --branch=master \ - --path=clusters/home +``` +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/ ``` -`clusters/home/*.yaml` already point at `./apps/home`, `./infrastructure/home`, and `./monitoring/controllers/home`. +**`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.