Skip to content

config: add restricted PSS contexts for suggestions - #2683

Open
danish9039 wants to merge 6 commits into
kubeflow:masterfrom
danish9039:pr3487/katib-restricted-pss
Open

config: add restricted PSS contexts for suggestions#2683
danish9039 wants to merge 6 commits into
kubeflow:masterfrom
danish9039:pr3487/katib-restricted-pss

Conversation

@danish9039

Copy link
Copy Markdown
Member

What this PR does / why we need it:

This PR makes the built-in Katib suggestion deployments compatible with Kubernetes restricted Pod Security Standards by using existing runtime.suggestions[*].securityContext support in the install configs.

It also enables init.controller.injectSecurityContext so Katib metrics collector init containers get restricted-compatible security contexts. No API/schema fields or Trial template mutation are added.

OpenShift install note: katib-openshift keeps the restricted fields but omits a fixed runAsUser so OpenShift SCC UID allocation can choose the namespace-assigned UID.

Validation:

  • KUBEBUILDER_ASSETS="$(/home/danish/go/bin/setup-envtest use 1.34.0 -p path)" go test -count=1 ./pkg/util/v1beta1/katibconfig ./pkg/controller.v1beta1/suggestion/composer
  • kustomize build for all six install overlays plus katib-with-kubeflow
  • git diff --check

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Related to kubeflow/community-distribution#3487

Checklist:

  • Docs included if any changes are user facing

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

🎉 Welcome to the Kubeflow Katib repo! 🎉

Thanks for opening your first PR! We're excited to have you onboard 🚀

Next steps:

Feel free to ask questions in the comments. Thanks again for contributing! 🙏

@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign johnugeorge for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coveralls

coveralls commented Jul 4, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 9.93%danish9039:pr3487/katib-restricted-pss into kubeflow:master. No base build found for kubeflow:master.

Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
@danish9039
danish9039 force-pushed the pr3487/katib-restricted-pss branch from 2617764 to 8ab8afe Compare July 17, 2026 11:58
@danish9039

Copy link
Copy Markdown
Member Author

Two notes from testing this alongside the downstream restricted Pod Security Standards work in kubeflow/community-distribution#3487.

On the fixed runAsUser: 1000 in the non-OpenShift installs: it works today, but only because the images have no OCI User and therefore run as root unless told otherwise. I confirmed every suggestion image plus earlystopping-medianstop and file-metrics-collector declares an empty User. Their Dockerfiles already end with chgrp -R 0 ${TARGET_DIR} && chmod -R g+rwX ${TARGET_DIR}, the arbitrary-UID pattern — and that pattern only works because runAsUser without runAsGroup yields GID 0, which I verified on a restricted-enforcing cluster (uid=1000 gid=0(root) groups=0(root)).

The durable fix would be a numeric USER 1000:0 in the images themselves. The group-0 groundwork is already there, so it is a one-line addition per Dockerfile, and it would let every manifest drop runAsUser — matching what kserve/kserve#5855 and the merged kubeflow/notebooks#1229 do. Restricted only requires runAsNonRoot: true; runAsUser is not part of the profile. Happy to raise that as a follow-up if it is useful.

One thing I could not verify and that is worth a second look: whether all writable paths work under the selected identity for the pbt suggestion specifically, since it mounts a ReadWriteMany persistentVolumeClaim. Unlike emptyDir, PVC ownership is not automatically world-writable, so that path may need fsGroup.

@danish9039

Copy link
Copy Markdown
Member Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants