Expand PodOverrides with volumes, volumeMounts, and securityContext#1041
Open
JustinElst wants to merge 1 commit intokelos-dev:mainfrom
Open
Expand PodOverrides with volumes, volumeMounts, and securityContext#1041JustinElst wants to merge 1 commit intokelos-dev:mainfrom
JustinElst wants to merge 1 commit intokelos-dev:mainfrom
Conversation
Adds four optional fields to the shared PodOverrides struct so that spawned Task pods can attach extra volumes, mount them into the agent container, and declare pod- and container-level securityContext. This unblocks PSS-restricted namespaces and use cases that need extra mounts (writable profile dirs, CA bundles, custom CLI configs). Field semantics: - Volumes: appended to the Job's PodSpec.Volumes; user-supplied names must not collide with the Kelos-managed names "workspace" and "kelos-plugin", and duplicates are rejected. - VolumeMounts: appended to the agent container's mounts. A flat list rather than a map keyed by container name -- only the agent container is exposed; init containers stay private. - PodSecurityContext: replaces the pod-level securityContext set by the controller. As a carve-out, FSGroup is preserved from Kelos's default when the user does not set it explicitly, so the agent user retains read/write access to the workspace volume. - ContainerSecurityContext: replaces the agent container's securityContext (allowPrivilegeEscalation=false, capabilities.drop=[ALL], readOnlyRootFilesystem=true, etc.) so the pod can land in a PSS-restricted namespace. Also fixes a latent bug in helmchart.Render: rendered templates were being split into YAML documents with strings.Split(content, "---\n"), which corrupts documents whose description text happens to contain "---\n". The new corev1 types pulled into the CRD surface this -- PodSecurityContext.fsGroup's description contains the literal example "rw-rw----\n", which the naive split treats as a document boundary. Replaced with k8s.io/apimachinery/pkg/util/yaml's reader, which only splits on lines that exactly match "---". Existing render tests that relied on a substring search for ":latest" were also tightened to match real image references rather than CRD description text that mentions ":latest" in prose.
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.
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds four optional fields to the shared
PodOverridesstruct so that spawned Task pods can attach extra volumes, mount them into the agent container, and declare pod- and container-level security contexts:volumes— appended to the Job'sPodSpec.Volumes. User-supplied names must not collide with Kelos-managed names (workspace,kelos-plugin); duplicates are rejected.volumeMounts— appended to the agent container's mounts. A flat list rather than a map keyed by container name; only the agent container is exposed, init containers stay private.podSecurityContext— replaces the pod-level security context set by the controller. As a carve-out,fsGroupis preserved from Kelos's default when the user does not set it explicitly, so the agent user retains read/write access to the workspace volume.containerSecurityContext— replaces the agent container's security context, so callers can declareallowPrivilegeEscalation: false,capabilities.drop: [ALL],readOnlyRootFilesystem: true, etc., and the pod can land in a PSS-restricted namespace.Without these fields, namespaces enforcing PSS
restrictedreject Kelos-spawned pods because the spawned containers don't declare the required security primitives — so operators are forced to relax the agent namespace tobaseline. With these fields exposed, callers can opt back intorestrictedand can also mount things like writable profile dirs, custom CA bundles, or per-task config files.This PR also fixes a latent bug in
internal/helmchart/render.go: rendered templates were being split into YAML documents withstrings.Split(content, "---\n"), which corrupts documents whose description text happens to contain"---\n". The newcorev1types pulled into the CRD surface this —PodSecurityContext.fsGroup's description contains the literal examplerw-rw----\n, which the naive split treats as a document boundary. Replaced withk8s.io/apimachinery/pkg/util/yaml's reader, which only splits on lines that exactly match---. A couple of render tests that relied on a substring search for":latest"were also tightened to match real image references rather than CRD description text mentioning:latestin prose.Which issue(s) this PR is related to:
N/A
Special notes for your reviewer:
ServiceAccountNamewas already exposed onPodOverrides, so this PR only adds the four new fields above.VolumeMountsandContainerSecurityContextare intentionally not keyed by container name — the agent container is the only meaningful target, and exposing init containers would let users break the workspace setup. The flat shape mirrors howResourcesis exposed today.PodSecurityContextmerge semantics: user values win field-by-field on the user-supplied struct (Kelos copies it viaDeepCopyand applies it directly), with one exception — if the user did not setFSGroup, the controller preserves the Kelos-defaultFSGroup, since dropping it silently breaks workspace volume access.Does this PR introduce a user-facing change?