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:
parent
0fdd918875
commit
3d21e96a9c
18 changed files with 239 additions and 127 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue