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

Merged
sirius merged 1 commit from wt/t_2bbe34a8 into master 2026-11-27 06:15:45 +00:00
18 changed files with 239 additions and 127 deletions
Showing only changes of commit 3d21e96a9c - Show all commits

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).
Lancelot 2026-11-27 01:15:07 -05:00

View file

@ -1,7 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# Two namespaces: `forgejo` (enforce: baseline) and `forgejo-runners`
# (enforce: privileged — the CI capsule). Namespace objects sort first.
- namespace.yaml
- runner-namespace.yaml
- httproute.yaml
- pvc.yaml
- cluster.yaml
@ -12,6 +15,12 @@ resources:
- deployment.yaml
- service.yaml
- runner-configmap.yaml
# The runner PVCs/Deployments below and the prune CronJob — plus the two
# runner-token Secrets near the bottom — live in namespace `forgejo-runners`,
# not `forgejo`: the dind sidecars need `privileged` and the prune Job needs a
# hostPath socket, both of which `forgejo` now rejects at admission
# (enforce: baseline).
#
# Static PVs/PVCs pinned to rpi: dynamic local-path cannot provision there
# (its helper pod is hardcoded to siriussec). Must sort before the runner
# Deployments that consume the claims.

View file

@ -2,21 +2,28 @@ apiVersion: v1
kind: Namespace
metadata:
name: forgejo
# Pod Security: warn/audit only. `enforce: baseline` is deliberately NOT set
# yet: the three Actions runner Deployments in this namespace carry a
# docker-in-docker sidecar that cannot lose `privileged: true` on these nodes
# (see the long note in runner-amd64.yaml — procfs needs CAP_SYS_ADMIN,
# kubelet mounts /sys/fs/cgroup read-only for non-privileged pods, and
# rootless dind is blocked by the masked /proc and the absent /dev/net/tun).
# Baseline would reject those pods at admission, i.e. take CI down rather
# than harden it. The remaining fix (move the CI capsule to its own
# explicitly-privileged namespace, or exempt the runner ServiceAccount) is
# tracked on card t_2bbe34a8.
# Pod Security: `enforce: baseline` here. Everything that lives in this
# namespace — Forgejo itself, the CNPG Postgres cluster, the nightly
# cluster-backup CronJob — is baseline-clean (no privileged, no hostPath,
# no host namespaces, no added capabilities), so the enforcement is real
# rather than decorative.
#
# warn/audit at `restricted` means every future pod creation here prints its
# violations and records them as audit annotations, so the next privileged,
# hostPath or hostNetwork pod is visible even without enforcement.
# The Actions runners are NOT here any more. A docker-in-docker sidecar
# cannot lose `privileged: true` on these nodes (procfs needs CAP_SYS_ADMIN,
# kubelet mounts /sys/fs/cgroup read-only for non-privileged pods, rootless
# dind is blocked by the masked /proc and the absent /dev/net/tun — all
# measured, see docs/pod-security.md), so the three runner Deployments, their
# PVCs and the prune CronJob live in `forgejo-runners`, which enforces PSA at
# `privileged` on purpose. Moving them out is what lets this namespace
# enforce baseline: if a runner (or anything else privileged/hostPath) is
# ever added here, admission rejects it instead of silently accepting it.
#
# warn/audit stay at `restricted`: a future pod that is baseline-clean but
# not restricted-clean (e.g. missing seccomp/runAsNonRoot) is still printed
# and recorded as audit annotations.
labels:
pod-security.kubernetes.io/enforce: baseline
pod-security.kubernetes.io/enforce-version: latest
pod-security.kubernetes.io/warn: restricted
pod-security.kubernetes.io/warn-version: latest
pod-security.kubernetes.io/audit: restricted

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

View file

@ -2,7 +2,7 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: forgejo-runner-amd64
namespace: forgejo
namespace: forgejo-runners
spec:
accessModes:
- ReadWriteOnce
@ -15,7 +15,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: forgejo-runner-amd64
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
arch: amd64
@ -170,6 +170,12 @@ spec:
# What this file *does* remove: the runner's uid 0, the privileged
# flag on CI job containers (runner configmap), and the old
# chmod-666 socket race.
#
# Consequence: this Deployment cannot live in namespace
# `forgejo` (PSA enforce: baseline there). All three runners,
# their PVCs and the prune CronJob live in `forgejo-runners`,
# which enforces PSA at `privileged` by design — keep that
# namespace free of anything but this CI capsule.
privileged: true
volumeMounts:
- name: dind-run

View file

@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: forgejo-runner-arm64
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
arch: arm64
@ -136,6 +136,8 @@ spec:
# is forbidden by Pod Security baseline).
# What *is* removed: privileged job containers (runner configmap),
# the runner's uid 0, and the host docker socket (no hostPath).
# This pod lives in namespace forgejo-runners (enforce:
# privileged), not forgejo (enforce: baseline) — see runner-amd64.yaml.
privileged: true
volumeMounts:
- name: dind-run

View file

@ -2,7 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: forgejo-runner-config
namespace: forgejo
namespace: forgejo-runners
data:
arm64.toml: |
log:

View file

@ -19,7 +19,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: forgejo-runner-deploy-arm64
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
arch: arm64
@ -148,6 +148,8 @@ spec:
# runner-amd64.yaml (procfs without CAP_SYS_ADMIN, /sys/fs/cgroup
# mounted read-only by kubelet, rootless dind blocked by masked
# /proc + missing /dev/net/tun). Verified live 2026-11-27.
# Lives in namespace forgejo-runners (enforce: privileged),
# not forgejo (enforce: baseline) — see runner-amd64.yaml.
privileged: true
volumeMounts:
- name: dind-run

View file

@ -64,7 +64,7 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: forgejo-runner-arm64-dind
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
arch: arm64
@ -108,7 +108,7 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: forgejo-runner-deploy-arm64-dind
namespace: forgejo
namespace: forgejo-runners
labels:
app: forgejo-runner
role: deploy

View file

@ -0,0 +1,31 @@
apiVersion: v1
kind: Namespace
metadata:
name: forgejo-runners
# The Forgejo Actions CI capsule: three runner Deployments (each with a
# privileged docker-in-docker sidecar), their data PVCs, and the nightly
# prune CronJob (hostPath `/var/run/docker.sock`).
#
# `enforce: privileged` is deliberate and is the whole point of this
# namespace existing. Pod Security has no per-workload exception: if these
# pods share `forgejo`, that namespace can only ever be warn/audit, i.e. no
# namespace in the cluster enforces anything. Isolating the capsule here lets
# `forgejo` enforce `baseline` (Forgejo, Postgres, backups) while this
# namespace keeps the one shape that genuinely needs node root and is
# labelled as such in Git.
#
# This is containment, not a grant of new privilege: the dind sidecar was
# already privileged, and CI job containers are unprivileged
# (`container.privileged: false` in the runner ConfigMap). Keep this
# namespace free of anything that is not part of the CI capsule, and give it
# its own NetworkPolicy/RBAC scope rather than widening it.
#
# warn/audit at `restricted` still print and record every violation, so a new
# privileged/hostPath pod here is visible even though it is admitted.
labels:
pod-security.kubernetes.io/enforce: privileged
pod-security.kubernetes.io/enforce-version: latest
pod-security.kubernetes.io/warn: restricted
pod-security.kubernetes.io/warn-version: latest
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/audit-version: latest

View file

@ -4,7 +4,7 @@ data:
kind: Secret
metadata:
name: forgejo-runner-amd64-token
namespace: forgejo
namespace: forgejo-runners
type: Opaque
sops:
age:
@ -18,6 +18,6 @@ sops:
-----END AGE ENCRYPTED FILE-----
recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp
encrypted_regex: ^(data|stringData)$
lastmodified: "2026-11-27T05:16:42Z"
mac: ENC[AES256_GCM,data:ew8vSr7GtItgOJfbvZAPWd/gQrSnMP+FNNx0P2AWBx+miBsj8sWckGqgHwVzgIPTDh9kjX4bz2i78HYR6sfDMTYPIbxTQJH/7bzhmBWDqQcb2MklE6Gn/vF6qiTn1GimPIn5xuxfyEJCIBQKzNDp3oMqvBPqQhwes4KnCgkZF4A=,iv:HzNfofZIpPEijLRqbb4/5OttlksbAWE9DY4L9HUKB+g=,tag:ucrfUYY8dKHOU33yF1WXnA==,type:str]
lastmodified: "2026-11-27T06:12:09Z"
mac: ENC[AES256_GCM,data:F0c0O4Nq6rUEKepp75smiiLz1dbwtvGpHXBkWqZ6NQhwZPyb/nPKcW+uyZZRHPtgt7qsMVe3ETu8p0PNflI6v5D6TesEwOsnhAoff+fjS+CgUUl8wEW4o4mK0uHsYoN7BJ2yog238LGEqkqU4t7yj0xBbBR4gicN3Dhkuhb++Io=,iv:B9Kqk7oPL8Miip6viXU7HJnUBHlf866+E47sC+BsaaA=,tag:r3/z+/4aIlWrdUaO9nt8aQ==,type:str]
version: 3.13.3

View file

@ -4,7 +4,7 @@ data:
kind: Secret
metadata:
name: forgejo-runner-deploy-arm64-token
namespace: forgejo
namespace: forgejo-runners
type: Opaque
sops:
age:
@ -18,6 +18,6 @@ sops:
-----END AGE ENCRYPTED FILE-----
recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp
encrypted_regex: ^(data|stringData)$
lastmodified: "2026-11-27T05:16:42Z"
mac: ENC[AES256_GCM,data:1RxSAz4VP9qtxi9AcBxgXhb/ynWuHTj1Cor/A4igCapedCchKCjCcfjBfJgnwilDmQSvZ27VT8sBVwGnzmI05zrfPrhiV39xXtyyNmoVwjU8XBoNrRZMYN5Sow5/1JWhf0NqdoofJ/JTsVg4hyRiPvRQ9xRG1gldjsbVH4XNy34=,iv:UZg6/yBdf4LamyLPjXPiGQYIE/7aJAzSk9MvWHLHMhs=,tag:Rgt9HjB5RANsDouByPtIQQ==,type:str]
lastmodified: "2026-11-27T06:12:09Z"
mac: ENC[AES256_GCM,data:HcIUcXyxgkJyaQiQVUWdMSYDWWgltavFC5RtKn/+vWJ2Lm8tyXgqLCpmEuFxkYwf+WyQrqmyi++0EzMfBxnsRAE+b7U5PS5VqX+pvq0nD4SAPMSm1B+cXz/zrHAzLBVXHHhOzvK8yJtTXqb9iM89bagXiwFIVNCuvhwzDACtX3k=,iv:m3Lb4CiRz0nEOVLUI6MdtUuPTGx2b8zeFE6Mvkb9EIg=,tag:zOHLyo3Uv1uTMQayMywjOQ==,type:str]
version: 3.13.3

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
```

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