Skip to content

test: enforce restricted PSS for CI user namespace - #3487

Open
danish9039 wants to merge 24 commits into
kubeflow:masterfrom
danish9039:pss-restricted-user-namespace-ci
Open

test: enforce restricted PSS for CI user namespace#3487
danish9039 wants to merge 24 commits into
kubeflow:masterfrom
danish9039:pss-restricted-user-namespace-ci

Conversation

@danish9039

@danish9039 danish9039 commented May 26, 2026

Copy link
Copy Markdown
Member

Summary of Changes

This pull request makes continuous integration validate Kubeflow user workloads under Kubernetes Pod Security Standards restricted.

  • Relabel the continuous-integration Profile namespace kubeflow-user-example-com to pod-security.kubernetes.io/enforce=restricted after the Profile Controller creates it, only when GITHUB_ACTIONS is set.
  • Keep the production and default Profile Controller behavior unchanged.
  • Update workflow path filters so shared Pod Security Standards test-script and local overlay changes rerun affected component workflows.
  • Make continuous-integration workload examples compatible with restricted Pod Security Standards across Katib, KServe, Notebooks, Workspaces, Trainer, Ray, and Istio validation.
  • Move Katib and Trainer restricted Pod Security Standards test mutations into local overlays instead of live kubectl patch or 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_ACTIONS is 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, defaultSecurityContextRunAsGroup and defaultSecurityContextRunAsNonRoot directly in applications/pipeline/overlays/pipeline-install-config-securitycontext.yaml. That path is referenced from example/kustomization.yaml, so it changed every regular installation and not only GitHub Actions.

That file is now byte-identical to master again, and the restricted defaults live in a new continuous-integration only overlay applications/pipeline/restricted-pss, selected by tests/pipelines_install.sh. This matches how tests/katib_install.sh and tests/trainer_install.sh already gate their overlays.

Verified by rendering:

kustomize build example                              -> RunAsUser "", RunAsGroup "", RunAsNonRoot ""
kustomize build applications/pipeline/overlays       -> RunAsUser "", RunAsGroup "", RunAsNonRoot ""
kustomize build applications/pipeline/restricted-pss -> RunAsUser "1000", RunAsGroup "0", RunAsNonRoot "true"

Rebase onto master

This branch is rebased onto master at d8504b91 (2026-08-28). master moved under the pull request and made three of its temporary continuous-integration patches redundant, so they are gone:

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.yaml was deleted upstream. tests/trainer_test.sh keeps master's kubeflow-trainer-api==2.3.0 pin plus the torch-distributed runtime 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/*/upstream folders or common/* 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 #3444.

Validation

Current head is 8c4d0d43.

Local validation on 8c4d0d43:

  • kustomize build example renders empty Pipelines identity defaults, as shown above.
  • kustomize build succeeds for applications/pipeline/overlays, applications/pipeline/restricted-pss, applications/katib/overlays/security and applications/trainer/overlays/runtimes-restricted.
  • git diff master -- applications/pipeline/overlays tests/notebooks_install.sh tests/workspaces_pipeline_run_test.sh is empty.
  • black --check tests/*.py passes with black 26.5.1, the version continuous integration uses.
  • No applications/*/upstream/** file is modified.

Contributor Checklist

  • I have tested these changes with kustomize. See Installation Prerequisites.
  • 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:
#3562

Copilot AI review requested due to automatic review settings May 26, 2026 21:57
@github-actions

Copy link
Copy Markdown

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • Update 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.
  • Add tests/kubeflow_profile_install.sh and tests/PSS_enable.sh to workflow on.pull_request.paths filters across several test workflows.
  • Broaden some workflow path filters (e.g., 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.

Show a summary per file
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.

Comment thread tests/kubeflow_profile_install.sh Outdated
Comment thread tests/kubeflow_profile_install.sh Outdated
Comment thread tests/dashboard_install.sh Outdated
@danish9039
danish9039 requested a review from Copilot May 28, 2026 12:02
@danish9039
danish9039 marked this pull request as ready for review May 30, 2026 14:15
@danish9039

Copy link
Copy Markdown
Member Author

@juliusvonkohout

@juliusvonkohout
juliusvonkohout requested review from Copilot and removed request for Copilot June 1, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

Comment thread tests/katib_install.sh Outdated
Comment thread tests/katib_install.sh
Comment thread tests/katib_test.sh Outdated
Comment thread tests/notebooks_install.sh Outdated
Comment thread tests/trainer_test.sh Outdated
kubectl get pods -n kubeflow-system -l app.kubernetes.io/name=trainer
kubectl get clustertrainingruntimes torch-distributed

kubectl patch clustertrainingruntime torch-distributed --type=json -p='[

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must also be a proper overlay and maybe upstreamed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might already bea recent Pr for this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the torch-distributed runtime changes into applications/trainer/overlays/runtimes-restricted; upstream follow-up is noted separately.

@danish9039 danish9039 Jun 5, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked kubeflow/trainer#3066 ; it helps with override support, but this PR still needs the local runtime default overlay.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split to kubeflow/trainer#3702; #3487 keeps the CI-only runtime overlay until that lands.

Comment thread tests/training_operator_install.sh Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this into applications/training-operator/overlays/kubeflow-restricted-pss and noted the follow-up removal after 26.03.1.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept as a proper overlay and logged the removal follow-up after 26.03.1.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 37 out of 37 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

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

Comment thread .github/workflows/workspaces_pipeline_run_test.yaml
danish9039 and others added 21 commits August 28, 2026 23:17
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>
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>
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>
`Remove legacy Training Operator (kubeflow#3540)` deleted `applications/training-operator/upstream`,
so `applications/training-operator/overlays/kubeflow-restricted-pss` no longer builds:

    accumulating resources from '../../upstream/overlays/kubeflow':
    evalsymlink failure ... no such file or directory

The matching `tests/training_operator_*.sh`, `tests/training_operator_job.yaml` and
`.github/workflows/training_operator_test.yaml` were removed by the same upstream change
while rebasing, so nothing references this overlay any more.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bm4s3z25BrfMky6b4R2ej6
Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
`applications/pipeline/overlays` is referenced from `example/kustomization.yaml:69`, so
setting `defaultSecurityContextRunAsUser`, `defaultSecurityContextRunAsGroup` and
`defaultSecurityContextRunAsNonRoot` there changed every regular installation, not only
GitHub Actions.

Restore the upstream empty values in `applications/pipeline/overlays` and move the
restricted Pod Security Standards defaults into a new continuous-integration only
overlay `applications/pipeline/restricted-pss`, selected by `tests/pipelines_install.sh`
when `GITHUB_ACTIONS` is set. This matches how `tests/katib_install.sh` and
`tests/trainer_install.sh` already gate their restricted overlays.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bm4s3z25BrfMky6b4R2ej6
Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
`black` 26.5.1 wraps the `FileNotFoundError` warning in
`tests/pipeline_run_and_wait_kubeflow.py`, which failed the `format_python_files` check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bm4s3z25BrfMky6b4R2ej6
Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>
@danish9039
danish9039 force-pushed the pss-restricted-user-namespace-ci branch 2 times, most recently from 1badb96 to 8f216ba Compare August 28, 2026 20:26
@danish9039

Copy link
Copy Markdown
Member Author

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:

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.

@danish9039
danish9039 force-pushed the pss-restricted-user-namespace-ci branch from 8f216ba to f25ebfb Compare August 29, 2026 06:32
The KServe overlay on master already sets the restricted security context
on the default ClusterStorageContainer since kubeflow#3515, without runAsUser.

Signed-off-by: danish9039 <danishsiddiqui040@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Three Pipelines workflows omit the new restricted overlay from path filters, and several introduced names violate mandatory repository guidance.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (4)

tests/pipeline_run_and_wait_kubeflow.py:119

  • The newly introduced exception variable e violates the repository requirement for explicitly long, expressive names in AGENTS.md:7. Rename it to exception.
        except Exception as e:

tests/pipeline_run_and_wait_kubeflow.py:127

  • The newly introduced exception variable e violates the repository requirement for explicitly long, expressive names in AGENTS.md:7. Rename it to exception.
        except Exception as e:

tests/pipeline_run_and_wait_kubeflow.py:174

  • The newly introduced exception variable e violates the repository requirement for explicitly long, expressive names in AGENTS.md:7. Rename it to exception.
    except Exception as e:

tests/pipeline_run_and_wait_kubeflow.py:183

  • The newly introduced exception variable e violates the repository requirement for explicitly long, expressive names in AGENTS.md:7. Rename it to exception.
    except Exception as e:
  • Files reviewed: 28/28 changed files
  • Comments generated: 5
  • Review effort level: Balanced

- common/cert-manager/**
- common/oauth2-proxy/**
- common/istio*/**
- tests/pipeline*
- tests/pipeline_v1_test.py
- tests/pipeline_v2_test.py
- experimental/security/PSS/*
- tests/pipeline*
- tests/dashboard_install.sh
- tests/multi_tenancy_install.sh
- tests/pipelines_install.sh
- tests/kubeflow_profile_install.sh
Comment on lines +10 to +30
PSS_ENFORCE=baseline
if [[ "${GITHUB_ACTIONS:-false}" == "true" ]]; then
PSS_ENFORCE=restricted
fi

kubectl label namespace "$KF_PROFILE" \
"pod-security.kubernetes.io/enforce=${PSS_ENFORCE}" \
--overwrite

if [[ "$PSS_ENFORCE" == "restricted" ]]; then
kubectl label namespace "$KF_PROFILE" \
pod-security.kubernetes.io/enforce-version=latest \
--overwrite
fi

kubectl get namespace "$KF_PROFILE" \
-o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce}' | grep -qx "$PSS_ENFORCE"

if [[ "$PSS_ENFORCE" == "restricted" ]]; then
kubectl get namespace "$KF_PROFILE" \
-o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce-version}' | grep -qx latest
Comment on lines +106 to +111
except Exception as e:
logger.warning(
"Unable to run diagnostic command. Exception: %s: %s",
e.__class__.__name__,
str(e),
)
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.

5 participants