Merge pull request 'ci(runners): name the CI capsule ci-runners; privileged warn/audit' (#73) from wt/t_2bbe34a8-rename into master

This commit is contained in:
sirius 2026-11-27 06:21:07 +00:00
commit 2ae67faf98
18 changed files with 104 additions and 98 deletions

View file

@ -1,7 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: forgejo-runners
name: ci-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`).
@ -20,12 +20,16 @@ metadata:
# 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.
# warn/audit are `privileged` too, on purpose: at that level PSA prints and
# records nothing, which is the honest signal — everything here is allowed by
# design, and the namespace holds only the CI capsule. (Warn/audit at
# `restricted` would emit the same five violations for every pod, every
# restart, and train everyone to ignore them.) Anything added here that is not
# part of the capsule is a review failure in Git, not an admission event.
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: privileged
pod-security.kubernetes.io/warn-version: latest
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/audit: privileged
pod-security.kubernetes.io/audit-version: latest

View file

@ -1,10 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# Two namespaces: `forgejo` (enforce: baseline) and `forgejo-runners`
# Two namespaces: `forgejo` (enforce: baseline) and `ci-runners`
# (enforce: privileged — the CI capsule). Namespace objects sort first.
- namespace.yaml
- runner-namespace.yaml
- ci-runners-namespace.yaml
- httproute.yaml
- pvc.yaml
- cluster.yaml
@ -16,7 +16,7 @@ resources:
- 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`,
# runner-token Secrets near the bottom — live in namespace `ci-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).

View file

@ -13,7 +13,7 @@ metadata:
# 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
# PVCs and the prune CronJob live in `ci-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.

View file

@ -35,18 +35,18 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: forgejo-prune
namespace: forgejo-runners
namespace: ci-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-runners only.
# docker inside them (pods/exec create) — in namespace ci-runners only.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: forgejo-prune
namespace: forgejo-runners
namespace: ci-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-runners
namespace: ci-runners
labels:
app: forgejo-runner
role: prune
@ -73,13 +73,13 @@ roleRef:
subjects:
- kind: ServiceAccount
name: forgejo-prune
namespace: forgejo-runners
namespace: ci-runners
---
apiVersion: v1
kind: ConfigMap
metadata:
name: forgejo-prune-scripts
namespace: forgejo-runners
namespace: ci-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-runners that have a
# Selector: pods with app=forgejo-runner in namespace ci-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-runners}
NS=${NAMESPACE:-ci-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-runners
namespace: ci-runners
labels:
app: forgejo-runner
role: prune
@ -343,7 +343,7 @@ spec:
command: ["/bin/sh", "/scripts/dind-daemons.sh"]
env:
- name: NAMESPACE
value: forgejo-runners
value: ci-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-runners
namespace: ci-runners
spec:
accessModes:
- ReadWriteOnce
@ -15,7 +15,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: forgejo-runner-amd64
namespace: forgejo-runners
namespace: ci-runners
labels:
app: forgejo-runner
arch: amd64
@ -173,7 +173,7 @@ spec:
#
# 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`,
# their PVCs and the prune CronJob live in `ci-runners`,
# which enforces PSA at `privileged` by design — keep that
# namespace free of anything but this CI capsule.
privileged: true

View file

@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: forgejo-runner-arm64
namespace: forgejo-runners
namespace: ci-runners
labels:
app: forgejo-runner
arch: arm64
@ -136,7 +136,7 @@ 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:
# This pod lives in namespace ci-runners (enforce:
# privileged), not forgejo (enforce: baseline) — see runner-amd64.yaml.
privileged: true
volumeMounts:

View file

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

View file

@ -19,7 +19,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: forgejo-runner-deploy-arm64
namespace: forgejo-runners
namespace: ci-runners
labels:
app: forgejo-runner
arch: arm64
@ -148,7 +148,7 @@ 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),
# Lives in namespace ci-runners (enforce: privileged),
# not forgejo (enforce: baseline) — see runner-amd64.yaml.
privileged: true
volumeMounts:

View file

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

View file

@ -4,7 +4,7 @@ data:
kind: Secret
metadata:
name: forgejo-runner-amd64-token
namespace: forgejo-runners
namespace: ci-runners
type: Opaque
sops:
age:
@ -18,6 +18,6 @@ sops:
-----END AGE ENCRYPTED FILE-----
recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp
encrypted_regex: ^(data|stringData)$
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]
lastmodified: "2026-11-27T06:18:39Z"
mac: ENC[AES256_GCM,data:+hlch3XHEHTl+PUFjAjIL/cJdGIJBtwlA3gldWYpUVtsKOPJ2Vfi5DUfwodvpTCSjZYTTipR4Kz2BoAhQ9y+vVMGfTKko/1fA5UMjf74uiCXhur0B2vyAcFUn79xrZql/J6q7DmkufHveS7baNd5YRQSLV6Catm70IkIL81o1/Q=,iv:6esPz9ggtY0+5NedEfET0NfX39xw5fwokVNQB3ak24s=,tag:+5WduOvKK35AV65auauM2Q==,type:str]
version: 3.13.3

View file

@ -4,7 +4,7 @@ data:
kind: Secret
metadata:
name: forgejo-runner-deploy-arm64-token
namespace: forgejo-runners
namespace: ci-runners
type: Opaque
sops:
age:
@ -18,6 +18,6 @@ sops:
-----END AGE ENCRYPTED FILE-----
recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp
encrypted_regex: ^(data|stringData)$
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]
lastmodified: "2026-11-27T06:18:39Z"
mac: ENC[AES256_GCM,data:/SrVMnWWPRDMJYCWcGsmyIp3VuBBEw1pzKSHCty/ZUuqlE4IrvAaQpisAF8ByMsOBTc80JfRjaiFYr5nu1L7jlTDbivPHXAc4CgLMX3FGtvqTgrmPCwvjUV2x0kK6pSNgo/AuDmFYCh+UKqyNEToi4uDnqtiXwy91fsfvg60fLw=,iv:S3SOMKy6ZYWdYKC8DZs4mdQhPTMv/bt+d8+UO5cKOLI=,tag:YvHkNscDXMutN5BFekrfow==,type:str]
version: 3.13.3

View file

@ -19,7 +19,7 @@ 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
> `ci-runners` so `forgejo` can enforce Pod Security `baseline`. Commands
> below use the new namespace; the dind design and every measurement are
> unchanged.
---
@ -628,7 +628,7 @@ difference between the two runners).
`docker:27-dind` already contains the client and the plugins:
```
$ kubectl -n forgejo-runners exec deploy/forgejo-runner-amd64 -c dind -- sh -c 'command -v docker; ls /usr/local/libexec/docker/cli-plugins/'
$ kubectl -n ci-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
@ -705,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-runners get deploy,pvc` and `ssh rpi docker ps` — record before.
1. `kubectl -n ci-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
@ -717,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-runners scale deploy/forgejo-runner-arm64 --replicas=0`, then
6. `kubectl -n ci-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).
@ -744,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-runners create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)`
`kubectl -n ci-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-runners get pvc` (both Bound),
13. `df -h /` on rpi before/after, `kubectl -n ci-runners get pvc` (both Bound),
`kubectl get deploy -n forgejo -o wide`.
## 11. Rollback
@ -766,9 +766,9 @@ Kept in place for this purpose, and none of it is deleted by the cutover:
Rollback, ~5 minutes:
```
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
kubectl -n ci-runners apply -f <git show HEAD~1:apps/base/forgejo/runner-arm64.yaml>
kubectl -n ci-runners apply -f <git show HEAD~1:apps/base/forgejo/runner-deploy-arm64.yaml>
kubectl -n ci-runners scale deploy/forgejo-runner-arm64 --replicas=1
```
(down the dind deployment first, kill any job container inside dind, then apply.)
@ -932,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-runners get deploy <n> -o yaml | grep -c hostPath` = 0 for both,
`kubectl -n ci-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.
@ -962,7 +962,7 @@ The `dind` container is named exactly `dind` (§1.6 naming contract).
PVCs bound on rpi, static, `Retain`:
```
$ kubectl -n forgejo-runners get pvc -o wide | grep dind
$ kubectl -n ci-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
@ -975,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-runners get deploy -o wide
$ kubectl -n ci-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-runners exec <arm64-pod> -c dind -- docker version --format 'server={{.Server.Version}}'
$ kubectl -n ci-runners exec <arm64-pod> -c dind -- docker version --format 'server={{.Server.Version}}'
server=27.5.1
```
@ -1007,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-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:"
$ kubectl -n ci-runners create job --from=cronjob/forgejo-runner-prune prune-manual-1793084490
$ kubectl -n ci-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
@ -1022,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-runners exec <arm64-pod> -c dind -- wget -qO- http://10.10.0.1:5000/v2/
$ kubectl -n ci-runners exec <arm64-pod> -c dind -- wget -qO- http://10.10.0.1:5000/v2/
{} # from the job daemon itself
```
@ -1066,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-runners scale deploy/forgejo-runner-arm64 --replicas=0
kubectl -n forgejo-runners scale deploy/forgejo-runner-deploy-arm64 --replicas=0
kubectl -n ci-runners scale deploy/forgejo-runner-arm64 --replicas=0
kubectl -n ci-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-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 |
| 7 | ci-runners | `forgejo-runner-amd64-…` | siriussec | 10.244.0.x | Actions runner (privileged dind sidecar), labels `docker-amd64`, `amd64` | internal |
| 8 | ci-runners | `forgejo-runner-arm64-…` | rpi | 10.244.1.x | Actions runner (privileged dind sidecar), labels `docker-arm64`, `arm64`, `docker` | internal |
| 9 | ci-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 |
@ -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-runners/forgejo-runner-prune`)
### 6.5 Nightly disk reclamation (`ci-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-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`).
**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 `ci-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-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
kubectl -n ci-runners create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)
kubectl -n ci-runners logs job/prune-manual-<ts> -c host-daemon # Pi daemon
kubectl -n ci-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-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` |
| 12 | `kubectl -n ci-runners get deploy -o json` | 3 runner Deployments + nodeSelectors; pod/container securityContext as documented |
| 13 | `kubectl -n ci-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-runners"` (the `cnpg_actions_*` panels keep `namespace="forgejo"`: that label is the Postgres cluster's namespace).
`namespace="ci-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

@ -3,14 +3,15 @@
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`.
`ci-runners` at `privileged`.
## Levels in use
| level | namespaces |
|---|---|
| `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` |
| `enforce: privileged` + `warn`/`audit: privileged` | `ci-runners` (the Actions CI capsule) |
| `enforce: privileged` + `warn`/`audit: restricted` | `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 workload templates first: every
@ -49,7 +50,7 @@ for ns in kube-system kube-public kube-node-lease default cnpg-system cilium-sec
done
```
## The Forgejo CI capsule (`forgejo-runners`)
## The Forgejo CI capsule (`ci-runners`)
The three Actions runners (`forgejo-runner-amd64`, `forgejo-runner-arm64`,
`forgejo-runner-deploy-arm64`) each carry a docker-in-docker sidecar with
@ -71,10 +72,11 @@ split buys:
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.
* the capsule's `warn`/`audit` are `privileged` as well (the operator's decision):
they emit nothing because everything there is allowed by design, and the
namespace is reviewed in Git rather than at admission.
What is inside `forgejo-runners`: the three runner Deployments, their PVCs
What is inside `ci-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
@ -134,12 +136,12 @@ Three independent attempts to drop the flag were measured live on 2026-11-27
kubectl -n forgejo get pods -o jsonpath='{..securityContext.privileged}'
# 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}'
kubectl get ns forgejo ci-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
kubectl -n ci-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-runners",pod=~"forgejo-runner-(amd64|arm64|deploy-arm64)-.*"'
RUN = 'namespace="ci-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-runners",deployment=~"forgejo-runner-.*"}) or vector(0)')],
stat("Runner pods Ready", [target('sum(kube_deployment_status_replicas_ready{namespace="ci-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-runners",persistentvolumeclaim="forgejo-runner-amd64"})')],
stat("dind PVC nominal size", [target('max(kube_persistentvolumeclaim_resource_requests_storage_bytes{namespace="ci-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-runners\",deployment=~\"forgejo-runner-.*\"}) or vector(0)",
"expr": "sum(kube_deployment_status_replicas_ready{namespace=\"ci-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-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",condition=\"false\"} == 1) or vector(0)",
"expr": "sum(kube_pod_status_ready{namespace=\"ci-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-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[24h]))",
"expr": "sum by (pod, container) (increase(kube_pod_container_status_restarts_total{namespace=\"ci-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-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",container!=\"\"}[5m]))",
"expr": "sum by (pod) (rate(container_cpu_usage_seconds_total{namespace=\"ci-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-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",container!=\"\"})",
"expr": "sum by (pod) (container_memory_working_set_bytes{namespace=\"ci-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-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[5m]))",
"expr": "sum by (pod) (rate(container_network_receive_bytes_total{namespace=\"ci-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-runners\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[5m]))",
"expr": "sum by (pod) (rate(container_network_transmit_bytes_total{namespace=\"ci-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-runners\",persistentvolumeclaim=\"forgejo-runner-amd64\"})",
"expr": "max(kube_persistentvolumeclaim_resource_requests_storage_bytes{namespace=\"ci-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-runners/forgejo-runner-prune` reclaims build cache nightly. Its
# Context: `ci-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-runners", cronjob="forgejo-runner-prune"} > 26 * 3600
time() - kube_cronjob_status_last_successful_time{namespace="ci-runners", cronjob="forgejo-runner-prune"} > 26 * 3600
)
or
absent(kube_cronjob_status_last_successful_time{namespace="forgejo-runners", cronjob="forgejo-runner-prune"})
absent(kube_cronjob_status_last_successful_time{namespace="ci-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-runners get jobs -l role=prune` and the pod logs of
`kubectl -n ci-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-runners create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)
kubectl -n ci-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-runners", job_name=~"forgejo-runner-prune-.*"}
kube_job_status_failed{namespace="ci-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-runners logs job/{{ $labels.job_name }} -c
Read `kubectl -n ci-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-runners", pod=~"forgejo-runner-.*"}),
max by (node) (kube_pod_info{namespace="ci-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-runners exec <runner-pod> -c dind -- docker system df -v`
`kubectl -n ci-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-runners create job
the nightly prune reclaim (or force it: kubectl -n ci-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-runners", pod=~"forgejo-runner-.*"}),
max by (node) (kube_pod_info{namespace="ci-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-runners scale deploy/<runner> --replicas=0`),
runner to 0 (`kubectl -n ci-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-runners exec <pod> -c dind -- docker system df -v`
`kubectl -n ci-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-runners create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)`.
`kubectl -n ci-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-runners create job
Reclaim with `kubectl -n ci-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