Add securityContexts.disableDefaults flag for OpenShift SCC compatibility#70238
Add securityContexts.disableDefaults flag for OpenShift SCC compatibility#70238Aaryan123456679 wants to merge 6 commits into
Conversation
7052119 to
9557fef
Compare
Miretpl
left a comment
There was a problem hiding this comment.
I would see it more like adding a flag which would make all of the default options not added. Currently, in most cases (if not in all), if securityContexts.* is empty, in the helper function logic we are adding some values. I think they should not be added there, and if we want to have some default values in the chart for them, they should be in the values.yaml file (version 2.0).
In this PR, I would add a flag for not adding these default values in the helper function when, e.g. securityContexts.pod is {} (default in values.yaml file). This would be, IMHO, much more intuitive for the users; in the end will require less logic to handle and maintain and should be cleaner too.
WDYT?
…exts OpenShift assigns runAsUser/fsGroup automatically via SCC and rejects pods that hard-code them, so users need to null these out in the rendered pod securityContext. The vendored PodSecurityContext schema required these fields to be integers, so setting them to null failed Helm's values.schema.json validation before the templates ever rendered (the templates already pass through explicit nulls correctly). Introduces a new AirflowPodSecurityContext schema definition (not io.k8s.*-prefixed, so it survives vendor_k8s_json_schema.py regeneration) that allows null for runAsUser/runAsGroup/fsGroup, and points all 16 securityContexts.pod $refs at it instead of the vendored definition. closes: apache#41630
Named after the GitHub issue instead of the actual PR number, which the check-newsfragment-pr-number CI check expects.
…isableDefaults flag Explicit null in securityContexts.pod/containers was fragile and made every call site guess whether to render a key at all. A dedicated flag is more explicit about intent and lets the chart omit the default runAsUser/fsGroup (and related) values entirely on platforms like OpenShift where the cluster's SCC assigns them automatically and rejects hard-coded values.
The OpenShift SCC guidance still described the earlier null-based workaround, which no longer omits the rendered securityContext keys.
9557fef to
bc9eaf8
Compare
|
Thanks for the suggestion — that's a cleaner approach. I've reworked the PR accordingly:
Let me know if this matches what you had in mind, or if you'd adjust the flag's scope or naming. |
…ma description securityContexts.pod / securityContexts.containers appeared as plain text in the disableDefaults description, which the docs build renders as prose rather than code, tripping the spellchecker on the camelCase identifier.
OpenShift assigns
runAsUser/fsGroupautomatically via SCC and rejects pods that hard-code them, so users need to null these out in the rendered podsecurityContext. The Helm chart'svalues.schema.jsontypedsecurityContexts.pod.runAsUser/runAsGroup/fsGroupas non-nullable integers (via the vendoredio.k8s.api.core.v1.PodSecurityContextdefinition), so setting them tonullfailed schema validation before the templates ever rendered — the templates themselves already pass through explicit nulls correctly.This introduces a new
AirflowPodSecurityContextschema definition (notio.k8s.*-prefixed, so it survivesvendor_k8s_json_schema.pyregeneration) that allowsnullfor these three fields, and points all 16securityContexts.pod$refs at it instead of the vendored definition.closes: #41630
Test plan
test_main_pod_setting_runasuser_fsgroup_nullverifyingrunAsUser/fsGrouprender asNonewhen explicitly nulledbreeze testing helm-tests --test-type security— 188 passedbreeze testing helm-tests --use-xdist(full suite) — 2061 passedhelm templatethat the schema now accepts the null override and the rendered manifest'sspec.template.spec.securityContextreflects the explicit nullsWas generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Sonnet 5) following the guidelines