test: enforce restricted PSS for CI user namespace #3487
Welcome to the Kubeflow Manifests Repository
Thanks for opening your first PR. Your contribution means a lot to the Kubeflow community.
Before making more PRs:
Please ensure your PR follows our Contributing Guide.
Please also be aware that many components are synchronizes from upstream via the scripts in /scripts.
So in some cases you have to fix the problem in the upstream repositories first, but you can use a PR against kubeflow/manifests to test the platform integration.
Community Resources:
Thanks again for helping to improve Kubeflow.
These jsonpath expressions are likely incorrect for label keys that contain / (e.g., pod-security.kubernetes.io/enforce). With kubectl -o jsonpath, map keys containing / should be accessed via bracket notation (e.g., .metadata.labels['pod-security.kubernetes.io/enforce']), otherwise the expression can evaluate to empty and make the grep assertions fail even when the label is present.
Using pod-security.kubernetes.io/enforce-version=latest can make CI behavior non-deterministic across Kubernetes upgrades (the enforced policy semantics can change as 'latest' advances). Consider pinning to an explicit version (e.g., matching the cluster minor version) to keep test results stable over time.
Pull request overview
[!NOTE]
Copilot was unable to run its full agentic suite in this review.
This PR updates CI to validate/enforce Kubernetes Pod Security Standards (PSS) settings for Kubeflow profile namespaces, and wires the related test scripts into multiple GitHub Actions path filters so relevant workflows run when these scripts change.
Changes:
kubeflow_profile_install.sh to label the Kubeflow user namespace with pod-security.kubernetes.io/enforce=restricted and enforce-version=latest, and assert the labels are applied.tests/kubeflow_profile_install.sh and tests/PSS_enable.sh to workflow on.pull_request.paths filters across several test workflows.tests/pipeline, tests/katib) to cover more related changes.Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
<details>
<summary>Show a summary per file</summary>
| File | Description |
| ---- | ----------- |
| tests/kubeflow_profile_install.sh | Labels the profile namespace for PSS restricted + adds assertions for applied labels. |
| .github/workflows/workspaces_pipeline_run_test.yaml | Triggers workflow on profile/PSS test script changes. |
| .github/workflows/volumes_web_application_test.yaml | Triggers workflow on profile install script changes. |
| .github/workflows/training_operator_test.yaml | Triggers workflow on profile/PSS test script changes. |
| .github/workflows/trainer_test.yaml | Triggers workflow on profile/PSS test script changes. |
| .github/workflows/pipeline_test.yaml | Broadens pipeline path trigger + triggers on profile/PSS test script changes. |
| .github/workflows/pipeline_run_from_notebook.yaml | Adds pipeline wildcard + profile/PSS script triggers. |
| .github/workflows/kserve_test.yaml | Triggers workflow on profile/PSS test script changes. |
| .github/workflows/kserve_models_web_application_test.yaml | Triggers workflow on profile install script changes. |
| .github/workflows/katib_test.yaml | Broadens katib path trigger + triggers on profile/PSS test script changes. |
| .github/workflows/istio_validation.yaml | Triggers workflow on profile/PSS test script changes. |
| .github/workflows/dex_oauth2-proxy_test.yaml | Triggers workflow on profile/PSS test script changes. |
</details>
please drop the || true after debugging / before merging, that is a wrong recommendation from LLMs. You want to fail fast.
Keeping this as-is because kubectl accepts the escaped label-key JSONPath here; I verified it returns restricted/latest, while the unescaped bracket form returns empty.
Keeping latest intentionally so CI tracks the restricted PSS semantics of the pinned Kind Kubernetes version; if the cluster image moves, we want that compatibility signal.
Addressed
@juliusvonkohout
The Katib config patching is brittle and can generate invalid YAML if the upstream config ever adds an injectSecurityContext field (this awk injects a second key). It also depends on an exact line match for webhookPort: 8443. Make the patch idempotent by updating an existing key when present, and only inserting when missing.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
most of that belong into an PSS overlay.in https://github.com/kubeflow/manifests/tree/master/applications/katib/overlays/security or so
can you make this relaibale without yaml patches here ?
is that not part of the GHA upload artifacts ?
please use collect logs on failure instead of debug dump or so everywhere.
this must also be a proper overlay and maybe upstreamed.
There might already bea recent Pr for this.
please a proper overlay. this has to survive the next release and then we can already remove it. Please raise a follow up PR to remove it such that i can merge it afte rthe 26.03.1 release.
The upload-artifact step runs with if: always() but logs/ is only created in the preceding if: failure() step. On a successful run, logs/ may not exist and actions/upload-artifact can fail the job. Fix by either creating logs/ unconditionally (e.g., mkdir -p logs in the upload step) or setting with: if-no-files-found: ignore. This same pattern appears in several other updated workflows in this PR and should be applied consistently.
Pull request overview
Copilot reviewed 37 out of 37 changed files in this pull request and generated 1 comment.
<details>
<summary>Comments suppressed due to low confidence (2)</summary>
tests/workspaces_pipeline_run_test.sh:1
This JSONPatch adds nested fields under /spec/podTemplate/securityContext/... and /spec/podTemplate/containerSecurityContext/.... JSONPatch add will fail if the parent object (e.g., /spec/podTemplate/securityContext) does not already exist. To make this robust across different base WorkspaceKind manifests, patch the parent objects in one operation (e.g., add/merge the full securityContext / containerSecurityContext objects) or use a strategic/merge patch (--type=merge) targeting the parent keys.
tests/kserve_test.sh:1
The polling logic treats any response other than 403 as success (twice). This can still false-positive on 404/503 while routes/backends are not ready—exactly the failure mode mentioned in the comment above the loop. Prefer checking for the expected success code (typically 200) or at least explicitly excluding 404/503 (and possibly 000) from counting toward STABLE_POLL_COUNT, to prevent passing the policy wait while the service is still unreachable.
#!/bin/bash
</details>
The awk path is gone now; Katib installs from applications/katib/overlays/security with a rendered katib-config instead.
Moved this into applications/katib/overlays/security and kept the install script to a plain kustomize build | kubectl apply.
Removed the live suggestion deployment patch; the suggestion container securityContext now comes from the Katib security overlay.
Moved the debug dumps out of the scripts and added Collect Logs on Failure plus artifact upload steps in the affected workflows.
Moved the torch-distributed runtime changes into applications/trainer/overlays/runtimes-restricted; upstream follow-up is noted separately.
Checked https://github.com/kubeflow/trainer/pull/3066 ; it helps with override support, but this PR still needs the local runtime default overlay.
Moved this into applications/training-operator/overlays/kubeflow-restricted-pss and noted the follow-up removal after 26.03.1.
Latest successful run confirms upload-artifact only warns when logs/ is absent, so I kept this consistent with the existing workflows.
Can you upstream this or make sure to only patch the securitycontext, but not the image for example ?
may you update ray and kuberay to the latest available versions please
is it possible to have 2 steps for this? since these scripts are also used for the single step install and would reach customers.
Maybe you have to use kustomize components instead of overlays to have a cleaner separation. If componnts do not work you can also stay with the overlay
you caould have an if around it as in our kind installation that you install the extra security stuff on top only if you are in GHA. That goes for all installation scripts.
can you add this directly to the kserve installation as patch ? Maybe even upstream it ?
only when you are in the GHA environments as in our kind script.
[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 kimwnasptd 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 open>
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
</details>
<!-- META={"approvers":["kimwnasptd"]} -->
Tracking the follow-up pull requests split out from this restricted-PSS CI work:
Training Operator removal remains deferred until after 26.03.1.
/retest
Please rebase to master
Rebased onto master at d8504b91, as requested. Head is 8f216bab, 24 commits, linear, MERGEABLE.
master moved under this pull request and made three of its temporary patches redundant, so they are gone rather than merged:
ClusterStorageContainer in applications/kserve/kserve/kustomization.yaml#L24-L43, without runAsUser because the image declares OCI user 1000. The GitHub-Actions-only kubectl patch clusterstoragecontainer in tests/kserve_test.sh is removed; #3527 is superseded by the same change.tests/workspacekind.test.yaml with the restricted fields and no fixed user, and master applies it in tests/workspaces_pipeline_run_test.sh. The patch_workspacekind_for_restricted_pss function, including the runAsUser: 1000 @thesuperzapper flagged, is dropped.master already waits 180s in tests/notebooks_install.sh, so this pull request no longer touches that file.Verified locally on 8f216bab: kustomize build for example, applications/pipeline/overlays, applications/pipeline/restricted-pss, applications/katib/overlays/security and applications/trainer/overlays/runtimes-restricted; git diff master -- applications/pipeline/overlays is empty; black --check passes with 26.5.1. The description is updated to match; the change set is 28 files, +635 / -104.
On the Katib overlay question (applications/katib/overlays/security/katib-config.yaml): it cannot be reduced to a securityContext-only patch, because katib-config.yaml is a single opaque string inside the katib-config ConfigMap and kustomize cannot patch a field inside it. The copy is temporary until kubeflow/katib#2683, which adds the same contexts to the default configuration, is released and synchronized; then the overlay is deleted.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@vikas-saxena02 can you help out there as well ?
juliusvonkohout
danish9039
Summary of Changes
This pull request makes continuous integration validate Kubeflow user workloads under Kubernetes Pod Security Standards
restricted.kubeflow-user-example-comtopod-security.kubernetes.io/enforce=restrictedafter the Profile Controller creates it, only whenGITHUB_ACTIONSis set.kubectl patchor generated temporary-overlay logic.Scope: no change to the regular installation
Every restricted Pod Security Standards default in this pull request is selected only when
GITHUB_ACTIONSis set:| Component | Selected by | Scope |
|---|---|---|
| Katib |
tests/katib_install.sh| continuous integration only || Trainer runtimes |
tests/trainer_install.sh| continuous integration only || Kubeflow Pipelines |
tests/pipelines_install.sh| continuous integration only || Profile Controller baseline |
tests/profile_controller_install.sh| continuous integration only |An earlier revision of this pull request set
defaultSecurityContextRunAsUser,defaultSecurityContextRunAsGroupanddefaultSecurityContextRunAsNonRootdirectly inapplications/pipeline/overlays/pipeline-install-config-securitycontext.yaml. That path is referenced fromexample/kustomization.yaml, so it changed every regular installation and not only GitHub Actions.That file is now byte-identical to
masteragain, and the restricted defaults live in a new continuous-integration only overlayapplications/pipeline/restricted-pss, selected bytests/pipelines_install.sh. This matches howtests/katib_install.shandtests/trainer_install.shalready gate their overlays.Verified by rendering:
Rebase onto
masterThis branch is rebased onto
masteratd8504b91(2026-08-28).mastermoved under the pull request and made three of its temporary continuous-integration patches redundant, so they are gone:ClusterStorageContainerwith the restricted security context inapplications/kserve/kserve/kustomization.yaml#L24-L43, withoutrunAsUser, because the image declares OCI user1000. The GitHub-Actions-onlykubectl patch clusterstoragecontainerintests/kserve_test.shis removed. The downstream pull request #3527 is superseded by the same change; kserve/kserve#5855 remains the upstream fix.v2.0.0-beta.0) addedtests/workspacekind.test.yamlwithseccompProfile,runAsNonRoot, dropped capabilities andfsGroup, and no fixedrunAsUser.tests/workspaces_pipeline_run_test.shonmasterapplies that file, so thepatch_workspacekind_for_restricted_pssfunction and itsrunAsUser: 1000are dropped. This also resolves the review comment that a fixed user identifier should not be hard-coded there.masteralready waits180sper Notebooks deployment intests/notebooks_install.shwith a state dump on failure, so this pull request no longer touches that file.Earlier rebase notes still apply: the legacy Training Operator overlay was dropped after #3540, the failure-log collection steps live in #3560, and
.github/workflows/kserve_models_web_application_test.yamlwas deleted upstream.tests/trainer_test.shkeepsmaster'skubeflow-trainer-api==2.3.0pin plus thetorch-distributedruntime dump.The change set is now 28 files,
+635 / -104.Notes
This is intentionally continuous-integration and test focused. It does not change the default customer Profile namespace policy.
The new application changes are local Kubeflow manifests overlays. They do not edit synchronized
applications//upstreamfolders orcommon/manifests.A follow-up note is still tracked for keeping the copied Katib continuous-integration configuration in sync during future Katib synchronizations.
Related
Follow-up to https://github.com/kubeflow/community-distribution/pull/3444.
Validation
Current head is
8c4d0d43.Local validation on
8c4d0d43:kustomize build examplerenders empty Pipelines identity defaults, as shown above.kustomize buildsucceeds forapplications/pipeline/overlays,applications/pipeline/restricted-pss,applications/katib/overlays/securityandapplications/trainer/overlays/runtimes-restricted.git diff master -- applications/pipeline/overlays tests/notebooks_install.sh tests/workspaces_pipeline_run_test.shis empty.black --check tests/.pypasses withblack26.5.1, the version continuous integration uses.applications//upstream/**file is modified.Contributor Checklist
- [x] I have tested these changes with kustomize. See Installation Prerequisites.
- [x] All commits are _signed-off_ to satisfy the DCO check.
- [ ] I have considered adding my company to the adopters page to support Kubeflow and help the community, since I expect help from the community for my issue.
Related Issues
Tracking issue:
https://github.com/kubeflow/community-distribution/issues/3562