docs: Add cluster inventory and simplification plan.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Change-Id: Ie679b818ac69d23d48eed6259f9d01537c0eece7
diff --git a/docs/simplification-plan.md b/docs/simplification-plan.md
new file mode 100644
index 0000000..3c5e20c
--- /dev/null
+++ b/docs/simplification-plan.md
@@ -0,0 +1,434 @@
+# ifirn: state of the cluster and simplification plan
+
+Status: **plan only, nothing has been migrated.** Inventory taken from the live cluster and host on 2026-11-16 (not from this repository, which is partly stale).
+
+Contents:
+
+1. [Summary](#1-summary)
+2. [Findings](#2-findings)
+3. [Decisions](#3-decisions)
+4. [Target architecture](#4-target-architecture)
+5. [Phases](#5-phases)
+6. [Expected effect](#6-expected-effect)
+7. [Repository changes](#7-repository-changes)
+8. [Open points](#8-open-points)
+9. [How the numbers were measured](#9-how-the-numbers-were-measured)
+
+## 1. Summary
+
+`ifirn` is one machine running a full kubeadm cluster that has grown for nine years. It is permanently overloaded (load 20 on 4 cores), and three things cause most of it:
+
+- **Crawlers.** About 90% of all HTTP requests are bots walking the code forges (cgit, Gerrit, GitLab).
+- **GitLab.** Twelve pods, an operator, an S3 store, a cache and a VM-isolated runner, for 49 projects and no CI jobs in the last 30 days.
+- **The platform itself.** kubelet, containerd, apiserver, etcd, Calico and Gatekeeper together use roughly 0.8 of the 4 cores.
+
+A lot of what is deployed is no longer running: 22 Deployments are scaled to zero and 23 volume claims are mounted by nothing.
+
+The plan is a **hybrid**: k3s for the web apps; the shared databases, Samba and mailcow move to the host under systemd, so they keep running when the cluster is down. It proceeds in phases that each leave the system working, starting with the bot gate, which gives most of the CPU relief on its own.
+
+## 2. Findings
+
+### 2.1 Hardware and host
+
+| Item | Value |
+|---|---|
+| CPU | AMD Ryzen 3 2200G, 4 cores, 4 threads (AM4 socket) |
+| RAM | 48 GB; 43 GB used, 8 GB swapped out |
+| Swap | 16 GB zram plus a ZFS zvol (`rpool/swap`) |
+| OS | Ubuntu 24.04.5, kernel 6.8, cgroup v2 |
+| `rpool` | 2 mirrors of HDDs (2 × 3 TB WD Red, 2 × 5 TB Seagate), 7.27 T, 67% full |
+| `ssd2` | one 512 GB NVMe, no redundancy, 16% full; holds only `/var/lib/containerd` |
+| Network | `enp37s0` 192.168.2.153 (DHCP) + 192.168.1.119 (secondary, used by the apiserver); wifi `wlp36s0` is also up and carries the same secondary address; WireGuard `wg0` 10.8.4.100 |
+| Snapshots | sanoid on all of `rpool` (24 hourly, 30 daily, 6 monthly); 5,385 snapshots under `rpool/var/k8s` |
+| Off-box backup | **none found.** No syncoid, restic or similar job in cron or systemd |
+
+Load at the time of measurement:
+
+| Metric | Value |
+|---|---|
+| Load average | 20.7 / 20.7 / 18.9 |
+| CPU pressure (PSI some, 5 min) | 68% |
+| I/O pressure (PSI some, 5 min) | 28%, peaks above 50% |
+| CPU requests / limits in Kubernetes | 85% / 1008% of the node |
+| Memory requests / limits | 62% / 98% |
+
+Top CPU consumers (percent of one core):
+
+| Process | CPU |
+|---|---|
+| GitLab puma workers (2 pods) | 40 + 40 |
+| kubelet | 35 |
+| Gerrit JVM | 26 |
+| mailcow Kata VM (qemu) | 25 |
+| cgit CGI | 18 |
+| GitLab Sidekiq | 17 |
+| containerd | 16 |
+| kube-apiserver | 11 |
+| Traefik | 8 |
+| kube-controller-manager | 7 |
+| etcd | 5 |
+
+Other host observations:
+
+- `rpool/containerd` (111 G) and `ssd2/containerd` have the same mountpoint, so the old one is shadowed and reclaimable.
+- `rpool/archive` (141 G) and `rpool/lxd` (1.3 G) are old; one libvirt VM `tsa` exists and is shut off.
+- A clone from 2021, `pvc-72646cc4…__autosnap_2021-08-12_20:00:02_hourly` (3.7 G), is still in the PV tree.
+- Running host services that look unused: `tor`, `rinetd` (empty config), `ModemManager`, `avahi-daemon`, `mom`, `snapd`, `nix-daemon`.
+- Custom timers: `mulk-add-secondary-ip` (fails every hour), `mulk-containerd-prune` (obsolete), `mulk-cri-prune`, `mulk-nerdctl-prune`, `mulk-server-watchdog`, `ifirn-rr-update` (dynamic DNS for regfish and joker).
+
+### 2.2 Kubernetes platform
+
+| Component | Version / shape |
+|---|---|
+| Distribution | kubeadm, single node, v1.37.2, control plane as static pods |
+| Datastore | etcd 3.7.0 |
+| Runtime | containerd 2.2.1, overlayfs snapshotter |
+| CNI | Calico 3.33.0 through the Tigera operator: calico-node, typha, kube-controllers, 2 × calico-apiserver, operator; IPIP, BGP enabled, pool 10.240.0.0/12 |
+| Service proxy | kube-proxy DaemonSet |
+| Ingress | Traefik v3.7.16 (Helm) on hostPorts 80/443, reading `nginx`-class Ingresses through the ingress-nginx compatibility provider; 35 Ingresses, 2 IngressRoutes |
+| Certificates | cert-manager 1.21.3, one ClusterIssuer (`letsencrypt-prod`, HTTP-01), 34 Certificates |
+| Storage | local-path-provisioner 0.0.37 with custom ZFS hooks, one dataset per PV under `rpool/var/k8s`; 83 PVCs |
+| Policy | Gatekeeper 3.23.1 (audit + controller); its only content is two `Assign` mutations that set CPU requests to 1m in `gitlab-system` |
+| Sandboxing | kata-deploy 3.28.0 installs 19 RuntimeClasses; two pods use `kata-qemu` (mailcow, gitlab-runner) |
+| Other | metrics-server; 83 CRDs (22 Calico, 9 Tigera, ~17 Gatekeeper, 25 Traefik, 6 cert-manager, GitLab, Garage) |
+| Helm releases | calico, garage, gatekeeper, gitlab-operator, kata-deploy, mastodon, metrics-server, openwebui, traefik, valkey |
+| Tenancy | users `gericht`, `lidia`, `magdalena`, `simon` with `edit` on their namespaces; Pod Security labels per namespace; none of them deploy any more |
+
+There is one NetworkPolicy in the whole cluster (from the Mastodon chart) and no monitoring stack.
+
+### 2.3 Traffic
+
+18,460 requests passed Traefik in 30 minutes (about 10 per second):
+
+| Router | Requests | Share | Notes |
+|---|---|---|---|
+| cgit (`git.benkard.de`) | 7,903 | 43% | 1,217 distinct IPs; `/log`, `/diff`, `/plain`, `/commit` of two repositories |
+| Gerrit | 5,770 | 31% | 1,438 distinct IPs; almost all `/plugins/gitiles/…`; 30% are 302 redirects to Keycloak |
+| GitLab | 2,970 | 16% | 967 distinct IPs; 23% end as 499, 6% as 502 because GitLab cannot keep up |
+| Keycloak | 413 | 2% | mostly the login redirects triggered by Gerrit crawlers |
+| Phorge | 449 | 2% | |
+| Dendrite | 314 | 2% | federation |
+| everything else | ~640 | 4% | muma, Nextcloud, mailcow, registry, static sites, Mastodon (16 requests) |
+
+The crawlers send no User-Agent header and spread over thousands of addresses, so per-IP and per-UA limits do not catch them. The existing 5 r/s cap on cgit keeps cgit alive but also throttles real users.
+
+### 2.4 Workloads that are running
+
+| Namespace | Workload | Notes |
+|---|---|---|
+| `gitlab-system` | GitLab 19.5.3 via operator 3.5.3: webservice × 2, sidekiq, gitaly, gitlab-shell × 2, kas, registry, mailroom, exporter, toolbox, operator; Valkey | ~1.3 cores, ~6 GB. 49 projects, 12 active users, 190 events in 90 days, 0 CI jobs in 30 days. `gitlab-mailroom` has restarted 44 times |
+| `garage` | Garage 2.3.0 | S3 backend for GitLab only, 1.1 G of data |
+| `mastodon` | web, sidekiq, streaming, Elasticsearch, Redis | ~2.2 GB RAM |
+| `mulk` | mailcow | Docker inside a privileged Kata VM, custom image, 8 Gi reserved, 14 PVCs, ~0.5 core |
+| `mulk` | zulip (+ redis, memcached, rabbitmq in one pod) | 3 GB in use, 5.5 Gi reserved |
+| `mulk` | gerrit 3.8.2 | 1.2 GB JVM |
+| `mulk` | git (cgit + gitolite) | canonical git hosting; feeds `git-github-replication` every 2 h |
+| `mulk` | phabricator (Phorge 2026.27 + phd) | own image |
+| `mulk` | nextcloud 35 | 453 G of data |
+| `mulk` | samba | hostNetwork, SMB on 445 and sshd on 22445; **3.97 T** of data |
+| `mulk` | keycloak 26.8.1 | OIDC for most apps |
+| `mulk` | outline 1.12.0 | only client of `system/redis` |
+| `mulk` | dendrite 0.15.2, coturn 4.18.0 | Matrix |
+| `mulk` | mulkcms, mulkcms2, static-web, magdalena-web | sites |
+| `mulk` | tt-rss, tikiwiki, znc, tinc | tinc logs only failed peer lookups |
+| `mulk` | open-webui, ollama, pipelines, redis | no GPU on this machine |
+| `mulk` | gitlab-runner (Kata), marge | `marge` has restarted 1,227 times |
+| `mulk--jenkins` | Jenkins (`jdk11` image) | idle |
+| `lidia` | WordPress | |
+| `simon` | dasbahn, muma | |
+| `system` | postgresql 18 (+ pgbouncer 1.12), mariadb 10, redis 5.0.7 | shared databases |
+| `system` | portus 2.4.3 + registry 2.5.2 + nginx | private registry `docker.benkard.de`; Portus is unmaintained, the registry rejects OCI manifests; 45 G of images; 16 running containers pull from it |
+| `system` | port-proxy (`k8s.gcr.io/proxy-to-service:v2`) | forwards host ports 655 (tinc) and 29418 (Gerrit SSH) |
+
+CronJobs: `mastodon-media-remove` (weekly), `git-github-replication` (2-hourly), `nextcloud-webcron` (5-minutely); suspended: `doctowatch` (for 5 years), `renovate`.
+
+Host ports in use: 80, 443 (Traefik); 25, 110, 143, 465, 587, 993, 995, 4190, 19991 (mailcow); 3478, 3479, 5349, 49152–49160 (coturn); 445, 22445 (Samba); 10456 (znc); 655, 29418 (port-proxy). NodePorts: 32222 (GitLab SSH), 30110 (gitolite), 30334 (Gerrit SSH), 31025 (mailcow), 32340 (PostgreSQL), 30025/31907 (tinc), 31410 (Keycloak), 31486 (mulkcms), 32339 (registry UI).
+
+### 2.5 Workloads that are not running
+
+Deployments at 0 replicas (22): `magdalena/caddy`, `schreiberlinge/wordpress`, and in `mulk`: `elasticsearch`, `feedsheet`, `foswiki`, `hshello`, `hubzilla`, `kanboard`, `kibana`, `kibana-keycloak-proxy`, `kube-registry`, `kube-registry-ui`, `mailcow-fake`, `mongooseim`, `strangequirk`, `xwiki`, plus the Ingresses, Services and volumes that belong to them.
+
+PVCs mounted by no pod (23): `gitlab-minio`, `redis-data-gitlab-redis-master-0`, `magdalena/satt-results`, mastodon `elasticsearch-data-0`, `-data-1`, `-master-1`, `minio-data0-mastodon-pool-0-0`, and in `mulk`: `conduit-data`, `elasticsearch-data`, `foswiki-data`, `hubzilla-data`, `kanboard-data`, `kanboard-plugins`, `kibana-data`, `kube-registry-image-store`, `mailcow-config`, `mailcow-vmail-attachments`, `mongooseim-acme`, `mongooseim-mnesia`, `xwiki-data`, and the three `schreiberlinge/wordpress-*`.
+
+Four Ingresses have no class and are served by nothing (`hshello`, `kibana-keycloak-proxy`, `mongooseim`, `xwiki`). Namespace `gericht` holds no workloads.
+
+### 2.6 Data
+
+Largest volumes (ZFS `used`, including snapshots):
+
+| Volume | Size |
+|---|---|
+| `samba-homes` | 3.98 T |
+| `nextcloud-data` | 503 G |
+| `portus-registry` | 45.5 G |
+| `mailcow-docker` (Docker images inside the VM) | 30.3 G |
+| `gitlab-runner-docker` | 20.9 G |
+| mailcow redis / vmail / postfix / vmail-index / solr | 16 / 13.5 / 10.6 / 6.4 / 6.4 G |
+| `system/redis-data` | 10.3 G, of which 7 MB is live (old AOF in snapshots) |
+| `postgresql-data` | 10.3 G (3.4 G live) |
+| `kube-registry-image-store` (unused) | 8.0 G |
+| `elasticsearch-data` (unused) | 5.4 G |
+| `mastodon-system` | 5.4 G |
+| `mysql-data` | 3.4 G (0.6 G live) |
+
+PostgreSQL databases: `tt-rss` 1.6 G, `nextcloud` 1.5 G, `dendrite` 387 M, `gitlab` 309 M, `hubzilla` 216 M, `mulkcms` 135 M, `mastodon` 107 M, `foswiki` 51 M, `zulip` 26 M, `xwiki`, `mongooseim`, `kanboard`, `keycloak`, `outline`, `portus`, `benki`, `ghost`, `gerrit`, and nine empty `dendrite_*` databases. Databases with no connections that belong to stopped apps: `hubzilla`, `foswiki`, `xwiki`, `mongooseim`, `kanboard`, `ghost`, `benki`. The server runs with `max_connections=2000`; about 140 are in use.
+
+MariaDB databases: `mailcow` 390 M, `phabricator_*` (about 150 M in ~60 schemas), `tikiwiki` 27 M, `wordpress_schreiberlinge` 13 M, `movabletype` 4 M, `wordpress_lidia` 2 M.
+
+### 2.7 Maintainability problems
+
+- **The repository does not describe the cluster.** About 70 directories are untracked; Outline and Keycloak are upgraded with `kubectl set image` and their files here are years stale; `mailcow/` alone is 3,720 tracked files of a vendored upstream.
+- **Four ways to deploy:** Helm with values in the repo, plain manifests, an operator CR, and imperative edits.
+- **Secrets in the open:** at least one Deployment (`kanboard`) carries a database password as a plain environment value.
+- **Upgrades are fragile.** The 1.32→1.37 round needed manual etcd swaps, apiserver manifest bounces and kubeadm flag workarounds (see the upgrade notes); each control-plane restart takes minutes on this node.
+- **Circular dependencies.** The private registry, its database and the workloads that pull from it all run in the same cluster; bouncing them together has already caused pull failures.
+- **Storage hook history.** PVs created before 2026-11-04 may hide data under ZFS child datasets after a reboot.
+
+## 3. Decisions
+
+Taken on 2026-11-16:
+
+| Question | Decision |
+|---|---|
+| Platform | Hybrid: k3s for web apps; mailcow, Samba and the shared databases on the host |
+| Forges | Keep all four for now: cgit + gitolite, GitLab, Gerrit, Phorge |
+| GitLab | Shrink first; **consider replacing it with something smaller as a later step** (Phase 7) |
+| Retire | Jenkins, Open WebUI + Ollama, and everything already stopped |
+| Tenancy | Single administrator; per-user RBAC and kubeconfigs can go |
+
+## 4. Target architecture
+
+```
+ifirn (Ubuntu 24.04, ZFS, sanoid)
+├─ systemd tier (independent of k3s)
+│   ├─ Podman Quadlets, host network:  postgres:18   mariadb:10.x   samba
+│   └─ libvirt VMs (NAT network + nftables DNAT):  mailcow (upstream mailcow-dockerized)   ci-runner (optional)
+└─ k3s (single binary, SQLite datastore, flannel host-gw, embedded kube-proxy / CoreDNS / metrics-server)
+    ├─ Traefik (own Helm release, existing values) + Anubis proof-of-work gate on forge routes
+    ├─ cert-manager (unchanged), local-path-provisioner with this repo's ZFS hooks
+    ├─ registry:3 + htpasswd (replaces Portus)
+    └─ apps: GitLab (one Omnibus pod), Gerrit, Phorge, cgit + gitolite, Mastodon, Zulip, Nextcloud, Keycloak,
+       Outline, Dendrite + coturn, mulkcms / mulkcms2, tt-rss, tikiwiki, WordPress (lidia), static sites, znc, tinc, simon/*
+```
+
+Removed for good: kubeadm, etcd, Calico and the Tigera operator, the kube-proxy DaemonSet, Gatekeeper, the GitLab operator, Garage, Valkey, kata-deploy, Portus, port-proxy, Jenkins, Open WebUI and Ollama, per-user RBAC, per-namespace pull secrets.
+
+Reasons for the main choices:
+
+- **k3s instead of a slimmed kubeadm.** One binary on SQLite removes the class of problems seen in the last upgrade round (etcd swaps, static-pod backoff, kubeadm timeouts, Typha holds). Manifests and Helm charts carry over unchanged.
+- **Leaving Kubernetes entirely was rejected** because about 30 small web apps already have working manifests, Ingresses and certificates; rewriting them all would cost more than it saves.
+- **Quadlets that reuse the same images and data directories** for PostgreSQL, MariaDB and Samba. No dump and restore and no config rewrite; only the supervisor changes. Apps keep using `postgresql.system` and `mysql.system` through selector-less Services that point at the node.
+- **mailcow in a plain VM.** It is already Docker inside a Kata VM with a custom image. A libvirt VM with unmodified upstream mailcow-dockerized gets upstream's `update.sh`, makes Kata unnecessary, and avoids Docker-versus-CNI firewall conflicts on the host.
+- **GitLab as a single Omnibus container.** Replaces the operator, 12 pods, 6 autoscalers, Garage, Valkey, 3 Issuers and Gatekeeper, while still using the shared PostgreSQL.
+- **cert-manager and the Traefik Helm release stay.** Both work, cost little, and 34 certificates depend on them.
+
+## 5. Phases
+
+Each phase is useful on its own and leaves the system working. The order matters: Phase 0 creates the CPU headroom that makes the later phases safe.
+
+### Phase 0: stop the bleeding
+
+No architecture change; about one evening.
+
+1. **Anubis in front of the forges.** One Anubis instance in namespace `traefik` in forwardAuth mode, a `forge-botgate` Middleware in `traefik/middlewares.yaml`, attached to the routers of cgit (IngressRoute `git-cgit-cgi` in `git/git.yaml`), Gerrit, GitLab web and Phorge.
+   - Challenge all HTML requests, including those with an empty User-Agent.
+   - Bypass git smart HTTP (`/info/refs`, `git-upload-pack`, `git-receive-pack`), `/api/`, `/oauth`, `/-/health`, Gerrit `/a/`, and the User-Agents `git/*` and `gitlab-runner`.
+   - Afterwards relax `git-cgit-ratelimit` from 5 r/s.
+2. **Cheap per-app measures.** Enable cgit's response cache (`cache-size`, `cache-root` on an emptyDir). Make Gerrit gitiles require sign-in, since cgit already publishes the same repositories. Turn on GitLab's built-in rate limits for unauthenticated requests.
+3. **GitLab quick trim** in `gitlab-system/gitlab.yaml`: webservice 2→1, gitlab-shell 2→1, KAS and gitlab-exporter off.
+4. **Fix or stop the noise.** `marge` and `gitlab-mailroom` crash loops; delete CronJob `doctowatch`.
+5. **Safety net before anything destructive.** Set up off-box replication (syncoid or restic to an external target) for at least `samba-homes`, `nextcloud-data`, the mail volumes and the database volumes. First confirm whether a backup exists that this inventory did not see.
+
+Checks: load below 6; CPU pressure below 30%; Traefik request counts for the three forge routers down by about 80%; `git clone` over HTTPS and SSH works on all four forges; a GitLab runner still picks up a job.
+
+### Phase 1: prune, and make the repository authoritative
+
+Still on kubeadm.
+
+1. **Archive, then delete, the stopped apps.** For each one: dump its database, take a final ZFS snapshot of its volumes into `rpool/archive/k8s-retired-2026-11/`, then delete its Deployment, Service, Ingress, PVCs and Secrets and drop the database.
+   - Apps: hubzilla, xwiki, foswiki, kanboard, mongooseim, kibana + kibana-keycloak-proxy + elasticsearch, hshello, feedsheet, strangequirk, kube-registry + UI, mailcow-fake, schreiberlinge WordPress, magdalena caddy, Jenkins, Open WebUI + Ollama + pipelines + redis (`helm uninstall openwebui`).
+   - Orphan PVCs listed in 2.5.
+   - Unused databases: `ghost`, `benki`, `gerrit` (if Gerrit is on NoteDb), the nine empty `dendrite_*`, `movabletype`.
+   - Namespaces `gericht`, `magdalena`, `schreiberlinge`, `mulk--jenkins`; the `owner-edit` RoleBindings and the extra kubeconfig users.
+2. **Confirm per app whether it is still wanted:** tinc (the host already has WireGuard), znc, tikiwiki, the old `mulkcms` next to `mulkcms2`, renovate, marge, and Mastodon's Elasticsearch (needed only for full-text search).
+3. **Replace Portus** with `registry:3` and htpasswd behind Traefik on the same hostname, serving the existing `portus-registry` volume (the on-disk layout is the same). OCI images then push normally and `bin/build-and-push-image` works without special flags. Drop database `portus`.
+4. **Replace `system/port-proxy`:** hostPort 29418 directly on the Gerrit pod; the same for tinc's 655 if tinc stays.
+5. **Restructure the repository**, one commit per app:
+   - `apps/<name>/`: manifests exported from the live cluster and cleaned (Outline and Keycloak in particular), or `values.yaml` plus a pinned chart version for Helm apps.
+   - `platform/`: k3s config, Traefik, cert-manager, local-path-storage, registry.
+   - `host/`: Quadlets, VM definitions, nftables, sanoid config, systemd timers.
+   - Delete stale untracked directories after comparing them with the live state. Move plain-text passwords from Deployment env into Secrets.
+   - Secrets stay out of git: exported to `/root/cluster-secrets/` on ifirn (root only, snapshotted).
+   - `bin/deploy <app>` wraps `kubectl apply -f apps/<app>` or `helm upgrade`.
+
+Checks: no Deployment at 0 replicas; no unmounted PVC; `kubectl diff -f apps/<name>` is empty for every app; an OCI image can be pushed to and pulled from `docker.benkard.de`.
+
+### Phase 2: databases and Samba to the host
+
+One short outage per service.
+
+1. Install Podman and write Quadlets in `host/quadlets/`:
+   - `postgres.container`: `postgres:18.<pinned>`, host network, today's arguments with `max_connections` lowered from 2000 to 300, the existing `postgresql-data` and `postgresql-wal` datasets. Add pgbouncer only if something still connects to it; no pod environment refers to it.
+   - `mariadb.container`: the exact current 10.x tag, today's arguments, the existing `mysql-data` dataset.
+   - `samba.container`: the current image, host network, the `samba-homes` dataset, config and secrets copied from the ConfigMap and Secrets into `/etc/ifirn/samba/`.
+2. Cutover per service: scale the Deployment to 0, start the Quadlet, replace the Service with a selector-less Service and EndpointSlice pointing at the node address. Restrict 5432 and 3306 to localhost and the pod network with `pg_hba.conf` and nftables. Drop NodePort 32340 unless a LAN client uses it.
+3. Give the node a proper static address: put `192.168.1.119/24` into the NetworkManager profile of `enp37s0` and take it off wifi. This also retires the failing `mulk-add-secondary-ip` unit.
+4. Move the three datasets out of the PV tree (`rpool/data/postgres`, `rpool/data/mariadb`, `rpool/data/samba-homes`). Set the PVs to `Retain` before deleting the PV and PVC objects.
+5. Nightly `pg_dumpall` and `mariadb-dump` from a systemd timer into `rpool/data/db-dumps`; this replaces the `postgresql-export` volume.
+6. Optional but recommended: keep the two database datasets on `ssd2` (NVMe) with hourly `syncoid` to `rpool`. This removes most of the I/O pressure; if the NVMe dies, at most one hour of database changes is lost.
+7. Replace `system/redis` 5.0.7 (only Outline uses it) with a small Valkey Deployment next to Outline on a fresh volume.
+
+Checks: every database client logs in and writes (Keycloak, Zulip, tt-rss, Nextcloud, GitLab, Mastodon, Dendrite, Outline, mulkcms, Phorge, tikiwiki, lidia's WordPress, mailcow); SMB and SFTP on 22445 work from a LAN client; stopping kubelet interrupts neither Samba nor the databases.
+
+### Phase 3: mailcow into a VM, Kata away
+
+1. Create libvirt VM `mailcow` (Debian 13, 4 vCPUs, 6 GB, OS disk as a zvol on `ssd2`) with a static lease on the libvirt NAT network. Share one dataset, `rpool/data/mailcow`, into it with virtiofs for the Docker volumes that hold mail and state, so that sanoid keeps snapshotting at file level.
+2. Install upstream mailcow-dockerized at the version of the running image. Stop the pod, `rsync` the 12 live mailcow volumes into the matching Docker volumes, copy `mailcow.conf`, and move the `mailcow` schema from the shared MariaDB into mailcow's own MariaDB container.
+3. Host nftables DNAT (`host/nftables/`) for 25, 110, 143, 465, 587, 993, 995 and 4190 to the VM, which preserves client addresses. Check what 19991 and NodePort 31025 are used for and carry them over if needed. `mail.benkard.de` and `autodiscover` stay on Traefik, backed by a selector-less Service to the VM's web port.
+4. GitLab runner: either a VM `ci-runner` (2 vCPUs, 4 GB, Docker executor, not autostarted until CI is used again) or deregister the runner for now.
+5. `helm uninstall kata-deploy`; delete the 19 RuntimeClasses, the containerd drop-ins and `kata-deploy/`. Delete the `mailcow/` build tooling once the VM has run for two weeks.
+
+Checks: mail in and out against an external mailbox; IMAP login; SOGo; autodiscover; rspamd shows real client addresses; `update.sh --check` runs clean; no RuntimeClass is left.
+
+### Phase 4: GitLab as one Omnibus pod
+
+Skip this phase if Phase 7 is decided early; see there.
+
+1. Back up with the toolbox's `backup-utility` (repositories, uploads, artifacts, LFS and packages, including what lives in Garage). Save `gitlab-rails-secret` as `gitlab-secrets.json`.
+2. New Deployment in `apps/gitlab/`: `gitlab/gitlab-ce` at the same version, `strategy: Recreate`, one PVC each for `/etc/gitlab`, `/var/opt/gitlab` and `/var/log/gitlab`. `gitlab.rb` in a ConfigMap: external PostgreSQL, bundled Redis, local object storage, bundled nginx on plain HTTP behind Traefik, registry only if it is in use, `puma['worker_processes'] = 0`, `sidekiq['concurrency'] = 10`, Prometheus and exporters off. Memory limit 4 Gi.
+3. Restore, run `gitlab-rake gitlab:check` and `gitlab:doctor:secrets`, then point the Ingresses and SSH NodePort 32222 at the new pod.
+4. Remove the GitLab CR, `helm uninstall gitlab-operator valkey garage gatekeeper`, the two `Assign` objects, the Issuers, autoscalers, IngressClass `gitlab-nginx`, namespaces `garage` and `gatekeeper-system`, and `gatekeeper-values.yaml`.
+
+Checks: web login through Keycloak; clone and push over SSH and HTTPS; an LFS object and a CI artifact download; marge and the replication job still authenticate; one pod in `gitlab-system`; GitLab below 0.4 core when idle.
+
+### Phase 5: cut over from kubeadm to k3s
+
+Planned outage of about 3 to 4 hours for the web apps. By this point the cluster holds roughly 30 small pods, no operators and nothing the host tier depends on.
+
+Preparation, without downtime:
+
+1. `bin/export-cluster`: for every remaining namespace, cleaned Deployments, StatefulSets, Services, Ingresses, IngressRoutes, Middlewares, ConfigMaps and CronJobs into `apps/`; Secrets (including all TLS Secrets and the ACME account key), Certificates and the ClusterIssuer into `/root/cluster-secrets/`.
+2. `bin/gen-static-pvs`: one PersistentVolume per remaining claim (`local` volume, the existing `/var/k8s/<dir>` path, node affinity `ifirn`, preset `claimRef`, reclaim policy `Retain`) plus the PVC with `volumeName`, committed as `platform/pvs.yaml`.
+3. `platform/k3s/config.yaml`: disable the bundled `traefik`, `servicelb` and `local-storage`; `flannel-backend: host-gw`; `node-ip: 192.168.1.119`; the same cluster and service CIDRs as today so that ClusterIPs referenced in configs stay valid; systemd cgroup driver; `secrets-encryption: true`. `registries.yaml` carries the `docker.benkard.de` credentials and replaces all `portus-token` pull secrets.
+4. Rehearse the full import against the local `rancher-desktop` k3s context with dummy volume paths, and fix whatever fails to apply.
+5. Export the 16 private images with `ctr images export` so they can be imported into k3s before the registry itself is up.
+
+Cutover:
+
+1. ZFS snapshots `@pre-k3s` of `rpool/var/k8s`, `rpool/var/etcd` and `rpool/ROOT/ubuntu`; copy of an etcd snapshot.
+2. Scale everything to 0, disable kubelet, `kubeadm reset` without touching `/var/k8s`, remove Calico's CNI config and `tunl0`, reboot to clear leftover firewall chains.
+3. Install k3s at the same Kubernetes minor (v1.37.x). Apply in order: local-path-storage, `pvs.yaml`, secrets, cert-manager with ClusterIssuer and Certificates, Traefik (middlewares before the Helm release), registry, then apps in dependency order with Keycloak first.
+4. Databases, mail and Samba are unaffected throughout.
+
+Rollback: `k3s-uninstall.sh`, roll back the root and etcd snapshots, re-enable kubelet. The cutover never rewrites volume data.
+
+Checks: every hostname returns the same HTTPS status as before; a test certificate becomes Ready over HTTP-01; about 45 pods; no etcd, Calico, kube-proxy or Gatekeeper processes; the k3s server below 0.25 core when idle.
+
+### Phase 6: host hygiene and upkeep
+
+1. Storage: destroy the shadowed `rpool/containerd`, the leftover `ssd2/containerd/io.containerd.snapshotter.v1.zfs`, the 2021 clone, and after 30 days the old kubeadm and etcd datasets; review `rpool/archive` and `rpool/lxd`.
+2. Swap: remove the zvol swap, keep zram.
+3. Disable host services that turn out to be unused: `tor`, `rinetd`, `ModemManager`, `avahi-daemon`, `mom`, `snapd`/LXD, wifi. Remove the timers `mulk-containerd-prune`, `mulk-cri-prune`, `mulk-nerdctl-prune` and `mulk-add-secondary-ip`.
+4. Upkeep routine in `README.org`: k3s upgrades by re-running the installer with a pinned version; `podman auto-update` for the Quadlets; mailcow's `update.sh`; image tags pinned in `apps/` and checked by Renovate.
+5. Minimal alerting: extend `mulk-server-watchdog` to send mail on failed systemd units, a degraded pool, certificates expiring within 14 days, and CPU pressure above 50% for 15 minutes.
+6. Optional hardware step if the load is still high: the board is AM4, so a Ryzen 5 5600G or 5700G class CPU (6 to 8 cores, 12 to 16 threads) is a drop-in replacement after a BIOS update and roughly triples throughput.
+
+### Phase 7 (later, to be decided): replace GitLab with something smaller
+
+GitLab remains the heaviest single application even as one Omnibus pod (about 3 to 4 GB of RAM and a noticeable idle CPU cost) for 49 projects and 12 users. Once the platform work is done, evaluate replacing it.
+
+What GitLab is used for today, and what a replacement must cover:
+
+| Use | Evidence | Requirement |
+|---|---|---|
+| Repository hosting with merge requests and issues | 49 projects, 190 events in 90 days | import of repositories, issues, merge requests, labels, milestones, releases |
+| Sign-in | Keycloak OIDC | OIDC login |
+| CI | runner registered, 0 jobs in 30 days | optional; decide whether CI is still wanted at all |
+| Merge automation | marge-bot polls several projects | built-in auto-merge or drop it |
+| Container registry, packages, LFS, Pages | `registry.gitlab.benkard.de` exists; usage not yet measured | measure before deciding |
+| Mirror target | `git-github-replication` clones from `gitlab.benkard.de` | repoint the job |
+
+Candidates:
+
+| Option | Footprint | Notes |
+|---|---|---|
+| **Forgejo** (suggested default) | one Go binary, about 150 to 300 MB RAM, PostgreSQL or SQLite | built-in GitLab migrator (repositories, issues, merge requests, labels, milestones, releases, wiki); OIDC; Actions-compatible CI with a small runner; package and container registry; auto-merge; push and pull mirrors |
+| Gitea | same shape as Forgejo | Forgejo is the community-governed fork; functionally close |
+| No replacement | zero | fold GitLab's projects into the forges that stay (gitolite + cgit for hosting, Gerrit or Phorge for review). Loses issues and merge-request history unless exported |
+
+Wider consolidation that this step makes possible, each to be decided separately:
+
+- Forgejo's container registry could replace the standalone `registry:3` behind `docker.benkard.de`.
+- Forgejo's push mirrors could replace the `git-github-replication` CronJob.
+- Forgejo could also take over from cgit + gitolite, which would leave three forges instead of four. Its repository browser is cheaper to serve than cgit's CGI, but it would still need the bot gate.
+
+Suggested way to decide:
+
+1. After Phase 0, record one month of real GitLab use: logins, pushes, merge requests, CI jobs, registry pulls, package and LFS traffic.
+2. Stand up Forgejo next to GitLab (one pod, database in the shared PostgreSQL) and import two or three representative projects with the migrator. Check merge-request history, issue references, LFS objects and OIDC login.
+3. If the trial is good, migrate project by project, set GitLab read-only, keep a final `gitlab-backup` in `rpool/archive`, and redirect `gitlab.benkard.de` URLs to the new locations.
+
+Interaction with Phase 4: converting GitLab to Omnibus is only worth the effort if GitLab stays for a good while. If the decision to replace it is taken before Phase 4 starts, skip Phase 4, migrate to the replacement while still on the operator, and then remove the operator, Garage, Valkey and Gatekeeper in one go. Phase 5 only requires that the operator stack is gone by then, whichever way that happens.
+
+## 6. Expected effect
+
+| | Now | After Phase 6 |
+|---|---|---|
+| Running pods | about 77, plus 22 stopped Deployments | about 45 |
+| PVCs | 83 | about 40 |
+| Helm releases | 10 | 3 (Traefik, cert-manager, Mastodon) |
+| CRDs | 83 | about 35 |
+| Platform components | kubeadm, etcd, Calico + Tigera, kube-proxy, Gatekeeper, Kata, GitLab operator, Garage, Valkey, Portus | k3s, Traefik, cert-manager, local-path |
+| Load average | about 20 | target below 4, most of it from Phase 0 |
+| RAM in use | 43 GB plus 8 GB swap | roughly 25 to 28 GB, no swap |
+
+These are estimates from the per-process measurements in section 2, not results. Phase 7 would save a further 3 GB or so.
+
+## 7. Repository changes
+
+- Reused as they are: `traefik/values.yaml`, `traefik/middlewares.yaml`, `traefik/ingressclass.yaml`, `local-path-storage/` (`local-path-storage.yaml`, `setup.sh`, `teardown.sh`, `helperPod.yaml`), `bin/build-and-push-image`, `samba/`, `mastodon/`, `zulip/`, `git/git.yaml`, `gerrit/`, `phabricator/`, `coturn/`, `dendrite/`.
+- New: the `apps/` layout, `platform/k3s/{config.yaml,registries.yaml}`, `platform/pvs.yaml`, `platform/registry/`, `platform/anubis/`, `host/quadlets/*.container`, `host/libvirt/{mailcow,ci-runner}.xml`, `host/nftables/mailcow-dnat.nft`, `host/systemd/db-dump.{service,timer}`, `bin/{export-cluster,gen-static-pvs,deploy}`, a rewritten `README.org`.
+- Removed: `calico.yaml`, `calico-values.yaml`, `gatekeeper-values.yaml`, `metrics-server-values.yaml`, `kata-deploy/`, `garage/`, `gitlab-system/` (replaced by `apps/gitlab/` or by Phase 7), `portus/`, `jenkins/`, `open-webui/`, `mailcow/` once Phase 3 has settled, `marge/` and `renovate/` if retired, and the stale untracked directories.
+
+## 8. Open points
+
+- Is there an off-box backup that this inventory missed, and if not, which target should be used (Phase 0)?
+- Keep or retire: tinc, znc, tikiwiki, old mulkcms, renovate, marge, Mastodon's Elasticsearch (Phase 1)?
+- Database datasets on the NVMe with hourly replication to the HDD pool (Phase 2)?
+- A CI runner VM, or deregister the runner (Phase 3)?
+- Are GitLab's container registry and Pages in use (Phases 4 and 7)?
+- Replace GitLab, and if so before or after Phase 4 (Phase 7)?
+
+## 9. How the numbers were measured
+
+All read-only. Re-run these to compare before and after each phase.
+
+```sh
+# Cluster inventory
+kubectl get nodes -o wide; kubectl top nodes; kubectl top pods -A --sort-by=cpu
+kubectl get deploy,sts,ds,cronjob -A -o wide
+kubectl get ingress,ingressroute,middleware -A
+kubectl get pvc -A; helm list -A; kubectl get crd
+kubectl describe node ifirn        # "Allocated resources"
+
+# PVCs mounted by no pod
+comm -23 <(kubectl get pvc -A --no-headers | awk '{print $1"/"$2}' | sort) \
+         <(kubectl get pods -A -o json | jq -r '.items[] | .metadata.namespace as $n
+            | .spec.volumes[]? | select(.persistentVolumeClaim)
+            | "\($n)/\(.persistentVolumeClaim.claimName)"' | sort -u)
+
+# Requests per Traefik router over 30 minutes
+kubectl -n traefik logs deploy/traefik --since=30m \
+  | awk '{ if (match($0, /"[a-z0-9-]+@[a-z]+"/)) print substr($0, RSTART, RLENGTH) }' \
+  | sort | uniq -c | sort -rn
+
+# Host (on ifirn)
+uptime; cat /proc/pressure/cpu /proc/pressure/io /proc/pressure/memory; free -g
+ps -eo pcpu,pmem,rss,comm --sort=-pcpu | head -25
+zpool list; zfs list -d 1 -o used,refer,usedbysnapshots,name -S used rpool/var/k8s
+systemctl list-timers; systemctl --failed
+
+# Databases
+kubectl -n system exec deploy/postgresql -c master -- psql -U postgres -Atc \
+  "select datname, pg_size_pretty(pg_database_size(datname)) from pg_database order by pg_database_size(datname) desc"
+```