diff --git a/charts/substrate/README.md b/charts/substrate/README.md index de1dd125fa..172c564ed5 100644 --- a/charts/substrate/README.md +++ b/charts/substrate/README.md @@ -66,6 +66,17 @@ 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. + +When you upgrade on OpenShift, remove an `anyuid` grant made for RustFS. `anyuid` +takes priority over restricted-v2 and assigns no fsGroup, so RustFS cannot write +a new volume. Kubelet moves existing RustFS data to the fsGroup restricted-v2 +assigns. Storage that skips that ownership change, as many NFS setups do, leaves +the data writable only by UID 10001: keep the `anyuid` grant there, so RustFS +still runs as that user. + `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..f4bb6fa0d4 100644 --- a/charts/substrate/templates/_helpers.tpl +++ b/charts/substrate/templates/_helpers.tpl @@ -241,6 +241,14 @@ definition so the fallback cannot drift between pods. {{- ((.Values.global).imagePullPolicy) | default "IfNotPresent" -}} {{- end -}} +{{/* +Empty on OpenShift, whose restricted-v2 SCC assigns each pod's UID and fsGroup +and refuses IDs outside the namespace's range. +*/}} +{{- 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..b824d11d75 100644 --- a/charts/substrate/templates/k8s-credential-provider.yaml +++ b/charts/substrate/templates/k8s-credential-provider.yaml @@ -70,8 +70,6 @@ spec: serviceAccountName: {{ include "substrate.fullname" (list "k8s-credential-provider" .) }} {{- with include "substrate.imagePullSecrets" . }}{{- . | nindent 6 }}{{- end }} securityContext: - runAsUser: 65532 - runAsGroup: 65532 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..47c7cb12da 100644 --- a/charts/substrate/tests/control_plane_test.yaml +++ b/charts/substrate/tests/control_plane_test.yaml @@ -206,6 +206,46 @@ tests: content: name: statusz containerPort: 4040 +- it: pins RustFS's IDs off OpenShift + template: rustfs.yaml + documentSelector: + path: kind + value: Deployment + asserts: + - equal: + path: spec.template.spec.securityContext + value: + runAsUser: 10001 + runAsGroup: 10001 + fsGroup: 10001 +- it: runs the credential provider as its image's non-root user + template: k8s-credential-provider.yaml + documentSelector: + path: kind + value: Deployment + asserts: + - equal: + path: spec.template.spec.securityContext + value: + runAsNonRoot: true +- 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: