Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions charts/substrate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`.
Expand Down
11 changes: 11 additions & 0 deletions charts/substrate/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions charts/substrate/templates/k8s-credential-provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions charts/substrate/templates/rustfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions charts/substrate/tests/control_plane_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading