Define and enforce security-context behavior as a clear contract, then implement CI/runtime logic to match it without brittle assumptions.
Apply this in two places:
1) Helm/manifest security-context checks (CI)
runAsUser”), not a magic UID number.Example pattern:
# contract: default render must not set runAsUser
helm template bifrost ./helm-charts/bifrost \
--set image.tag=v1.0.0 \
> /tmp/out.yaml
if grep -Eq '^[[:space:]]+runAsUser:[[:space:]]*' /tmp/out.yaml; then
echo "Fail: runAsUser must not be pinned in default render"
exit 1
fi
2) Startup permissions (runtime)
chown/fix ownership (avoid CAP_CHOWN-dependent correctness).fsGroup constraints).Net effect: fewer admission/runtime surprises and fewer CI “green but wrong” security-context failures.