From 6df0f8a2ed2d1a08aa2b476dcc63da7669c6bd1b Mon Sep 17 00:00:00 2001 From: Ada Lundhe Date: Tue, 17 Nov 2026 12:07:48 -0800 Subject: [PATCH] charts: let OpenShift's SCC assign pod IDs OpenShift's default SCC, restricted-v2, assigns each pod a UID and fsGroup from its namespace's range and refuses a runAsUser or fsGroup outside it. RustFS and k8s-credential-provider pin theirs, so a default install on OpenShift never starts them. Leave runAsUser, runAsGroup and fsGroup unset when the cluster serves security.openshift.io/v1, so these pods run in group 0 like other pods with an assigned UID. Other clusters render the same manifests as before. RustFS runs as an arbitrary UID with a group-writable /data; it logs to stdout when it cannot write /logs. Signed-off-by: Ada Lundhe --- charts/substrate/README.md | 4 ++++ charts/substrate/templates/_helpers.tpl | 11 +++++++++++ .../templates/k8s-credential-provider.yaml | 2 ++ charts/substrate/templates/rustfs.yaml | 2 ++ charts/substrate/tests/control_plane_test.yaml | 18 ++++++++++++++++++ 5 files changed, 37 insertions(+) diff --git a/charts/substrate/README.md b/charts/substrate/README.md index de1dd125fa..b5984221d9 100644 --- a/charts/substrate/README.md +++ b/charts/substrate/README.md @@ -66,6 +66,10 @@ allow. New installs should set `atelet.enabled=false` and install the helm template substrate ./charts/substrate ``` +On OpenShift the chart leaves pod UIDs and fsGroups for the SCC to assign. It +detects OpenShift from the cluster's API versions, which `helm template` cannot +see, so add `--api-versions security.openshift.io/v1` when rendering for it. + `manifests/ate-install/` in the repo is the rendered mTLS output and is regenerated by `hack/render-manifests.sh`. The separate `substrate-crds` chart mirrors `manifests/ate-install/generated/`. diff --git a/charts/substrate/templates/_helpers.tpl b/charts/substrate/templates/_helpers.tpl index 38e4d1b433..881154a4c5 100644 --- a/charts/substrate/templates/_helpers.tpl +++ b/charts/substrate/templates/_helpers.tpl @@ -241,6 +241,17 @@ definition so the fallback cannot drift between pods. {{- ((.Values.global).imagePullPolicy) | default "IfNotPresent" -}} {{- end -}} +{{/* +pinIDs is non-empty unless the cluster is OpenShift. OpenShift's default SCC, +restricted-v2, assigns each pod a UID and fsGroup from its namespace's range +and refuses a runAsUser or fsGroup outside it. Pods leave runAsGroup unset there +too, so they run in group 0 like other pods with an assigned UID. To render for +OpenShift without a cluster, pass --api-versions security.openshift.io/v1. +*/}} +{{- define "substrate.pinIDs" -}} +{{- if not (.Capabilities.APIVersions.Has "security.openshift.io/v1") }}true{{ end -}} +{{- end -}} + {{/* Object storage settings shared by object-store plugins. */}} {{- define "substrate.storage.env" -}} - name: ATE_STORAGE_BACKEND diff --git a/charts/substrate/templates/k8s-credential-provider.yaml b/charts/substrate/templates/k8s-credential-provider.yaml index b6215b8c85..6476fd14c5 100644 --- a/charts/substrate/templates/k8s-credential-provider.yaml +++ b/charts/substrate/templates/k8s-credential-provider.yaml @@ -70,8 +70,10 @@ spec: serviceAccountName: {{ include "substrate.fullname" (list "k8s-credential-provider" .) }} {{- with include "substrate.imagePullSecrets" . }}{{- . | nindent 6 }}{{- end }} securityContext: +{{- if include "substrate.pinIDs" . }} runAsUser: 65532 runAsGroup: 65532 +{{- end }} runAsNonRoot: true containers: - name: k8s-credential-provider diff --git a/charts/substrate/templates/rustfs.yaml b/charts/substrate/templates/rustfs.yaml index 95a5b10053..bd1f70ec32 100644 --- a/charts/substrate/templates/rustfs.yaml +++ b/charts/substrate/templates/rustfs.yaml @@ -69,10 +69,12 @@ spec: app: rustfs spec: serviceAccountName: {{ include "substrate.fullname" (list "rustfs" .) }} +{{- if include "substrate.pinIDs" . }} securityContext: runAsUser: 10001 runAsGroup: 10001 fsGroup: 10001 +{{- end }} {{- with include "substrate.imagePullSecrets" . }}{{- . | nindent 6 }}{{- end }} containers: - name: rustfs diff --git a/charts/substrate/tests/control_plane_test.yaml b/charts/substrate/tests/control_plane_test.yaml index 72fe6c2026..e9c3404fc5 100644 --- a/charts/substrate/tests/control_plane_test.yaml +++ b/charts/substrate/tests/control_plane_test.yaml @@ -206,6 +206,24 @@ tests: content: name: statusz containerPort: 4040 +- it: leaves pod IDs to OpenShift's SCC + templates: + - k8s-credential-provider.yaml + - rustfs.yaml + documentSelector: + path: kind + value: Deployment + matchMany: true + capabilities: + apiVersions: + - security.openshift.io/v1 + asserts: + - notExists: + path: spec.template.spec.securityContext.runAsUser + - notExists: + path: spec.template.spec.securityContext.runAsGroup + - notExists: + path: spec.template.spec.securityContext.fsGroup - it: stops OTLP push without an endpoint but keeps the scraped metrics template: ate-controller.yaml documentSelector: