homek8s/apps/base/forgejo/runner-dind-storage.yaml
Lancelot 3d21e96a9c 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).
2026-11-27 01:15:07 -05:00

122 lines
3.5 KiB
YAML

---
# Static storage for the arm64 runners' in-cluster dind daemons.
#
# Why static PVs and not the default `local-path` StorageClass: the
# provisioner's helper pod is hardcoded to siriussec
# (infrastructure/storage/local-path-storage.yaml, helper-pod nodeSelector) and
# for a local filesystem it never sets spec.nodeName, so a `local-path` PVC
# consumed by a pod on rpi stays Pending forever ("NodeAffinity failed").
# Measured 2026-10-27 in a throwaway namespace; see
# docs/arm64-runner-dind.md §6.1.
#
# `persistentVolumeReclaimPolicy: Retain` is deliberate: the runner's
# registration (`runner.ini`, uuid of the Forgejo action_runner row) lives in
# this directory. Deleting the PVC must never delete the identity — a re-
# registered runner burns a single-use token and leaves an orphaned
# action_runner row behind.
#
# Sizes come from measured steady state (docs/arm64-runner-dind.md §4):
# shared runner 146.5 GiB steady -> 200Gi request (named CI volumes)
# deploy runner ~0.3 GiB steady -> 40Gi request (image + buildx generations)
# 240 GiB of the Pi's 390 GiB free. A static PV does not enforce the request —
# the 70 % node-filesystem alert in monitoring/controllers/home/prune-alerts.yaml
# is the real cap.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-static
# No provisioner: every PV with this class is hand-made, so a typo'd claim
# hangs in Pending instead of silently landing somewhere unexpected.
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Retain
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: forgejo-runner-arm64-dind
labels:
app: forgejo-runner
arch: arm64
spec:
capacity:
storage: 200Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-static
volumeMode: Filesystem
hostPath:
# Same filesystem/tree the local-path provisioner uses, so df and the
# existing node-exporter alerting see it as ordinary node disk.
path: /opt/local-path-provisioner/forgejo-runner-arm64-dind
type: DirectoryOrCreate
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- rpi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: forgejo-runner-arm64-dind
namespace: forgejo-runners
labels:
app: forgejo-runner
arch: arm64
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-static
volumeName: forgejo-runner-arm64-dind
resources:
requests:
storage: 200Gi
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: forgejo-runner-deploy-arm64-dind
labels:
app: forgejo-runner
role: deploy
spec:
capacity:
storage: 40Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-static
volumeMode: Filesystem
hostPath:
path: /opt/local-path-provisioner/forgejo-runner-deploy-arm64-dind
type: DirectoryOrCreate
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- rpi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: forgejo-runner-deploy-arm64-dind
namespace: forgejo-runners
labels:
app: forgejo-runner
role: deploy
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-static
volumeName: forgejo-runner-deploy-arm64-dind
resources:
requests:
storage: 40Gi