feat: add pod security context defaults and CRD overrides#239
Merged
Conversation
Inference pods had no PodSecurityContext or container SecurityContext. On OpenShift, the restricted-v2 SCC requires seccompProfile to match, and without it the PVC stays root:root 0755, causing the init container to fail with "mkdir: Permission denied". This also affects any cluster enforcing the Kubernetes Pod Security Standards "restricted" profile. Add hardened defaults to all inference pods: - Pod: seccompProfile RuntimeDefault - Main container: allowPrivilegeEscalation=false, drop ALL capabilities - Init containers: same, plus readOnlyRootFilesystem=false for volume writes Expose podSecurityContext and securityContext fields on the InferenceService CRD so users can override defaults when needed (e.g. setting fsGroup for OpenShift namespace supplemental groups). BREAKING CHANGE: existing inference pods will be updated with security contexts on next reconcile. Deployments using custom images that require Linux capabilities or privilege escalation must set the new securityContext field to restore previous behavior. Fixes #238 Signed-off-by: Christopher Maher <chris@mahercode.io>
72068c5 to
aad8b60
Compare
14 tasks
Member
Author
|
@kannon92 is going to have a look to see if this works. If we're in a good spot, I'll get it merged |
|
LGTM! |
Merged
Defilan
added a commit
that referenced
this pull request
Mar 20, 2026
Add troubleshooting entry for the OpenShift permission denied issue fixed in #239, and link OpenShift from the setup guides line. Closes community-reported issue where init containers fail with "mkdir: Permission denied" on OpenShift due to SCC/fsGroup behavior. Signed-off-by: Christopher Maher <chris@mahercode.io>
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.
Summary
PodSecurityContext(seccompProfile: RuntimeDefault) and containerSecurityContext(allowPrivilegeEscalation: false,capabilities.drop: ALL) to all inference pods and init containerspodSecurityContextandsecurityContextfields on the InferenceService CRD so users can override defaults when needed (e.g. settingfsGroupfor OpenShift namespaces)Motivation
On OpenShift 4.21, the
restricted-v2SCC requiresseccompProfile: RuntimeDefaultto match. Without any security context, pods fall back to a less capable SCC that doesn't injectfsGroup, so the PVC at/modelsstaysroot:root 0755and the non-root init container fails withmkdir: Permission denied. This also affects any cluster enforcing the Kubernetes Pod Security Standards "restricted" profile.Breaking change
Existing inference pods will be updated with security contexts on next reconcile. Deployments using custom images that require Linux capabilities or privilege escalation must set the new
securityContextfield to restore previous behavior.How OpenShift users fix their deployment
After this change, OpenShift users can add
podSecurityContextto their InferenceService:The
seccompProfile: RuntimeDefaultdefault may also be sufficient on its own, since it allows proper SCC matching which auto-injectsfsGroup.Test plan
make generate && make manifestspassesmake testpasses (all existing + 6 new security context tests)make vet && make fmtcleanpodSecurityContext.fsGroupset (requested reporter to test)Fixes #238