fix(shield): add PSA-compatible securityContext to GKE allowlist waiter Job#2626
Open
EdwardArchive wants to merge 1 commit into
Open
Conversation
…ob (sysdiglabs#2623) The wait-for-allowlist Job had no Pod or container securityContext, so the pre-install/pre-upgrade hook was rejected on any cluster enforcing the Kubernetes PodSecurity "restricted" profile or OpenShift restricted-v2 SCC. Because it is a Helm hook, admission failure aborts the entire install/upgrade — and the waiter is only used on GKE Autopilot, which itself enforces a hardened profile. Reproduction on a vanilla k8s 1.34 namespace with `pod-security.kubernetes.io/enforce=restricted`: Error creating: pods "...-allowlist-waiter-xxx" is forbidden: violates PodSecurity "restricted:latest": allowPrivilegeEscalation != false, unrestricted capabilities, runAsNonRoot != true, seccompProfile After this fix the Pod is admitted and the script runs. The Pod only executes `kubectl wait` against an AllowlistSynchronizer CRD, so it does not need root, escalation, capabilities, or a writable rootfs. Defaults are configurable via .Values.gke_autopilot.allowlist_waiter.pod_security_context and .security_context for users who need to relax them on legacy clusters. Refs: sysdiglabs#2623
Contributor
|
Hi @EdwardArchive. Thanks for your PR. After inspecting your changes someone with write access to this repo needs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2623
Summary
The
wait-for-allowlistJob (Helmpre-install,pre-upgradehook added in shield 1.37.x) had no Pod or containersecurityContext, so it was rejected on any cluster enforcing the Kubernetes PodSecurity "restricted" profile or OpenShift restricted-v2 SCC. Because it's a Helm hook, admission failure aborts the whole install/upgrade — and the waiter is only used on GKE Autopilot, which itself enforces a hardened profile.Reproduction (live, vanilla k8s 1.34)
Result:
The Job loops in
FailedCreateforever — in Helm context, the install/upgrade hangs and ultimately fails.After this patch the same manifest is admitted and the Pod runs (it exits non-zero only because the AllowlistSynchronizer CRD is not installed on the test cluster — expected, as the waiter only makes sense on GKE Autopilot).
Changes
templates/host/gke-allowlist-waiter-job.yaml— add Pod-level and container-levelsecurityContext, both sourced from values.values.yaml— newgke_autopilot.allowlist_waiter.pod_security_contextand.security_context. Defaults satisfy the PodSecurityrestrictedprofile and OpenShiftrestricted-v2SCC:runAsNonRoot: true,runAsUser/Group: 65532,seccompProfile.type: RuntimeDefaultallowPrivilegeEscalation: false,readOnlyRootFilesystem: true,capabilities.drop: [ALL]tests/host/gke-allowlist-waiter-job_test.yaml— new test suite with 7 cases (default disabled, enabled rendering, pod context defaults, container context defaults, pod override, container override, hook annotations).README.md— new rows for the two configuration keys.Chart.yaml— bump to 1.37.2.Why these defaults are safe
The container only executes
kubectl waitagainst an AllowlistSynchronizer CRD. It does not need root, privilege escalation, Linux capabilities, or a writable rootfs. Users on permissive clusters can override either context via values if needed.Test plan
helm unittest --strict -f tests/host/gke-allowlist-waiter-job_test.yaml charts/shield→ 7/7 passedhelm unittest --strict -f tests/**/*_test.yaml charts/shield→ 482/482 passedFailedCreateloop, after-fixScheduledand runsChecklist
fix(shield):)tests/with_testsuffix🤖 Generated with Claude Code