feat(ci-runners): run the deploy runner in a Kata microVM (staged)

The CI capsule cannot enforce PSA baseline: every nested dockerd needs
SYS_ADMIN+NET_ADMIN in the pod spec and baseline forbids exactly those, which
sysbox, gVisor and Kata all reproduce (measured on both arches, card
t_8aa4af50). What a runtime CAN change is what privileged:true means.

Stage 1, one runner: forgejo-runner-deploy-arm64 (rpi) gets
runtimeClassName: kata-qemu, so its privileged dind and job containers run
inside a QEMU/KVM microVM instead of on rpi's host namespaces. The amd64 and
shared arm64 runners stay on privileged dind under runc, untouched.

Kata-specific plumbing in the same Deployment:
- loop-backed ext4 data-root (16GiB image on the existing claim) because
  overlayfs refuses virtiofs and Docker would silently fall back to vfs;
- binfmt_misc + tonistiigi/binfmt --install amd64 on every start, because the
  guest kernel has no qemu handlers and deploy-site.yml cross-builds amd64;
- the runner waits for /var/run/dind-ready (touched after both are set up).

RuntimeClass kata-qemu is cluster-scoped; the containerd handler lives on rpi
only (/etc/containerd/conf.d/50-kata.toml, kata-static 4.4.0). Rollback is one
field. docs/pod-security.md records the measurement and states plainly that the
namespace stays enforce: privileged.
This commit is contained in:
Sirius DevOps 2026-11-27 02:08:47 -05:00
commit 989a0997fb
4 changed files with 180 additions and 14 deletions

View file

