← Back to Pull requests

test: enforce restricted PSS for CI user namespace #3487

Open
danish9039 opened this pull request with 722 lines diff across 28 files
View on GitHub
danish9039 danish9039 commented on May 26, 2026 21:57 UTC
Author

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:

  • KServe storage initializer. #3515 (merged 2026-08-24) already patches the default ClusterStorageContainer with the restricted security context 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. The downstream pull request #3527 is superseded by the same change; kserve/kserve#5855 remains the upstream fix.

  • Workspaces. #3584 (Notebooks v2.0.0-beta.0) added tests/workspacekind.test.yaml with seccompProfile, runAsNonRoot, dropped capabilities and fsGroup, and no fixed runAsUser. tests/workspaces_pipeline_run_test.sh on master applies that file, so the patch_workspacekind_for_restricted_pss function and its runAsUser: 1000 are dropped. This also resolves the review comment that a fixed user identifier should not be hard-coded there.

  • Notebooks rollout timeouts. master already waits 180s per Notebooks deployment in tests/notebooks_install.sh with 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.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 https://github.com/kubeflow/community-distribution/pull/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

    - [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

    Diff: 722 lines (+618 / -104) across 28 files Reviewer: juliusvonkohout Review duration: 232809m
    All Vouch review confidence checks passed
    Residual risk 0.08 = Change Risk (0.78) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.78 · 722 lines diff across 28 files
    0.78
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.92 · 5 substantive comment(s)
    0.92
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    89%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.394
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    43 items
    github-actions[bot] github-actions[bot] commented on May 26, 2026 21:57 UTC
    Bot

    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:

  • CNCF Slack channels: https://www.kubeflow.org/docs/about/community/#kubeflow-slack-channels

  • Community meetings: https://www.kubeflow.org/docs/about/community/
  • Thanks again for helping to improve Kubeflow.

    Copilot Copilot commented on code on May 26, 2026 21:59 UTC
    Code Review
    tests/kubeflow_profile_install.sh:1
    @@ -5,5 +5,12 @@ sleep 30 # Let the profile controler reconcile the namespace
     PROFILE_CONTROLLER_POD=$(kubectl get pods -n kubeflow -o json | jq -r '.items[] | select(.metadata.name | startswith("profiles-deployment")) | .metadata.name')
     kubectl logs -n kubeflow "$PROFILE_CONTROLLER_POD"
     KF_PROFILE=kubeflow-user-example-com
    -kubectl -n $KF_PROFILE get pods,configmaps,secrets
    -kubectl label namespace $KF_PROFILE pod-security.kubernetes.io/enforce=baseline --overwrite
    +kubectl -n "$KF_PROFILE" get pods,configmaps,secrets
    +kubectl label namespace "$KF_PROFILE" \
    +  pod-security.kubernetes.io/enforce=restricted \
    +  pod-security.kubernetes.io/enforce-version=latest \
    +  --overwrite
    +kubectl get namespace "$KF_PROFILE" \
    +  -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce}' | grep -qx restricted
    +kubectl get namespace "$KF_PROFILE" \
    +  -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce-version}' | grep -qx latest

    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.

    Copilot Copilot commented on code on May 26, 2026 21:59 UTC
    Code Review
    tests/kubeflow_profile_install.sh:1
    @@ -5,5 +5,12 @@ sleep 30 # Let the profile controler reconcile the namespace
     PROFILE_CONTROLLER_POD=$(kubectl get pods -n kubeflow -o json | jq -r '.items[] | select(.metadata.name | startswith("profiles-deployment")) | .metadata.name')
     kubectl logs -n kubeflow "$PROFILE_CONTROLLER_POD"
     KF_PROFILE=kubeflow-user-example-com
    -kubectl -n $KF_PROFILE get pods,configmaps,secrets
    -kubectl label namespace $KF_PROFILE pod-security.kubernetes.io/enforce=baseline --overwrite
    +kubectl -n "$KF_PROFILE" get pods,configmaps,secrets
    +kubectl label namespace "$KF_PROFILE" \
    +  pod-security.kubernetes.io/enforce=restricted \
    +  pod-security.kubernetes.io/enforce-version=latest \
    +  --overwrite
    +kubectl get namespace "$KF_PROFILE" \
    +  -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce}' | grep -qx restricted
    +kubectl get namespace "$KF_PROFILE" \
    +  -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce-version}' | grep -qx latest

    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.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on May 26, 2026 21:59 UTC
    Reviewer

    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.

    <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>

    juliusvonkohout juliusvonkohout commented on code on May 27, 2026 10:13 UTC
    Code Review
    tests/dashboard_install.sh:1
    @@ -3,11 +3,30 @@ set -euxo pipefail
     
     echo "Installing Kubeflow Dashboard ..."
     
    +dump_dashboard_debug() {
    +  kubectl -n kubeflow get deployment,pods -l app.kubernetes.io/part-of=kubeflow-dashboard -o wide || true
    +  kubectl -n kubeflow describe deployment/dashboard || true

    please drop the || true after debugging / before merging, that is a wrong recommendation from LLMs. You want to fail fast.

    danish9039 danish9039 commented on code on May 30, 2026 14:09 UTC
    Code Review
    tests/kubeflow_profile_install.sh:1
    @@ -5,5 +5,12 @@ sleep 30 # Let the profile controler reconcile the namespace
     PROFILE_CONTROLLER_POD=$(kubectl get pods -n kubeflow -o json | jq -r '.items[] | select(.metadata.name | startswith("profiles-deployment")) | .metadata.name')
     kubectl logs -n kubeflow "$PROFILE_CONTROLLER_POD"
     KF_PROFILE=kubeflow-user-example-com
    -kubectl -n $KF_PROFILE get pods,configmaps,secrets
    -kubectl label namespace $KF_PROFILE pod-security.kubernetes.io/enforce=baseline --overwrite
    +kubectl -n "$KF_PROFILE" get pods,configmaps,secrets
    +kubectl label namespace "$KF_PROFILE" \
    +  pod-security.kubernetes.io/enforce=restricted \
    +  pod-security.kubernetes.io/enforce-version=latest \
    +  --overwrite
    +kubectl get namespace "$KF_PROFILE" \
    +  -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce}' | grep -qx restricted
    +kubectl get namespace "$KF_PROFILE" \
    +  -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce-version}' | grep -qx latest

    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.

    danish9039 danish9039 commented on code on May 30, 2026 14:09 UTC
    Code Review
    tests/kubeflow_profile_install.sh:1
    @@ -5,5 +5,12 @@ sleep 30 # Let the profile controler reconcile the namespace
     PROFILE_CONTROLLER_POD=$(kubectl get pods -n kubeflow -o json | jq -r '.items[] | select(.metadata.name | startswith("profiles-deployment")) | .metadata.name')
     kubectl logs -n kubeflow "$PROFILE_CONTROLLER_POD"
     KF_PROFILE=kubeflow-user-example-com
    -kubectl -n $KF_PROFILE get pods,configmaps,secrets
    -kubectl label namespace $KF_PROFILE pod-security.kubernetes.io/enforce=baseline --overwrite
    +kubectl -n "$KF_PROFILE" get pods,configmaps,secrets
    +kubectl label namespace "$KF_PROFILE" \
    +  pod-security.kubernetes.io/enforce=restricted \
    +  pod-security.kubernetes.io/enforce-version=latest \
    +  --overwrite
    +kubectl get namespace "$KF_PROFILE" \
    +  -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce}' | grep -qx restricted
    +kubectl get namespace "$KF_PROFILE" \
    +  -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce-version}' | grep -qx latest

    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.

    danish9039 danish9039 commented on code on May 30, 2026 14:11 UTC
    Code Review
    tests/dashboard_install.sh:1
    @@ -3,11 +3,30 @@ set -euxo pipefail
     
     echo "Installing Kubeflow Dashboard ..."
     
    +dump_dashboard_debug() {
    +  kubectl -n kubeflow get deployment,pods -l app.kubernetes.io/part-of=kubeflow-dashboard -o wide || true
    +  kubectl -n kubeflow describe deployment/dashboard || true

    Addressed

    danish9039 danish9039 commented on Jun 01, 2026 05:34 UTC
    Author

    @juliusvonkohout

    Copilot Copilot commented on code on Jun 01, 2026 14:16 UTC
    Code Review
    tests/katib_install.sh:1
    @@ -1,8 +1,31 @@
     #!/bin/bash
     set -euxo pipefail
     
    -cd applications/katib/upstream && kustomize build installs/katib-with-kubeflow | kubectl apply -f - && cd ../../../
    +KATIB_CI_OVERLAY=$(mktemp -d .katib-ci-overlay.XXXXXX)
    +trap 'rm -rf "$KATIB_CI_OVERLAY"' EXIT
     
    +awk '
    +  { print }
    +  $0 == "    webhookPort: 8443" { print "    injectSecurityContext: true" }
    +' applications/katib/upstream/installs/katib-cert-manager/katib-config.yaml > "$KATIB_CI_OVERLAY/katib-config.yaml"
    +grep -q "injectSecurityContext: true" "$KATIB_CI_OVERLAY/katib-config.yaml"

    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.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Jun 01, 2026 14:16 UTC
    Reviewer

    Pull request overview

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

    juliusvonkohout juliusvonkohout commented on code on Jun 01, 2026 14:20 UTC
    Code Review
    tests/katib_install.sh:1
    juliusvonkohout juliusvonkohout commented on code on Jun 01, 2026 14:21 UTC
    Code Review
    tests/katib_test.sh:1
    @@ -2,11 +2,69 @@
     set -euxo pipefail
     
     KF_PROFILE=${1:-kubeflow-user-example-com}
    +KATIB_SUGGESTION_DEPLOYMENT=grid-grid
    +
    +dump_katib_debug() {
    +  kubectl get experiments.kubeflow.org -n "$KF_PROFILE" -o yaml
    +  kubectl get trials.kubeflow.org -n "$KF_PROFILE" -o yaml
    +  kubectl get deployments,replicasets,jobs,pods -n "$KF_PROFILE" -o wide --show-labels
    +  kubectl describe experiments.kubeflow.org -n "$KF_PROFILE"
    +  kubectl describe trials.kubeflow.org -n "$KF_PROFILE"
    +  kubectl describe deployments,replicasets,jobs,pods -n "$KF_PROFILE"
    +  kubectl get events -n "$KF_PROFILE" --sort-by=.metadata.creationTimestamp
    +  kubectl logs -n kubeflow deployment/katib-controller --tail=100
    +}
    +
    +wait_for_katib_suggestion_deployment() {
    +  for _ in $(seq 1 90); do
    +    if kubectl get deployment "$KATIB_SUGGESTION_DEPLOYMENT" -n "$KF_PROFILE" >/dev/null 2>&1; then
    +      return 0
    +    fi
    +    sleep 2
    +  done
    +
    +  return 1
    +}
    +
    +patch_katib_suggestion_deployment() {

    can you make this relaibale without yaml patches here ?

    juliusvonkohout juliusvonkohout commented on code on Jun 01, 2026 14:25 UTC
    Code Review
    tests/notebooks_install.sh:1
    @@ -3,14 +3,30 @@ set -euxo pipefail
     
     echo "Installing Kubeflow Notebooks v1 ..."
     
    +dump_notebooks_debug() {

    is that not part of the GHA upload artifacts ?

    juliusvonkohout juliusvonkohout commented on code on Jun 01, 2026 14:26 UTC
    Code Review
    tests/notebooks_install.sh:1
    @@ -3,14 +3,30 @@ set -euxo pipefail
     
     echo "Installing Kubeflow Notebooks v1 ..."
     
    +dump_notebooks_debug() {

    please use collect logs on failure instead of debug dump or so everywhere.

    juliusvonkohout juliusvonkohout commented on code on Jun 01, 2026 14:27 UTC
    Code Review
    tests/trainer_test.sh:1
    @@ -17,5 +17,34 @@ kubectl get deployment kubeflow-trainer-controller-manager -n kubeflow-system
     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='[

    this must also be a proper overlay and maybe upstreamed.

    juliusvonkohout juliusvonkohout commented on code on Jun 01, 2026 14:27 UTC
    Code Review
    tests/trainer_test.sh:1
    @@ -17,5 +17,34 @@ kubectl get deployment kubeflow-trainer-controller-manager -n kubeflow-system
     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='[

    There might already bea recent Pr for this.

    juliusvonkohout juliusvonkohout commented on code on Jun 01, 2026 14:29 UTC
    Code Review
    tests/training_operator_install.sh:1

    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.

    Copilot Copilot commented on code on Jun 05, 2026 08:09 UTC
    Code Review
    .github/workflows/workspaces_pipeline_run_test.yaml:1
    @@ -71,3 +73,25 @@ jobs:
     
         - name: Apply Pod Security Standards restricted levels
           run: ./tests/PSS_enable.sh
    +
    +    - name: Collect Logs on Failure
    +      if: failure()
    +      run: |
    +        mkdir -p logs
    +        kubectl get all --all-namespaces > logs/resources.txt
    +        kubectl get events --all-namespaces --sort-by=.metadata.creationTimestamp > logs/events.txt
    +        kubectl get workspace test -n kubeflow-user-example-com -o yaml > logs/workspace-test.yaml 2>&1 || true
    +        kubectl get workspacekind jupyterlab -o yaml > logs/workspacekind-jupyterlab.yaml 2>&1 || true
    +        for namespace in kubeflow kubeflow-workspaces kubeflow-user-example-com istio-system cert-manager auth; do
    +            kubectl describe pods -n $namespace > logs/$namespace-pods.txt 2>&1 || true
    +            for pod in $(kubectl get pods -n $namespace -o jsonpath='{.items[*].metadata.name}' 2>/dev/null || true); do
    +                kubectl logs -n $namespace $pod --tail=100 > logs/$namespace-$pod.txt 2>&1 || true
    +            done
    +        done
    +
    +    - name: Upload Diagnostic Logs
    +      if: always()
    +      uses: actions/upload-artifact@v4
    +      with:
    +        name: kubeflow-test-logs
    +        path: logs/

    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.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Jun 05, 2026 08:09 UTC
    Reviewer

    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>

    danish9039 danish9039 commented on code on Jun 05, 2026 08:17 UTC
    Code Review
    tests/katib_install.sh:1
    @@ -1,8 +1,31 @@
     #!/bin/bash
     set -euxo pipefail
     
    -cd applications/katib/upstream && kustomize build installs/katib-with-kubeflow | kubectl apply -f - && cd ../../../
    +KATIB_CI_OVERLAY=$(mktemp -d .katib-ci-overlay.XXXXXX)
    +trap 'rm -rf "$KATIB_CI_OVERLAY"' EXIT
     
    +awk '
    +  { print }
    +  $0 == "    webhookPort: 8443" { print "    injectSecurityContext: true" }
    +' applications/katib/upstream/installs/katib-cert-manager/katib-config.yaml > "$KATIB_CI_OVERLAY/katib-config.yaml"
    +grep -q "injectSecurityContext: true" "$KATIB_CI_OVERLAY/katib-config.yaml"

    The awk path is gone now; Katib installs from applications/katib/overlays/security with a rendered katib-config instead.

    danish9039 danish9039 commented on code on Jun 05, 2026 08:17 UTC
    Code Review
    tests/katib_install.sh:1

    Moved this into applications/katib/overlays/security and kept the install script to a plain kustomize build | kubectl apply.

    danish9039 danish9039 commented on code on Jun 05, 2026 08:17 UTC
    Code Review
    tests/katib_test.sh:1
    @@ -2,11 +2,69 @@
     set -euxo pipefail
     
     KF_PROFILE=${1:-kubeflow-user-example-com}
    +KATIB_SUGGESTION_DEPLOYMENT=grid-grid
    +
    +dump_katib_debug() {
    +  kubectl get experiments.kubeflow.org -n "$KF_PROFILE" -o yaml
    +  kubectl get trials.kubeflow.org -n "$KF_PROFILE" -o yaml
    +  kubectl get deployments,replicasets,jobs,pods -n "$KF_PROFILE" -o wide --show-labels
    +  kubectl describe experiments.kubeflow.org -n "$KF_PROFILE"
    +  kubectl describe trials.kubeflow.org -n "$KF_PROFILE"
    +  kubectl describe deployments,replicasets,jobs,pods -n "$KF_PROFILE"
    +  kubectl get events -n "$KF_PROFILE" --sort-by=.metadata.creationTimestamp
    +  kubectl logs -n kubeflow deployment/katib-controller --tail=100
    +}
    +
    +wait_for_katib_suggestion_deployment() {
    +  for _ in $(seq 1 90); do
    +    if kubectl get deployment "$KATIB_SUGGESTION_DEPLOYMENT" -n "$KF_PROFILE" >/dev/null 2>&1; then
    +      return 0
    +    fi
    +    sleep 2
    +  done
    +
    +  return 1
    +}
    +
    +patch_katib_suggestion_deployment() {

    Removed the live suggestion deployment patch; the suggestion container securityContext now comes from the Katib security overlay.

    danish9039 danish9039 commented on code on Jun 05, 2026 08:17 UTC
    Code Review
    tests/notebooks_install.sh:1
    @@ -3,14 +3,30 @@ set -euxo pipefail
     
     echo "Installing Kubeflow Notebooks v1 ..."
     
    +dump_notebooks_debug() {

    Moved the debug dumps out of the scripts and added Collect Logs on Failure plus artifact upload steps in the affected workflows.

    danish9039 danish9039 commented on code on Jun 05, 2026 08:17 UTC
    Code Review
    tests/trainer_test.sh:1
    @@ -17,5 +17,34 @@ kubectl get deployment kubeflow-trainer-controller-manager -n kubeflow-system
     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='[

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

    danish9039 danish9039 commented on code on Jun 05, 2026 08:17 UTC
    Code Review
    tests/trainer_test.sh:1
    @@ -17,5 +17,34 @@ kubectl get deployment kubeflow-trainer-controller-manager -n kubeflow-system
     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='[

    Checked https://github.com/kubeflow/trainer/pull/3066 ; it helps with override support, but this PR still needs the local runtime default overlay.

    danish9039 danish9039 commented on code on Jun 05, 2026 08:17 UTC
    Code Review
    tests/training_operator_install.sh:1

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

    danish9039 danish9039 commented on code on Jun 05, 2026 08:17 UTC
    Code Review
    .github/workflows/workspaces_pipeline_run_test.yaml:1
    @@ -71,3 +73,25 @@ jobs:
     
         - name: Apply Pod Security Standards restricted levels
           run: ./tests/PSS_enable.sh
    +
    +    - name: Collect Logs on Failure
    +      if: failure()
    +      run: |
    +        mkdir -p logs
    +        kubectl get all --all-namespaces > logs/resources.txt
    +        kubectl get events --all-namespaces --sort-by=.metadata.creationTimestamp > logs/events.txt
    +        kubectl get workspace test -n kubeflow-user-example-com -o yaml > logs/workspace-test.yaml 2>&1 || true
    +        kubectl get workspacekind jupyterlab -o yaml > logs/workspacekind-jupyterlab.yaml 2>&1 || true
    +        for namespace in kubeflow kubeflow-workspaces kubeflow-user-example-com istio-system cert-manager auth; do
    +            kubectl describe pods -n $namespace > logs/$namespace-pods.txt 2>&1 || true
    +            for pod in $(kubectl get pods -n $namespace -o jsonpath='{.items[*].metadata.name}' 2>/dev/null || true); do
    +                kubectl logs -n $namespace $pod --tail=100 > logs/$namespace-$pod.txt 2>&1 || true
    +            done
    +        done
    +
    +    - name: Upload Diagnostic Logs
    +      if: always()
    +      uses: actions/upload-artifact@v4
    +      with:
    +        name: kubeflow-test-logs
    +        path: logs/

    Latest successful run confirms upload-artifact only warns when logs/ is absent, so I kept this consistent with the existing workflows.

    juliusvonkohout juliusvonkohout commented on code on Jun 05, 2026 11:32 UTC
    Code Review
    applications/katib/overlays/security/katib-config.yaml:1

    Can you upstream this or make sure to only patch the securitycontext, but not the image for example ?

    juliusvonkohout juliusvonkohout commented on code on Jun 05, 2026 11:33 UTC
    Code Review
    experimental/ray/raycluster_example.yaml:1
    @@ -111,57 +118,57 @@ spec:
                 seccompProfile:
                   type: RuntimeDefault
             volumes:
    -          - name: ray-logs
    -            emptyDir: {}
    +        - name: ray-logs
    +          emptyDir: {}
       workerGroupSpecs:
    -    - replicas: 1
    -      minReplicas: 1
    -      maxReplicas: 1
    -      groupName: small-group
    -      rayStartParams:
    -        num-cpus: '1'
    -        node-manager-port: '6380'
    -        object-manager-port: '6381'
    -        runtime-env-agent-port: '6382'
    -        dashboard-agent-grpc-port: '6383'
    -        dashboard-agent-listen-port: '52365'
    -        metrics-export-port: '8080'
    -        max-worker-port: '10012'
    -        # kubeflow-user-example-com should be replaced with the namespace where the Ray cluster is being deployed
    -        # TODO automatically use the current namespace
    -        node-ip-address: $(hostname -I | tr -d ' ' | sed 's/\./-/g').raycluster-istio-headless-svc.kubeflow-user-example-com.svc.cluster.local
    -      template:
    -        metadata:
    -          labels:
    -            sidecar.istio.io/inject: "true"
    -        spec:
    -          serviceAccountName: default-editor
    -          containers:
    -          - name: ray-worker
    -            image: rayproject/ray:2.44.1-py311-cpu
    -            lifecycle:
    -              preStop:
    -                exec:
    -                  command: ["/bin/sh","-c","ray stop"]
    -            # use volumeMounts.Optional.
    -            # Refer to https://kubernetes.io/docs/concepts/storage/volumes/
    -            volumeMounts:
    -             - mountPath: /tmp/ray
    -               name: ray-logs
    -            resources:
    -             limits:
    -               cpu: "1"
    -               memory: "1G"
    -             requests:
    -               cpu: "300m"
    -               memory: "1G"
    -            securityContext:
    -             allowPrivilegeEscalation: false
    -             capabilities:
    -               drop: ["ALL"]
    -             runAsNonRoot: true
    -             seccompProfile:
    -               type: RuntimeDefault
    -          volumes:
    -            - name: ray-logs
    -              emptyDir: {}
    +  - replicas: 1
    +    minReplicas: 1
    +    maxReplicas: 1
    +    groupName: small-group
    +    rayStartParams:
    +      num-cpus: '1'
    +      node-manager-port: '6380'
    +      object-manager-port: '6381'
    +      runtime-env-agent-port: '6382'
    +      dashboard-agent-grpc-port: '6383'
    +      dashboard-agent-listen-port: '52365'
    +      metrics-export-port: '8080'
    +      max-worker-port: '10012'
    +      # kubeflow-user-example-com should be replaced with the namespace where the Ray cluster is being deployed
    +      # TODO automatically use the current namespace
    +      node-ip-address: $(hostname -I | tr -d ' ' | sed 's/\./-/g').raycluster-istio-headless-svc.kubeflow-user-example-com.svc.cluster.local
    +    template:
    +      metadata:
    +        labels:
    +          sidecar.istio.io/inject: "true"
    +      spec:
    +        serviceAccountName: default-editor
    +        containers:
    +        - name: ray-worker
    +          image: rayproject/ray:2.44.1-py311-cpu

    may you update ray and kuberay to the latest available versions please

    juliusvonkohout juliusvonkohout commented on code on Jun 05, 2026 11:36 UTC
    Code Review
    tests/katib_install.sh:1
    @@ -1,8 +1,8 @@
     #!/bin/bash
     set -euxo pipefail
     
    -cd applications/katib/upstream && kustomize build installs/katib-with-kubeflow | kubectl apply -f - && cd ../../../
    -
    +kustomize build applications/katib/overlays/security | kubectl apply -f -

    is it possible to have 2 steps for this? since these scripts are also used for the single step install and would reach customers.

    juliusvonkohout juliusvonkohout commented on code on Jun 05, 2026 11:37 UTC
    Code Review
    tests/katib_install.sh:1
    @@ -1,8 +1,8 @@
     #!/bin/bash
     set -euxo pipefail
     
    -cd applications/katib/upstream && kustomize build installs/katib-with-kubeflow | kubectl apply -f - && cd ../../../
    -
    +kustomize build applications/katib/overlays/security | kubectl apply -f -

    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

    juliusvonkohout juliusvonkohout commented on code on Jun 05, 2026 11:38 UTC
    Code Review
    tests/katib_install.sh:1
    @@ -1,8 +1,8 @@
     #!/bin/bash
     set -euxo pipefail
     
    -cd applications/katib/upstream && kustomize build installs/katib-with-kubeflow | kubectl apply -f - && cd ../../../
    -
    +kustomize build applications/katib/overlays/security | kubectl apply -f -

    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.

    juliusvonkohout juliusvonkohout commented on code on Jun 05, 2026 11:40 UTC
    Code Review
    tests/kserve_test.sh:1
    @@ -8,6 +8,21 @@ export KSERVE_INGRESS_HOST_PORT=${KSERVE_INGRESS_HOST_PORT:-localhost:8080}
     export KSERVE_M2M_TOKEN="$(kubectl -n ${NAMESPACE} create token default-editor)"
     export KSERVE_TEST_NAMESPACE=${NAMESPACE}
     
    +kubectl patch clusterstoragecontainer default --type=merge --patch '{

    can you add this directly to the kserve installation as patch ? Maybe even upstream it ?

    juliusvonkohout juliusvonkohout commented on code on Jun 05, 2026 11:42 UTC
    Code Review
    tests/kubeflow_profile_install.sh:1
    @@ -5,5 +5,12 @@ sleep 30 # Let the profile controler reconcile the namespace
     PROFILE_CONTROLLER_POD=$(kubectl get pods -n kubeflow -o json | jq -r '.items[] | select(.metadata.name | startswith("profiles-deployment")) | .metadata.name')
     kubectl logs -n kubeflow "$PROFILE_CONTROLLER_POD"
     KF_PROFILE=kubeflow-user-example-com
    -kubectl -n $KF_PROFILE get pods,configmaps,secrets
    -kubectl label namespace $KF_PROFILE pod-security.kubernetes.io/enforce=baseline --overwrite
    +kubectl -n "$KF_PROFILE" get pods,configmaps,secrets
    +kubectl label namespace "$KF_PROFILE" \
    +  pod-security.kubernetes.io/enforce=restricted \
    +  pod-security.kubernetes.io/enforce-version=latest \
    +  --overwrite

    only when you are in the GHA environments as in our kind script.

    google-oss-prow[bot] google-oss-prow[bot] commented on Jul 04, 2026 20:04 UTC
    Bot

    [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:

  • OWNERS
  • 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"]} -->

    danish9039 danish9039 commented on Jul 04, 2026 20:43 UTC
    Author

    Tracking the follow-up pull requests split out from this restricted-PSS CI work:

  • Katib: https://github.com/kubeflow/katib/pull/2683 - adds restricted-compatible suggestion runtime contexts and metrics collector injection configuration.

  • KServe downstream: https://github.com/kubeflow/community-distribution/pull/3527 - keeps the storage initializer security context overlay until an upstream release is synchronized.

  • KServe upstream: https://github.com/kserve/kserve/pull/5855 - adds the storage initializer defaults at the canonical source.

  • Trainer: https://github.com/kubeflow/trainer/pull/3702 - updates Trainer v2 Torch runtime manifests and Helm templates for restricted PSS.

  • Trainer SDK dependency: https://github.com/kubeflow/sdk/pull/604 - writes generated training files to a writable path without overriding image working directories.

  • Workspaces/Notebooks: https://github.com/kubeflow/notebooks/pull/1229 - updates the WorkspaceKind samples on notebooks-v2.

  • Ray/KubeRay: https://github.com/kubeflow/community-distribution/pull/3528 - merged separately to align the experimental Ray/KubeRay versions.
  • Training Operator removal remains deferred until after 26.03.1.

    danish9039 danish9039 commented on Aug 05, 2026 06:45 UTC
    Author

    /retest

    juliusvonkohout juliusvonkohout commented on Aug 10, 2026 15:20 UTC
    Contributor

    Please rebase to master

    danish9039 danish9039 commented on Aug 28, 2026 20:32 UTC
    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:

  • KServe storage initializer. #3515 already patches the default 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.

  • Workspaces. #3584 added 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.

  • Notebooks timeouts. 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.

    github-actions[bot] github-actions[bot] commented on Nov 02, 2026 00:22 UTC
    Bot

    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.

    juliusvonkohout juliusvonkohout commented on Nov 03, 2026 10:18 UTC
    Contributor

    @vikas-saxena02 can you help out there as well ?

    Assignees
    danish9039 danish9039
    Labels
    risk: low confidence: 89.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 77.9% (HIGH) · Higher = larger blast radius
    77.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.9% · Lower = rushed or shallow review
    89.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.9% · Safe to merge
    7.9%