ci(runners): isolate the CI capsule in forgejo-runners, enforce baseline on forgejo

The three Actions runners (privileged dind sidecars) and the nightly prune
CronJob (hostPath /var/run/docker.sock) cannot live under PSA baseline, so
they move to their own namespace `forgejo-runners` with `enforce: privileged`
(plus warn/audit restricted). That lets `forgejo` — Forgejo, CNPG Postgres,
cluster-backup — enforce `baseline` instead of only warning.

The dind sidecars stay privileged: measured on these nodes, a non-privileged
pod cannot host a container runtime (cgroup fs is mounted ro; rootless dind
cannot mount procfs; procMount=Unmasked needs hostUsers=false where subuid
maps and /dev/net/tun are refused). See docs/pod-security.md.

- PVCs/PVs are reused, not recreated: the two static Retain PVs on rpi and the
  dynamic local-path PV on siriussec were rebound by name, so runner.ini
  (registration uuid), the dind data-root and the actions cache survive.
- prune CronJob + its SA/Role/RoleBinding/configmap move with the runners;
  NAMESPACE and the Role scope follow.
- monitoring: runner/prune queries and runbooks now select forgejo-runners;
  cnpg_actions_* panels keep namespace="forgejo" (that is the pg namespace).
- docs: pod-security.md rewritten for the two enforced namespaces.

Verified live: all three runners 2/2 Running in forgejo-runners with their
original registration uuids and image counts, forgejo rejects a privileged pod
at admission, and a real CI image build completes (see the card).
This commit is contained in:
Lancelot 2026-11-27 01:15:07 -05:00
commit 3d21e96a9c
18 changed files with 239 additions and 127 deletions

View file