@ -99,11 +99,86 @@ What was already removed from the runner shape (same change, card
Residual risk, stated plainly: a privileged dind container is node root on the
node it runs on, and a CI job can reach that daemon socket by design. The
capsule therefore means "trusted CI code" rather than isolation. The remaining
hardening path is a runtime that virtualises the container runtime (sysbox or
gVisor) behind a `RuntimeClass`, which would allow `enforce: baseline` on the
capsule too; that is a separate design card because it changes how every job
container executes.
capsule therefore means "trusted CI code" rather than isolation. The one
hardening path that changes what `privileged: true` *means* is a virtualised
runtime behind a `RuntimeClass`; it was evaluated and staged on one runner —
see below.
## `enforce: baseline` on `ci-runners` is unreachable by any runtime (measured)
All three candidate runtimes were installed on **both** arches and exercised
against the live cluster on 2026-11-27 (v1.36.4, containerd 2.3.4/2.3.5, Cilium
native routing). Architecture was never the blocker: sysbox-ce 0.7.2 ships an
arm64 `.deb`, gVisor publishes `gvisor-aarch64`, Kata publishes
`kata-static-4.4.0-arm64`, and `/dev/kvm` exists on siriussec **and** rpi.
The blocker is a contradiction, not a bug:
> PSA `baseline` forbids adding any capability outside `AUDIT_WRITE, CHOWN,
> DAC_OVERRIDE, FOWNER, FSETID, KILL, MKNOD, NET_BIND_SERVICE, SETFCAP, SETGID,
> SETPCAP, SETUID, SYS_CHROOT` — and every nested dockerd needs `SYS_ADMIN`
> (overlay, mounts) + `NET_ADMIN` (docker0, iptables) **in the pod spec**.
Measured verdicts, each on a live cluster:
| runtime | verdict |
|---|---|
| sysbox-ce 0.7.2 | The only one **admitted** at `enforce: baseline` with a clean spec (id-mapped userns, `uid_map 0 427680 65536`), but its inner dockerd cannot use the CNI-owned pod netns: `Failed to create bridge docker0 via netlink: operation not permitted`, `iptables ... Could not fetch rule set generation id: Permission denied`, and with `--bridge=none` every `docker run` dies on `failed to set into network namespace ... operation not permitted`. sysbox also bans inner `--net=host`, so there is no egress fallback. Also needs `enable_unprivileged_ports=false` + `enable_unprivileged_icmp=false` under containerd 2.x. |
| gVisor | Full CI shape works (nested run, pull, build, overlay2) **only** with `capabilities.add: ["ALL"]`; with a baseline-clean spec dockerd never starts (`failed to mount overlay: operation not permitted`). |
| Kata 4.4.0 | `privileged: false` hits the same caps wall *inside the guest*. With `privileged: true` the whole CI shape works on amd64 **and** arm64 (nested run, bridge+NAT egress, `docker build`) — but `/var/lib/docker` is virtiofs, overlayfs refuses it, and Docker falls back to `vfs`. |
So the letter of the original audit finding (drop `privileged`, enforce
`baseline`) cannot be met by swapping a runtime; only reworking CI off
docker-in-docker could, and that rewrites every workflow. The operator's
decision (card `t_8aa4af50`) was to take the one option that changes the
*consequence* of the flag, staged to a single runner.
## Kata microVM on the deploy runner (`forgejo-runner-deploy-arm64`, staged)
`forgejo-runner-deploy-arm64` (rpi) now runs with
`runtimeClassName: kata-qemu`. **Read this precisely:**
* the pod **still declares `privileged: true`** and `ci-runners` **still
enforces `privileged`**. Nothing about this namespace's PSA level changed; a
privileged pod in `forgejo` is still rejected;
* what changed is the blast radius: the dind sidecar and the job containers
live in a QEMU/KVM microVM with no host namespaces, no host kernel and only
the volumes the pod mounts. An escape from CI has to beat KVM, not just the
container runtime. On a runc runner the same flag is direct root on rpi;
* `forgejo-runner-amd64` and `forgejo-runner-arm64` are untouched (still
privileged dind under runc), so `docker-amd64` and `runs-on: docker` are
unchanged. Converting them is a separate decision, taken on the measured cost
of this one.
How it is wired (all in `apps/base/forgejo/`):
* `kata-runtimeclass.yaml` — `RuntimeClass` `kata-qemu`, handler `kata-qemu`;
* rpi's containerd has the handler via the drop-in
`/etc/containerd/conf.d/50-kata.toml` (`io.containerd.kata.v2`,
`privileged_without_host_devices = true` — a privileged container otherwise
receives all 218 of the node's `/dev` nodes, which is meaningless inside a VM
and makes runtime-rs fail the create with `get host path failed`), with
kata-static 4.4.0 under `/opt/kata` and
`/etc/kata-containers/configuration.toml` symlinked to the runtime-rs QEMU
config;
* the dind sidecar builds its own ext4 data-root: a 16 GiB image file at
`/data-docker/kata-ext4.img` on the existing claim, attached with
`losetup /dev/loop0` (the guest has to `mknod` the node — only
`/dev/loop-control` exists) and mounted at `/var/lib/docker`. This is what
restores `overlay2`; without it Docker silently uses `vfs`;
* the guest kernel has **no** binfmt registrations (the host's are not visible
from inside the VM), so every start mounts `binfmt_misc` and runs
`tonistiigi/binfmt --install amd64`. Without that, `deploy-site.yml`'s
`docker buildx build --platform linux/amd64` dies with `exec format error` /
`buildkit-qemu-x86_64: executable file not found`;
* the runner container waits for `/var/run/dind-ready`, which the dind sidecar
touches **after** the data-root and binfmt are set up, so a job can never
start against a half-initialised daemon.
Rollback is one field: drop `runtimeClassName: kata-qemu` from that Deployment
(Flux) — the pod returns to runc/privileged dind on the same claim, and the
`kata-ext4.img` is an unused file until then (it is a cache; deleting it is
safe). The containerd drop-in on rpi is inert once no pod asks for the handler.
## Why the dind sidecar keeps `privileged` (measured, do not re-derive)