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

@ -134,13 +134,13 @@ def ns_variable():
# Only the three runner Deployments' pods. `forgejo-runner-.*` also matches the
# `forgejo-runner-prune-*` CronJob pods, which are Completed and permanently
# "not Ready" — that turned a 0 into a 3 on the not-Ready stat.
RUN = 'namespace="forgejo",pod=~"forgejo-runner-(amd64|arm64|deploy-arm64)-.*"'
RUN = 'namespace="forgejo-runners",pod=~"forgejo-runner-(amd64|arm64|deploy-arm64)-.*"'
SIRIUSSEC_FS = 'instance="10.10.0.2:9100",mountpoint="/"'
RPI_FS = 'instance="10.10.0.1:9100",mountpoint="/"'
runners = [
row("Runners & queue", 0),
stat("Runner pods Ready", [target('sum(kube_deployment_status_replicas_ready{namespace="forgejo",deployment=~"forgejo-runner-.*"}) or vector(0)')],
stat("Runner pods Ready", [target('sum(kube_deployment_status_replicas_ready{namespace="forgejo-runners",deployment=~"forgejo-runner-.*"}) or vector(0)')],
{"h": 5, "w": 4, "x": 0, "y": 1}, desc="replicas_ready summed across the three runner Deployments. Expected 3.",
thresholds=[{"color": "red", "value": None}, {"color": "yellow", "value": 2}, {"color": "green", "value": 3}]),
stat("Runner pods not Ready", [target('sum(kube_pod_status_ready{%s,condition="false"} == 1) or vector(0)' % RUN)],
@ -192,7 +192,7 @@ runners = [
ts("Runner pod network I/O", [target('sum by (pod) (rate(container_network_receive_bytes_total{%s}[5m]))' % RUN, "{{pod}} in"),
target('sum by (pod) (rate(container_network_transmit_bytes_total{%s}[5m]))' % RUN, "{{pod}} out", ref="B")],
{"h": 8, "w": 8, "x": 0, "y": 25}, unit="Bps", desc="Image pulls and artifact traffic through the pod interface."),
stat("dind PVC nominal size", [target('max(kube_persistentvolumeclaim_resource_requests_storage_bytes{namespace="forgejo",persistentvolumeclaim="forgejo-runner-amd64"})')],
stat("dind PVC nominal size", [target('max(kube_persistentvolumeclaim_resource_requests_storage_bytes{namespace="forgejo-runners",persistentvolumeclaim="forgejo-runner-amd64"})')],
{"h": 8, "w": 4, "x": 8, "y": 25}, unit="bytes",
desc="Requested size of the forgejo-runner-amd64 PVC (docker data-root + named CI volumes). This is the ceiling, not the usage — see the note on this row."),
stat("siriussec root fs used", [target('100 * (1 - node_filesystem_avail_bytes{%s} / node_filesystem_size_bytes{%s})' % (SIRIUSSEC_FS, SIRIUSSEC_FS))],

View file

@ -87,7 +87,7 @@ data:
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(kube_deployment_status_replicas_ready{namespace=\"forgejo\",deployment=~\"forgejo-runner-.*\"}) or vector(0)",
"expr": "sum(kube_deployment_status_replicas_ready{namespace=\"forgejo-runners\",deployment=~\"forgejo-runner-.*\"}) or vector(0)",
"refId": "A",
"editorMode": "code",
"range": true,
@ -155,7 +155,7 @@ data:
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(kube_pod_status_ready{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",condition=\"false\"} == 1) or vector(0)",
"expr": "sum(kube_pod_status_ready{namespace=\"forgejo-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",condition=\"false\"} == 1) or vector(0)",
"refId": "A",
"editorMode": "code",
"range": true,
@ -692,7 +692,7 @@ data:
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (pod, container) (increase(kube_pod_container_status_restarts_total{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[24h]))",
"expr": "sum by (pod, container) (increase(kube_pod_container_status_restarts_total{namespace=\"forgejo-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[24h]))",
"refId": "A",
"editorMode": "code",
"range": true,
@ -749,7 +749,7 @@ data:
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (pod) (rate(container_cpu_usage_seconds_total{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",container!=\"\"}[5m]))",
"expr": "sum by (pod) (rate(container_cpu_usage_seconds_total{namespace=\"forgejo-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",container!=\"\"}[5m]))",
"refId": "A",
"editorMode": "code",
"range": true,
@ -806,7 +806,7 @@ data:
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (pod) (container_memory_working_set_bytes{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",container!=\"\"})",
"expr": "sum by (pod) (container_memory_working_set_bytes{namespace=\"forgejo-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",container!=\"\"})",
"refId": "A",
"editorMode": "code",
"range": true,
@ -876,7 +876,7 @@ data:
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (pod) (rate(container_network_receive_bytes_total{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[5m]))",
"expr": "sum by (pod) (rate(container_network_receive_bytes_total{namespace=\"forgejo-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[5m]))",
"refId": "A",
"editorMode": "code",
"range": true,
@ -888,7 +888,7 @@ data:
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (pod) (rate(container_network_transmit_bytes_total{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[5m]))",
"expr": "sum by (pod) (rate(container_network_transmit_bytes_total{namespace=\"forgejo-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[5m]))",
"refId": "B",
"editorMode": "code",
"range": true,
@ -945,7 +945,7 @@ data:
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max(kube_persistentvolumeclaim_resource_requests_storage_bytes{namespace=\"forgejo\",persistentvolumeclaim=\"forgejo-runner-amd64\"})",
"expr": "max(kube_persistentvolumeclaim_resource_requests_storage_bytes{namespace=\"forgejo-runners\",persistentvolumeclaim=\"forgejo-runner-amd64\"})",
"refId": "A",
"editorMode": "code",
"range": true,

View file

@ -1,6 +1,6 @@
# Alerts for the disk-reclamation job and the daemons it prunes.
#
# Context: `forgejo/forgejo-runner-prune` reclaims build cache nightly. Its
# Context: `forgejo-runners/forgejo-runner-prune` reclaims build cache nightly. Its
# own success/failure is invisible unless kube-state-metrics is watched, and
# the failure mode it exists to prevent (a full disk on siriussec → DiskPressure
# → Forgejo + Postgres evicted, public 503) shows up in node_exporter first.
@ -53,10 +53,10 @@ spec:
# never having succeeded at all.
expr: |
(
time() - kube_cronjob_status_last_successful_time{namespace="forgejo", cronjob="forgejo-runner-prune"} > 26 * 3600
time() - kube_cronjob_status_last_successful_time{namespace="forgejo-runners", cronjob="forgejo-runner-prune"} > 26 * 3600
)
or
absent(kube_cronjob_status_last_successful_time{namespace="forgejo", cronjob="forgejo-runner-prune"})
absent(kube_cronjob_status_last_successful_time{namespace="forgejo-runners", cronjob="forgejo-runner-prune"})
for: 10m
labels:
severity: warning
@ -66,10 +66,10 @@ spec:
description: >-
Build cache, exited containers and unused images are not being
reclaimed on the Pi host daemon or on the dind daemons. Check
`kubectl -n forgejo get jobs -l role=prune` and the pod logs of
`kubectl -n forgejo-runners get jobs -l role=prune` and the pod logs of
the newest Job; the job skips (exit 0) when a build is live, but
a *stale* success means it has not run at all. Force one run:
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)
- alert: ForgejoPruneJobFailed
# kube_job_failed was removed from kube-state-metrics; the supported
# series is kube_job_status_failed (0 for a successful job, >0 when a
@ -77,7 +77,7 @@ spec:
# transient failure ages out on its own after the history limit.
expr: |
max by (job_name) (
kube_job_status_failed{namespace="forgejo", job_name=~"forgejo-runner-prune-.*"}
kube_job_status_failed{namespace="forgejo-runners", job_name=~"forgejo-runner-prune-.*"}
) > 0
for: 5m
labels:
@ -86,7 +86,7 @@ spec:
summary: forgejo-runner-prune Job {{ $labels.job_name }} has a failed pod
description: >-
A prune run failed (or its dind discovery/exec container did).
Read `kubectl -n forgejo logs job/{{ $labels.job_name }} -c
Read `kubectl -n forgejo-runners logs job/{{ $labels.job_name }} -c
dind-daemons` — a failure there means a running dind daemon was
not reachable over the exec API, so that daemon is growing
unpruned. One retry is allowed by backoffLimit; persistent
@ -121,7 +121,7 @@ spec:
)
and on (nodename)
label_replace(
max by (node) (kube_pod_info{namespace="forgejo", pod=~"forgejo-runner-.*"}),
max by (node) (kube_pod_info{namespace="forgejo-runners", pod=~"forgejo-runner-.*"}),
"nodename", "$1", "node", "(.+)"
)
) > 0.80
@ -141,9 +141,9 @@ spec:
Prometheus. Per-PVC bytes cannot be measured here — kubelet 1.34+
no longer exports kubelet_volume_stats_* and /metrics/volumes is
404 — so this node-level rule is the guard. Inspect the offenders:
`kubectl -n forgejo exec <runner-pod> -c dind -- docker system df -v`
`kubectl -n forgejo-runners exec <runner-pod> -c dind -- docker system df -v`
and `du -sh /opt/local-path-provisioner/pvc-*` on the node, then let
the nightly prune reclaim (or force it: kubectl -n forgejo create job
the nightly prune reclaim (or force it: kubectl -n forgejo-runners create job
--from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)).
- alert: RunnerDindDiskCritical
expr: |
@ -159,7 +159,7 @@ spec:
)
and on (nodename)
label_replace(
max by (node) (kube_pod_info{namespace="forgejo", pod=~"forgejo-runner-.*"}),
max by (node) (kube_pod_info{namespace="forgejo-runners", pod=~"forgejo-runner-.*"}),
"nodename", "$1", "node", "(.+)"
)
) > 0.90
@ -174,7 +174,7 @@ spec:
DiskPressure is imminent on a node running CI: kubelet starts
evicting (Forgejo + pg-1 went Pending on siriussec this way) and
dind builds fail with "no space left on device". Act now: scale the
runner to 0 (`kubectl -n forgejo scale deploy/<runner> --replicas=0`),
runner to 0 (`kubectl -n forgejo-runners scale deploy/<runner> --replicas=0`),
force the prune, and only then clear the dind data-root by hand
(`/opt/local-path-provisioner/pvc-*_forgejo_forgejo-runner-*/` on
the node) — never wipe it while the runner pod is up. The 20Gi PVC
@ -212,10 +212,10 @@ spec:
200Gi and forgejo-runner-deploy-arm64-dind 40Gi) share rpi's only
filesystem with the kubelet. Nothing enforces those claim sizes.
Attribute the growth with
`kubectl -n forgejo exec <pod> -c dind -- docker system df -v`
`kubectl -n forgejo-runners exec <pod> -c dind -- docker system df -v`
(the nightly prune job prints this for every daemon and never
deletes named volumes), then reclaim with
`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)`.
See docs/arm64-runner-dind.md §4.4.
- name: disk-capacity
rules:
@ -238,7 +238,7 @@ spec:
annotations:
summary: "{{ $labels.nodename }} root filesystem is {{ $value | humanizePercentage }} full"
description: >-
Reclaim with `kubectl -n forgejo create job
Reclaim with `kubectl -n forgejo-runners create job
--from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)` (it
prunes the Pi host daemon and every dind daemon), and read that
job's `docker system df -v` output for the volumes that are