@ -16,6 +16,12 @@ finished in **27 s wall inside dind vs 28 s on the Pi's host daemon**
**peak RSS was 3.10 GiB**, which is 6× the 512 Mi currently requested and the
first thing that must change. See §15.
> **Namespace note (2026-11-27, card `t_2bbe34a8`):** the three runner
> Deployments, their PVCs and the prune CronJob moved from `forgejo` to
> `forgejo-runners` so `forgejo` can enforce Pod Security `baseline`. Commands
> below use the new namespace; the dind design and every measurement are
> unchanged.
---
## 1. What the arm64 runners depend on today
@ -622,7 +628,7 @@ difference between the two runners).
`docker:27-dind` already contains the client and the plugins:
```
$ kubectl -n forgejo exec deploy/forgejo-runner-amd64 -c dind -- sh -c 'command -v docker; ls /usr/local/libexec/docker/cli-plugins/'
$ kubectl -n forgejo-runners exec deploy/forgejo-runner-amd64 -c dind -- sh -c 'command -v docker; ls /usr/local/libexec/docker/cli-plugins/'
/usr/local/bin/docker
docker-buildx
docker-compose
@ -699,7 +705,7 @@ risk of migrating a target dir that has already caused `os error 13` corruption.
Pre-flight — every one is read-only and proves the next step:
1. `kubectl -n forgejo get deploy,pvc` and `ssh rpi docker ps` — record before.
1. `kubectl -n forgejo-runners get deploy,pvc` and `ssh rpi docker ps` — record before.
2. Confirm `onionwire`'s in-flight work: no `running` run on the `docker` label
(`action_task`), or accept that the cutover kills it (see §14).
3. Publish the Pi registry on `10.10.0.1:5000` and prove
@ -711,7 +717,7 @@ Pre-flight — every one is read-only and proves the next step:
Cutover — shared runner first (it owns `docker`):
6. `kubectl -n forgejo scale deploy/forgejo-runner-arm64 --replicas=0`, then
6. `kubectl -n forgejo-runners scale deploy/forgejo-runner-arm64 --replicas=0`, then
`ssh rpi docker ps --filter name=GITEA-ACTIONS` and `docker kill`/`rm` any
job containers **still running on the host daemon** (a Deployment restart does
not stop them; they keep writing to the volumes we are about to abandon).
@ -738,10 +744,10 @@ Cutover — shared runner first (it owns `docker`):
landed in the Pi registry (`curl -s http://10.10.0.1:5000/v2/_catalog`) and
the Garage sync succeeded.
12. Prove the existing prune discovers the new pod before trusting the night:
`kubectl -n forgejo create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)`
`kubectl -n forgejo-runners create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)`
and check its `dind-daemons` container log lists both new pods (label +
container-name contract, §1.6) and reports `docker system df` per daemon.
13. `df -h /` on rpi before/after, `kubectl -n forgejo get pvc` (both Bound),
13. `df -h /` on rpi before/after, `kubectl -n forgejo-runners get pvc` (both Bound),
`kubectl get deploy -n forgejo -o wide`.
## 11. Rollback
@ -760,9 +766,9 @@ Kept in place for this purpose, and none of it is deleted by the cutover:
Rollback, ~5 minutes:
```
kubectl -n forgejo apply -f <git show HEAD~1:apps/base/forgejo/runner-arm64.yaml>
kubectl -n forgejo apply -f <git show HEAD~1:apps/base/forgejo/runner-deploy-arm64.yaml>
kubectl -n forgejo scale deploy/forgejo-runner-arm64 --replicas=1
kubectl -n forgejo-runners apply -f <git show HEAD~1:apps/base/forgejo/runner-arm64.yaml>
kubectl -n forgejo-runners apply -f <git show HEAD~1:apps/base/forgejo/runner-deploy-arm64.yaml>
kubectl -n forgejo-runners scale deploy/forgejo-runner-arm64 --replicas=1
```
(down the dind deployment first, kill any job container inside dind, then apply.)
@ -926,7 +932,7 @@ The `dind` container is named exactly `dind` (§1.6 naming contract).
an in-pod daemon the socket is still `unix:///var/run/docker.sock` (in
`DOCKER_HOST`, the shim, and `container.options`), so the string appears 5×
per Deployment. The meaningful test is **no hostPath at all**:
`kubectl -n forgejo get deploy <n> -o yaml | grep -c hostPath` = 0 for both,
`kubectl -n forgejo-runners get deploy <n> -o yaml | grep -c hostPath` = 0 for both,
and every `docker.sock` reference resolves to the `emptyDir` shared by the
`dind` and `runner` containers.
@ -956,7 +962,7 @@ The `dind` container is named exactly `dind` (§1.6 naming contract).
PVCs bound on rpi, static, `Retain`:
```
$ kubectl -n forgejo get pvc -o wide | grep dind
$ kubectl -n forgejo-runners get pvc -o wide | grep dind
forgejo-runner-arm64-dind Bound forgejo-runner-arm64-dind 200Gi RWO local-static
forgejo-runner-deploy-arm64-dind Bound forgejo-runner-deploy-arm64-dind 40Gi RWO local-static
$ kubectl get pv forgejo-runner-arm64-dind forgejo-runner-deploy-arm64-dind
@ -969,10 +975,10 @@ Pods on rpi, two containers each, daemon `27.5.1` (the dind image — the Pi hos
daemon is `29.7.2`, so a job can never be talking to it):
```
$ kubectl -n forgejo get deploy -o wide
$ kubectl -n forgejo-runners get deploy -o wide
forgejo-runner-arm64 1/1 dind,runner docker:27-dind,code.forgejo.org/forgejo/runner:5.0.1
forgejo-runner-deploy-arm64 1/1 dind,runner docker:27-dind,code.forgejo.org/forgejo/runner:5.0.1
$ kubectl -n forgejo exec <arm64-pod> -c dind -- docker version --format 'server={{.Server.Version}}'
$ kubectl -n forgejo-runners exec <arm64-pod> -c dind -- docker version --format 'server={{.Server.Version}}'
server=27.5.1
```
@ -1001,8 +1007,8 @@ task 1737 in 1782 s (warm); deploy runner: task 1736 (`deploy-site.yml`) green i
Nightly prune reaches both new daemons (R10 proof, forced Job):
```
$ kubectl -n forgejo create job --from=cronjob/forgejo-runner-prune prune-manual-1793084490
$ kubectl -n forgejo logs job/prune-manual-1793084490 -c dind-daemons | grep -E "daemon: dind in pod/|summary:"
$ kubectl -n forgejo-runners create job --from=cronjob/forgejo-runner-prune prune-manual-1793084490
$ kubectl -n forgejo-runners logs job/prune-manual-1793084490 -c dind-daemons | grep -E "daemon: dind in pod/|summary:"
== daemon: dind in pod/forgejo-runner-amd64-f7bb99fb-mbv5f
== daemon: dind in pod/forgejo-runner-arm64-7c84998bb8-mmwqd
== daemon: dind in pod/forgejo-runner-deploy-arm64-5dcbd9f7fc-6nj2g
@ -1016,7 +1022,7 @@ $ ssh rpi 'ss -lntH "sport = :5000"'
LISTEN 0 4096 10.10.0.1:5000 0.0.0.0:*
LISTEN 0 4096 127.0.0.1:5000 0.0.0.0:*
$ ssh rpi 'curl -m5 -o /dev/null -w "%{http_code}" http://192.168.1.125:5000/v2/' → 000 (refused)
$ kubectl -n forgejo exec <arm64-pod> -c dind -- wget -qO- http://10.10.0.1:5000/v2/
$ kubectl -n forgejo-runners exec <arm64-pod> -c dind -- wget -qO- http://10.10.0.1:5000/v2/
{} # from the job daemon itself
```
@ -1060,8 +1066,8 @@ regrown inside dind — they rebuild cold by design, §4.2).
```
# 1. stop the dind pods (a job container lives inside them, so it dies with them)
kubectl -n forgejo scale deploy/forgejo-runner-arm64 --replicas=0
kubectl -n forgejo scale deploy/forgejo-runner-deploy-arm64 --replicas=0
kubectl -n forgejo-runners scale deploy/forgejo-runner-arm64 --replicas=0
kubectl -n forgejo-runners scale deploy/forgejo-runner-deploy-arm64 --replicas=0
# 2. Flux owns these files: suspend the apps Kustomization, or the next
# reconcile puts the dind manifests straight back
flux -n flux-system suspend kustomization apps

