From 4c0bbe2d1265a2bb3067e2a44324e86642cbdc7f Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 27 Nov 2026 00:48:37 -0500 Subject: [PATCH] fix(f6): fix-data-perms must run as root; add PSA labels to logging + cnpg-system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The init container that chowns the runner PVC to 1000:1000 was left with the runner's uid (1000), so `chown` failed and the arm64/amd64 runners could not start. It now runs as root for that one operation; the runner container itself stays uid 1000. Also label `logging` (warn+audit restricted alongside enforce=privileged) and `cnpg-system` (warn+audit) so every namespace reports PSA violations instead of silently allowing them — cnpg-system's labels live in the vendored operator manifest because Flux owns that Namespace object and strips out-of-band labels. --- apps/base/forgejo/runner-amd64.yaml | 19 +++++++------------ apps/base/forgejo/runner-arm64.yaml | 18 +++++++----------- .../databases/base/upstream/cnpg-1.30.0.yaml | 8 ++++++++ infrastructure/logging/namespace.yaml | 6 ++++++ 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/apps/base/forgejo/runner-amd64.yaml b/apps/base/forgejo/runner-amd64.yaml index 9f27a22..d149d87 100644 --- a/apps/base/forgejo/runner-amd64.yaml +++ b/apps/base/forgejo/runner-amd64.yaml @@ -79,11 +79,8 @@ spec: image: docker:27-dind imagePullPolicy: IfNotPresent securityContext: - # The image's own user. No root needed: the dind socket is created - # 0660 root:1000 by `dockerd --group 1000`, and fix-data-perms - # re-owns the PVC as 1000:1000 so the actions cache is writable. - runAsUser: 1000 - runAsGroup: 1000 + # root is needed for exactly one thing: chown of the PVC. + runAsUser: 0 command: - sh - -c @@ -175,14 +172,12 @@ spec: - name: runner image: code.forgejo.org/forgejo/runner:5.0.1 imagePullPolicy: IfNotPresent - # The image runs as uid 1000. The dind socket is created 660 - # root:docker and the one-shot chmod 666 in the dind container can - # race a dockerd restart, after which the runner crashloops on - # "permission denied ... /var/run/docker.sock" (its wait loop only - # checks that the socket exists). Running the runner as root removes - # the dependency on that race; it is the uid the dind setup assumes. securityContext: - runAsUser: 0 + # The image's own user. No root needed: the dind socket is 0660 + # root:1000 (`dockerd --group 1000`) and fix-data-perms owns the PVC + # as 1000:1000, so the actions cache is writable. + runAsUser: 1000 + runAsGroup: 1000 command: - sh - -c diff --git a/apps/base/forgejo/runner-arm64.yaml b/apps/base/forgejo/runner-arm64.yaml index 477ca8d..1449767 100644 --- a/apps/base/forgejo/runner-arm64.yaml +++ b/apps/base/forgejo/runner-arm64.yaml @@ -45,11 +45,8 @@ spec: image: docker:27-dind imagePullPolicy: IfNotPresent securityContext: - # Image default user (uid 1000). No root needed: the dind socket is - # 0660 root:1000 (dockerd --group 1000) and fix-data-perms owns the - # PVC as 1000:1000. - runAsUser: 1000 - runAsGroup: 1000 + # root is needed for exactly one thing: chown of the PVC. + runAsUser: 0 command: - sh - -c @@ -148,13 +145,12 @@ spec: # job in onionwire/siriusdevops-contact. image: code.forgejo.org/forgejo/runner:5.0.1 imagePullPolicy: IfNotPresent - # uid 1000 in this image vs a `660 root:docker` dind socket: the dind - # container's one-shot chmod 666 can race a dockerd restart and the - # runner's wait loop only checks that the socket exists, so it would - # crashloop on "permission denied". Running as root is what the amd64 - # runner proved deterministic (2eff85b). securityContext: - runAsUser: 0 + # The image's own user. No root needed: the dind socket is 0660 + # root:1000 (`dockerd --group 1000`) and fix-data-perms owns the PVC + # as 1000:1000, so the actions cache is writable. + runAsUser: 1000 + runAsGroup: 1000 command: - sh - -c diff --git a/infrastructure/databases/base/upstream/cnpg-1.30.0.yaml b/infrastructure/databases/base/upstream/cnpg-1.30.0.yaml index 4f7364a..5d2dce0 100644 --- a/infrastructure/databases/base/upstream/cnpg-1.30.0.yaml +++ b/infrastructure/databases/base/upstream/cnpg-1.30.0.yaml @@ -3,6 +3,14 @@ kind: Namespace metadata: labels: app.kubernetes.io/name: cloudnative-pg + # Pod Security: warn/audit only. The operator pods are baseline-clean today, + # but this namespace is upstream-managed and we do not want a future + # operator version to be rejected on a cluster upgrade without warning; + # warn/audit makes any such pod visible first. + 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 name: cnpg-system --- apiVersion: apiextensions.k8s.io/v1 diff --git a/infrastructure/logging/namespace.yaml b/infrastructure/logging/namespace.yaml index 5610945..03b83a0 100644 --- a/infrastructure/logging/namespace.yaml +++ b/infrastructure/logging/namespace.yaml @@ -11,3 +11,9 @@ metadata: # run with a read-only root filesystem; the only real privilege is the root # UID needed to read journal files (0640 root:systemd-journal). pod-security.kubernetes.io/enforce: privileged + # enforce=privileged silences PSA entirely; warn/audit at restricted keeps + # the violations visible on every pod creation (and in the audit log). + 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