homek8s/apps/base/forgejo/ci-runners-namespace.yaml

35 lines
1.8 KiB
YAML
Raw Normal View History

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
apiVersion: v1
kind: Namespace
metadata:
name: ci-runners
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
# 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 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.
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
labels:
pod-security.kubernetes.io/enforce: privileged
pod-security.kubernetes.io/enforce-version: latest
pod-security.kubernetes.io/warn: privileged
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
pod-security.kubernetes.io/warn-version: latest
pod-security.kubernetes.io/audit: privileged
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
pod-security.kubernetes.io/audit-version: latest