View file

@ -355,9 +355,9 @@ Producer: the **CNPG-I Barman Cloud plugin** (`cnpg-system/barman-cloud`,
| 4 | flux-system | `notification-controller-7cd6d4994b-drh8x` | siriussec | 10.244.0.125 | Flux alerts/webhooks | internal |
| 5 | flux-system | `source-controller-56549698b5-2lvmc` | siriussec | 10.244.0.44 | Flux git artifact fetcher | internal |
| 6 | forgejo | `forgejo-67847d596c-jpb7x` | siriussec | 10.244.0.197 | Forgejo **16.0.5** git/CI/registry UI | **public** `forgejo.siriusdevops.com` |
| 7 | forgejo | `forgejo-runner-amd64-65fdfdf884-bb88l` | siriussec | 10.244.0.17 | Actions runner (dind sidecar), labels `docker-amd64`, `amd64` | internal |
| 8 | forgejo | `forgejo-runner-arm64-7566647d9f-7q2wk` | rpi | 10.244.1.128 | Actions runner via Pi host Docker socket, labels `docker-arm64`, `arm64`, `docker` | internal |
| 9 | forgejo | `forgejo-runner-deploy-arm64-b748d7c6f-66r5j` | rpi | 10.244.1.167 | Actions runner, label **`deploy-arm64` only** (site deploys) | internal |
| 7 | forgejo-runners | `forgejo-runner-amd64-…` | siriussec | 10.244.0.x | Actions runner (privileged dind sidecar), labels `docker-amd64`, `amd64` | internal |
| 8 | forgejo-runners | `forgejo-runner-arm64-…` | rpi | 10.244.1.x | Actions runner (privileged dind sidecar), labels `docker-arm64`, `arm64`, `docker` | internal |
| 9 | forgejo-runners | `forgejo-runner-deploy-arm64-…` | rpi | 10.244.1.x | Actions runner (privileged dind sidecar), label **`deploy-arm64` only** (site deploys) | internal |
| 10 | forgejo | `pg-1` | siriussec | 10.244.0.159 | CNPG PostgreSQL for Forgejo (1 instance) | internal |
| 11 | kube-system | `cilium-cz7w6` | siriussec | 10.10.0.2 (host-net) | Cilium agent v1.20.1 | internal |
| 12 | kube-system | `cilium-dswfb` | rpi | 10.10.0.1 (host-net) | Cilium agent v1.20.1 | internal |
@ -412,9 +412,9 @@ Nothing runs on `linode` except its Cilium agent. `rpi` runs only the two runner
| Deployment | Node | Docker access | `runs-on` labels | Config |
|---|---|---|---|---|
| `forgejo-runner-arm64` | rpi | Pi **host** socket `/var/run/docker.sock` + host `docker-static` binary + cli-plugins | `docker-arm64`, `arm64`, **`docker`** | CM `forgejo-runner-config` key `arm64.toml`; `capacity 1`; root + privileged; pod `supplementalGroups: [984]`; **no `docker_host`** (would duplicate the socket mount) |
| `forgejo-runner-arm64` | rpi | privileged `docker:27-dind` sidecar, PVC `forgejo-runner-arm64-dind` (200 Gi static PV) | `docker-arm64`, `arm64`, **`docker`** | CM `forgejo-runner-config` key `arm64.toml`; `capacity 1`; runner uid 1000; no host socket |
| `forgejo-runner-amd64` | siriussec | privileged `docker:27-dind` sidecar, PVC `forgejo-runner-amd64` (20 Gi) | `docker-amd64`, `amd64` | key `amd64.toml`; `capacity 1`; `docker_host: unix:///var/run/docker.sock` |
| `forgejo-runner-deploy-arm64` | rpi | Pi host socket, same bind mounts | **`deploy-arm64` only** | key `deploy-arm64.toml`; `capacity 1`; `timeout 30m`; state on hostPath `/opt/siriusdevops/runner-deploy/data` |
| `forgejo-runner-deploy-arm64` | rpi | privileged `docker:27-dind` sidecar, PVC `forgejo-runner-deploy-arm64-dind` (40 Gi static PV) | **`deploy-arm64` only** | key `deploy-arm64.toml`; `capacity 1`; `timeout 30m`; state (runner.ini) on the PVC |
Label discipline that must not be broken:
@ -424,11 +424,11 @@ Label discipline that must not be broken:
Workflow labels actually present in the local checkouts *(live grep of `.forgejo/workflows`)*: `docker` (×8) and `docker-amd64` (×3) in `onionwire`; `deploy-arm64`, `docker-amd64` in `sirius-growth`; `docker-amd64` in `siriusdevops-contact`.
### 6.5 Nightly disk reclamation (`forgejo/forgejo-runner-prune`)
### 6.5 Nightly disk reclamation (`forgejo-runners/forgejo-runner-prune`)
`apps/base/forgejo/prune-cronjob.yaml`, `17 4 * * *` **UTC** (the repo's one CronJob timezone convention), `concurrencyPolicy: Forbid`, `startingDeadlineSeconds: 1800`, `backoffLimit: 1`, `activeDeadlineSeconds: 3600`.
**Two containers, because there are two kinds of daemon.** `host-daemon` (`docker:27-cli`) mounts the Pi's `/var/run/docker.sock`; `dind-daemons` (`alpine/k8s:1.36.4`) discovers in-cluster dind daemons — pods with label `app=forgejo-runner` **that have a container named `dind`** — and runs the same prune logic inside each over the exec API. The ServiceAccount `forgejo-prune` has only `pods get,list` and `pods/exec create` in namespace `forgejo`. No pod names are in the manifest, so the two arm64 dind daemons from the arm64 migration are picked up the first night they exist (proved by creating an unrelated `app=forgejo-runner` dind pod: the job reported `found=2 pruned=2`).
**Two containers, because there are two kinds of daemon.** `host-daemon` (`docker:27-cli`) mounts the Pi's `/var/run/docker.sock`; `dind-daemons` (`alpine/k8s:1.36.4`) discovers in-cluster dind daemons — pods with label `app=forgejo-runner` **that have a container named `dind`** — and runs the same prune logic inside each over the exec API. The ServiceAccount `forgejo-prune` has only `pods get,list` and `pods/exec create` in namespace `forgejo-runners`. No pod names are in the manifest, so the two arm64 dind daemons from the arm64 migration are picked up the first night they exist (proved by creating an unrelated `app=forgejo-runner` dind pod: the job reported `found=2 pruned=2`).
**Retention.** Exited containers > 48 h, unused **Pi-host** images > 168 h (a week of rollback for the sites). Build cache is capped at **20 GB** on the Pi host and **4 GB** per dind daemon; above the cap the script walks `--filter until=` down from 72 h to 0 s and stops as soon as the cache is under the cap, so the newest layers survive and a cold cache is the last resort. In-cluster images are **dangling-only** pruned: an `until` filter on a *pulled* image compares the upstream build date, so it would delete `node:20-bullseye` / `rust:*-bookworm` every night and make every job cold.
@ -439,9 +439,9 @@ Workflow labels actually present in the local checkouts *(live grep of `.forgejo
Force a run (safe any time; it self-skips when busy):
```bash
kubectl -n forgejo create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)
kubectl -n forgejo logs job/prune-manual-<ts> -c host-daemon # Pi daemon
kubectl -n forgejo logs job/prune-manual-<ts> -c dind-daemons # every dind daemon
kubectl -n forgejo-runners create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)
kubectl -n forgejo-runners logs job/prune-manual-<ts> -c host-daemon # Pi daemon
kubectl -n forgejo-runners logs job/prune-manual-<ts> -c dind-daemons # every dind daemon
```
**Two premises worth writing down, because the code depends on them** (both verified 2026-10-27):
@ -931,8 +931,8 @@ All times 2026-10-26 UTC. `kubeconfig` on the Legion admin laptop → `https://1
| 9 | `kubectl -n kube-system get ds,deploy` / image tags | cilium `v1.20.1`, envoy `v1.37.5` |
| 10 | `kubectl -n kube-system exec ds/cilium -- cilium-dbg status --brief` | `OK` |
| 11 | `kubectl top nodes` | `error: Metrics API not available` → no metrics-server |
| 12 | `kubectl -n forgejo get deploy -o json` | 3 runner Deployments + nodeSelectors; pod/container securityContext as documented |
| 13 | `kubectl -n forgejo get cm forgejo-runner-config -o jsonpath` | three TOMLs: `amd64.toml`, `arm64.toml`, `deploy-arm64.toml`, all `capacity: 1` |
| 12 | `kubectl -n forgejo-runners get deploy -o json` | 3 runner Deployments + nodeSelectors; pod/container securityContext as documented |
| 13 | `kubectl -n forgejo-runners get cm forgejo-runner-config -o jsonpath` | three TOMLs: `amd64.toml`, `arm64.toml`, `deploy-arm64.toml`, all `capacity: 1` |
| 14 | `kubectl -n forgejo exec deploy/forgejo -- forgejo --version` | `16.0.5` |
| 15 | rpi: `sudo wg show` | `wg0` 3 peers (handshakes 1 min / 48 min / 6 d); `wg-remote` 1 peer, 35 s |
| 16 | rpi: `sudo wg show wg0 dump \| wc -l` | `4` |

View file

@ -203,7 +203,7 @@ deploying another exporter.
- **CNPG custom-query metrics carry `namespace`/`pod` from the scrape, not the
exporter's `cluster` label.** `cnpg_collector_*` has `cluster`; the
`cnpg_actions_*` and `cnpg_pg_stat_*` families do not. Filter those by
`namespace="forgejo"`.
`namespace="forgejo-runners"` (the `cnpg_actions_*` panels keep `namespace="forgejo"`: that label is the Postgres cluster's namespace).
## Known unknowns (deliberate, documented on the boards themselves)

View file

@ -1,22 +1,25 @@
# Pod Security posture (2026-11-27)
Status of Pod Security Admission (PSA) labels per namespace, why some namespaces
enforce and others only warn/audit, and the one workload that cannot be
de-privileged on these nodes.
Status of Pod Security Admission (PSA) labels per namespace, why one workload
still needs `privileged`, and what is enforced where. Two namespaces now
*enforce*, not just warn: `forgejo` at `baseline` and the CI capsule
`forgejo-runners` at `privileged`.
## Levels in use
| level | namespaces |
|---|---|
| `enforce: baseline` + `warn`/`audit: restricted` | `customer1`, `metabase`, `osint`, `piedmont`, `secops`, `sirius-growth`, `siriusdevops`, `cert-manager` |
| `warn`/`audit: restricted` only | `forgejo`, `netsec`, `monitoring`, `node-io`, `internal`, `gateway-system`, `local-path-storage`, plus cluster-owned `kube-system`, `kube-public`, `kube-node-lease`, `default`, `cnpg-system`, `cilium-secrets`, `logging`, `flux-system` |
| `enforce: baseline` + `warn`/`audit: restricted` | `cert-manager`, `customer1`, `forgejo`, `metabase`, `osint`, `piedmont`, `secops`, `sirius-growth`, `siriusdevops` |
| `enforce: privileged` + `warn`/`audit: restricted` | `forgejo-runners` (the Actions CI capsule), `logging` |
| `warn`/`audit: restricted` only | `netsec`, `monitoring`, `node-io`, `internal`, `gateway-system`, `local-path-storage`, plus cluster-owned `kube-system`, `kube-public`, `kube-node-lease`, `default`, `cnpg-system`, `cilium-secrets`, `flux-system` |
The enforced set was picked by reading the live pods first: every namespace in
it had zero baseline violations (no `privileged`, no `hostNetwork`/`hostPID`/
`hostIPC`, no `hostPath`, no `hostPort`, no capability additions, no
`seccompProfile: Unconfined`) on 2026-11-27. Enforcement is per *pod creation*,
so a namespace that later needs one of those shapes has to be moved to
warn/audit deliberately, with a comment, instead of being allowed by accident.
The enforced set was picked by reading the live workload templates first: every
namespace in it had zero baseline violations (no `privileged`, no
`hostNetwork`/`hostPID`/`hostIPC`, no `hostPath`, no `hostPort`, no capability
additions, no `seccompProfile: Unconfined`) on 2026-11-27. Enforcement is per
*pod creation*, so a namespace that later needs one of those shapes has to be
moved to warn/audit deliberately, with a comment in Git, instead of being
allowed by accident.
The warn/audit-only set is the opposite list — each one hosts a workload that
baseline forbids today:
@ -25,12 +28,11 @@ baseline forbids today:
|---|---|
| `kube-system` | Cilium agent/envoy (hostNetwork, hostPath, privileged init, hostPorts), static control-plane pods |
| `monitoring` | node-exporter (hostNetwork + hostPID + hostPath `/proc`,`/sys`,`/`) |
| `logging` | Alloy DaemonSet (hostPath `/var/log`, journal, machine-id) |
| `logging` | Alloy DaemonSet (hostPath `/var/log`, journal, machine-id) — enforced at `privileged` because the shape is expected |
| `netsec` | hubble-flow-collector (hostPath socket + log dir) |
| `node-io` | etcd-io-guard (privileged, hostPID, hostPath) |
| `local-path-storage` | provisioner helper pods are privileged (created on every PVC) |
| `internal`, `gateway-system` | reserved for hostNetwork Cilium Gateway listeners |
| `forgejo` | Actions runner dind sidecars, see below |
`kube-system`, `kube-public`, `kube-node-lease`, `default`, `cnpg-system`,
`cilium-secrets`, `logging` and `flux-system` are not declared in this repo
@ -47,13 +49,61 @@ for ns in kube-system kube-public kube-node-lease default cnpg-system cilium-sec
done
```
## Why the Forgejo CI runners are still `privileged`
## The Forgejo CI capsule (`forgejo-runners`)
The three runner Deployments (`forgejo-runner-amd64`, `forgejo-runner-arm64`,
`forgejo-runner-deploy-arm64`) keep a docker-in-docker sidecar with
`privileged: true`. That is the reason `forgejo` is not in the enforced set:
baseline rejects those pods at admission, so enforcing it would break Actions
rather than harden it.
The three Actions runners (`forgejo-runner-amd64`, `forgejo-runner-arm64`,
`forgejo-runner-deploy-arm64`) each carry a docker-in-docker sidecar with
`privileged: true`, and the nightly prune CronJob mounts the Pi's host
`/var/run/docker.sock`. PSA has no per-workload exception, and baseline rejects
both shapes (`privileged`, `hostPath`) at admission. While those pods lived in
`forgejo`, that namespace could only ever be warn/audit — which is why
originally *nothing* in the cluster enforced.
The fix is the first option that was open: the **CI capsule moved to its own
namespace**, `apps/base/forgejo/runner-namespace.yaml`, which enforces PSA at
`privileged` *on purpose*, and `forgejo` now enforces `baseline`. This is
containment, not a new grant: the dind sidecar was already privileged. What the
split buys:
* `forgejo` (Forgejo itself, the CNPG Postgres cluster, the nightly
cluster-backup CronJob) is now protected by admission — a future privileged,
hostPath or hostNetwork pod added there is rejected instead of silently
accepted;
* the only namespace allowed to run a privileged pod is the one whose name says
so, labelled as such in Git, and it holds nothing but the CI capsule;
* the capsule keeps `warn`/`audit: restricted`, so every privileged/hostPath
pod there is still printed and recorded as an audit annotation.
What is inside `forgejo-runners`: the three runner Deployments, their PVCs
(`forgejo-runner-amd64` on siriussec's local-path, `forgejo-runner-arm64-dind`
200 Gi and `forgejo-runner-deploy-arm64-dind` 40 Gi as static Retain PVs on
rpi), the `forgejo-runner-config` ConfigMap, the two registration-token
Secrets, and the prune ServiceAccount/Role/RoleBinding/ConfigMap/CronJob. The
capsule's Deployments use the namespace's `default` ServiceAccount, which has
**no** RBAC; only the prune Job can `get/list` pods and `create pods/exec`, and
only in this namespace.
What was already removed from the runner shape (same change, card
`t_2bbe34a8`):
* the runner container no longer runs as uid 0 — it uses the image's uid 1000,
and the dind socket is created `0660 root:1000` via `dockerd --group 1000`
(which also removes the old one-shot `chmod 666` race that forced root);
* CI **job** containers are no longer privileged (`container.privileged: false`
in the runner ConfigMap) — previously every job container was privileged
inside a privileged dind;
* the runners have no `hostPath`, no `hostNetwork` and no host docker socket;
the only hostPath left in the capsule is the prune Job's Pi socket.
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.
## Why the dind sidecar keeps `privileged` (measured, do not re-derive)
Three independent attempts to drop the flag were measured live on 2026-11-27
(siriussec, kernel 6.18.50-lts; rpi reproduced the procfs failure):
@ -77,20 +127,19 @@ Three independent attempts to drop the flag were measured live on 2026-11-27
/dev/net/tun` is refused, so rootless dind has neither a uid map nor the
tun device it needs for networking.
What *was* removed in the same change:
## Verification
* the runner container no longer runs as uid 0 — it uses the image's uid 1000,
and the dind socket is created `0660 root:1000` via `dockerd --group 1000`
(which also removes the old one-shot `chmod 666` race that forced root);
* CI **job** containers are no longer privileged (`container.privileged: false`
in the runner ConfigMap) — previously every job container was privileged
inside a privileged dind;
* there is still no `hostPath`, no `hostNetwork` and no host docker socket in
any runner pod.
```sh
# no privileged container left in the Forgejo namespace (empty output = pass)
kubectl -n forgejo get pods -o jsonpath='{..securityContext.privileged}'
Remaining options for dropping `privileged` (each needs a design decision, not
a manifest edit): move the runner Deployments into their own
`pod-security.kubernetes.io/enforce: privileged` namespace so `forgejo` can
enforce baseline; exempt the runner ServiceAccount from PSA via the API server
`AdmissionConfiguration`; or introduce a runtime that virtualises the container
runtime (sysbox / gVisor) and a matching `RuntimeClass`.
# forgejo enforces baseline; the capsule is explicitly privileged + audited
kubectl get ns forgejo forgejo-runners -o jsonpath='{range .items[*]}{.metadata.name}{" "}{.metadata.labels}{"\n"}{end}'
# admission really rejects the shape in forgejo (expect Forbidden)
kubectl -n forgejo run probe-bad --image=busybox --restart=Never \
--overrides='{"spec":{"containers":[{"name":"p","image":"busybox","securityContext":{"privileged":true}}]}}'
# the prune CronJob (and its RBAC) now live in the capsule
kubectl -n forgejo-runners get cronjob,role,rolebinding,sa -l app=forgejo-runner
```