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

@ -35,18 +35,18 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: forgejo-prune
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
role: prune
---
# Least privilege: the job needs to find dind pods (get/list) and to run
# docker inside them (pods/exec create) — in namespace forgejo only.
# docker inside them (pods/exec create) — in namespace forgejo-runners only.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: forgejo-prune
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
role: prune
@ -62,7 +62,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: forgejo-prune
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
role: prune
@ -73,13 +73,13 @@ roleRef:
subjects:
- kind: ServiceAccount
name: forgejo-prune
namespace: forgejo
namespace: forgejo-runners
---
apiVersion: v1
kind: ConfigMap
metadata:
name: forgejo-prune-scripts
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
role: prune
@ -166,12 +166,12 @@ data:
dind-daemons.sh: |
#!/bin/sh
# Prune every in-cluster dind daemon, discovered by label.
# Selector: pods with app=forgejo-runner in namespace forgejo that have a
# Selector: pods with app=forgejo-runner in namespace forgejo-runners that have a
# container named `dind`. Nothing here is keyed to a pod name, so a new
# dind runner (e.g. the arm64 migration) is pruned the night it appears.
set -u
NS=${NAMESPACE:-forgejo}
NS=${NAMESPACE:-forgejo-runners}
CAP_BYTES=${CACHE_CAP_BYTES:-4000000000}
CACHE_AGE_H=${CACHE_AGE_H:-72}
CONTAINER_AGE_H=${CONTAINER_AGE_H:-48}
@ -263,7 +263,7 @@ apiVersion: batch/v1
kind: CronJob
metadata:
name: forgejo-runner-prune
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
role: prune
@ -343,7 +343,7 @@ spec:
command: ["/bin/sh", "/scripts/dind-daemons.sh"]
env:
- name: NAMESPACE
value: forgejo
value: forgejo-runners
- name: CACHE_CAP_BYTES
value: "4000000000"
- name: CACHE_AGE_H