Skip to content

feat: add pod security context defaults and CRD overrides#239

Merged
Defilan merged 1 commit intomainfrom
fix/openshift-securitycontext-238
Mar 19, 2026
Merged

feat: add pod security context defaults and CRD overrides#239
Defilan merged 1 commit intomainfrom
fix/openshift-securitycontext-238

Conversation

@Defilan
Copy link
Copy Markdown
Member

@Defilan Defilan commented Mar 18, 2026

Summary

  • Adds default PodSecurityContext (seccompProfile: RuntimeDefault) and container SecurityContext (allowPrivilegeEscalation: false, capabilities.drop: ALL) to all inference pods and init containers
  • Exposes new podSecurityContext and securityContext fields on the InferenceService CRD so users can override defaults when needed (e.g. setting fsGroup for OpenShift namespaces)
  • Regenerates CRD manifests and syncs Helm chart CRD

Motivation

On OpenShift 4.21, the restricted-v2 SCC requires seccompProfile: RuntimeDefault to match. Without any security context, pods fall back to a less capable SCC that doesn't inject fsGroup, so the PVC at /models stays root:root 0755 and the non-root init container fails with mkdir: 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 securityContext field to restore previous behavior.

How OpenShift users fix their deployment

After this change, OpenShift users can add podSecurityContext to their InferenceService:

spec:
  modelRef: tinyllama
  podSecurityContext:
    fsGroup: 1000680000
    runAsNonRoot: true

The seccompProfile: RuntimeDefault default may also be sufficient on its own, since it allows proper SCC matching which auto-injects fsGroup.

Test plan

  • make generate && make manifests passes
  • make test passes (all existing + 6 new security context tests)
  • make vet && make fmt clean
  • Manual: deploy on OpenShift with podSecurityContext.fsGroup set (requested reporter to test)

Fixes #238

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>
@Defilan Defilan force-pushed the fix/openshift-securitycontext-238 branch from 72068c5 to aad8b60 Compare March 18, 2026 21:06
@Defilan Defilan changed the title fix: add security context defaults for OpenShift compatibility feat: add pod security context defaults and CRD overrides Mar 18, 2026
@Defilan
Copy link
Copy Markdown
Member Author

Defilan commented Mar 18, 2026

@kannon92 is going to have a look to see if this works. If we're in a good spot, I'll get it merged

@kannon92
Copy link
Copy Markdown

#238 (comment)

LGTM!

@Defilan Defilan merged commit 904432b into main Mar 19, 2026
16 checks passed
@Defilan Defilan deleted the fix/openshift-securitycontext-238 branch March 19, 2026 18:20
@github-actions github-actions bot mentioned this pull request Mar 19, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unable to run example on Openshift

2 participants