Skip to content

charts: let OpenShift's SCC assign pod IDs - #180

Merged
adalundhe merged 5 commits into
mainfrom
fix/openshift-scc-assigned-ids
Nov 19, 2026
Merged

adalundhe merged 5 commits into
mainfrom
fix/openshift-scc-assigned-ids

Conversation

@adalundhe

@adalundhe adalundhe commented Nov 17, 2026 •

Copy link
Copy Markdown

OpenShift's default SCC, restricted-v2, assigns each pod a UID and fsGroup from its namespace's range. It refuses a runAsUser or fsGroup outside that range. The chart pins RustFS to 10001 and k8s-credential-provider to 65532, so OpenShift refuses both pods at admission until an admin grants another SCC.

RustFS now leaves runAsUser, runAsGroup and fsGroup unset when the cluster serves security.openshift.io/v1. The credential provider sets only runAsNonRoot: true on every cluster, like ate-controller, ate-api-server and ate-idp-server. Its distroless nonroot image already runs as 65532:65532, so other clusters keep the same UID. helm template cannot see the cluster, so the README says to pass --api-versions security.openshift.io/v1 when rendering for OpenShift.

The README also covers the RustFS SCC grant on upgrade: remove an anyuid grant for a new volume, and keep it on storage that skips ownership changes. Without a pod-wide UID, kubelet writes the credential provider's projected credential bundle with the projected default mode, 0644, as it does for the other three pods.

Not covered: the kustomize manifests in manifests/ate-install/ and manifests/egress-credential-injection/ still pin these IDs.

Tested:

Every OpenShift run below enforced SCCs. Each pod had to pass OpenShift's default SCC, restricted-v2, with no anyuid or nonroot-v2 added for the pods this change touches. That is the setting the fix targets.

  • Without the OpenShift API, RustFS renders as on main, and the credential provider drops only its runAsUser and runAsGroup. With --api-versions security.openshift.io/v1, RustFS drops its pinned IDs too.
  • New helm-unittest cases: RustFS keeps its IDs off OpenShift, the credential provider sets no IDs, and neither pod sets IDs on OpenShift. A substrate.pinIDs that always returns empty fails the first; main's credential-provider and RustFS templates each fail at least one.
  • RustFS 1.0.3 in Docker, as UID 1000680000 and GID 0 with the fsGroup as a supplementary group on an empty volume, starts and serves S3. It logs to stdout because it cannot write /logs.
  • RustFS 1.0.3 upgrade in Docker, from data written as UID 10001 with an anyuid grant, to UID 1000680000 in group 0. Where the volume's group moves to the new fsGroup, as kubelet does it, RustFS reads the old object and writes a new one. Without that ownership change it reads but cannot write. Kept on its image user, UID 10001, it reads and writes.
  • helm lint, hack/render-manifests.sh --check and helm unittest charts/substrate pass.
  • SCC admission, emulated: kind 1.34 with an admission webhook that applies OpenShift's SCC rules and namespace UID ranges. It refuses the pod specs from main (runAsUser=65532 ... not in the allowed range, fsGroup 10001 is not in the allowed range) and admits both pods with this change under restricted-v2.
  • SCC admission, real: on OpenShift Local (CRC) 4.21.14 and 5.0.0, with only restricted-v2 available to these two pods, RustFS and k8s-credential-provider are admitted under restricted-v2 with a UID and fsGroup from the namespace's range, and become ready. RustFS serves its bucket.
  • On the same clusters, restricted-v2 refuses the pod specs that main renders, for example .spec.securityContext.fsGroup: Invalid value: [10001]: 10001 is not an allowed group for RustFS.
Evidence: OpenShift Local 5.0.0 (4.21.14 gave the same result)

The SCC that admitted each pod, from its openshift.io/scc annotation. restricted-v2 is the only SCC either ServiceAccount can use:

POD                                        SCC            UID         FSGROUP
k8s-credential-provider-5dd5f87b4f-gmnsm   restricted-v2  1000670000  1000670000
rustfs-66c8688c84-7nzvt                    restricted-v2  1000670000  1000670000
rustfs-bucket-init-9mwf6                   restricted-v2  1000670000  1000670000

The RustFS pod spec from main, created through a ReplicaSet in a namespace where restricted-v2 is the only SCC:

REFUSED provider restricted-v2: .spec.securityContext.fsGroup: Invalid value: [10001]: 10001 is not an allowed group

AI use: AI-assisted with Claude Code, and a second agent session reviewed it adversarially. I reviewed and tested it.

  • Tests pass
  • Docs updated

🤖 Generated with Claude Code

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 <adalundhe@lundhe.audio>
@adalundhe
adalundhe marked this pull request as ready for review November 18, 2026 22:19
The README already says how to render for OpenShift without a cluster.

Signed-off-by: Ada Lundhe <adalundhe@lundhe.audio>

@codyhartsook codyhartsook left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI-generated review. I reviewed the findings before posting.

Nothing blocking. I have two suggestions and one optional test gap, all inline.

Checked at 1cf843f: helm unittest charts/substrate (65/65 pass), hack/render-manifests.sh --check, and a diff of renders with and without --api-versions security.openshift.io/v1. I didn't run anything on OpenShift.

Comment on lines +73 to +76
{{- if include "substrate.pinIDs" . }}
runAsUser: 65532
runAsGroup: 65532
{{- end }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This pod may not need the OpenShift check. ko builds it on distroless/static-debian13:nonroot (.ko.yaml), which already runs as 65532:65532. ate-controller, ate-api-server and ate-idp-server use the same base and set only runAsNonRoot: true, and they already pass restricted-v2.

If you drop runAsUser/runAsGroup here on every cluster, vanilla Kubernetes keeps the same UID. OpenShift then doesn't need --api-versions for this pod, and substrate.pinIDs is left with RustFS, which really needs it for fsGroup.

@adalundhe adalundhe Nov 19, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 56f8c7a. The credential provider now sets only runAsNonRoot: true, like the other three pods. Its image runs as UID 65532, so other clusters keep the same UID.

One difference: kubelet now writes its credential bundle as 0644 instead of 0600, the same as for the other three pods.

Comment on lines +69 to +71
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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could the anyuid upgrade note from the PR description go here too? The repo has no CHANGELOG, so after merge this paragraph is where an OpenShift operator will look. Anyone who keeps the grant gets an unwritable RustFS PVC on a new install.

Also, every test run was a fresh install. Upgrading an anyuid install with data owned by 10001 should still work, because kubelet changes the volume's group to the new fsGroup. Drivers that skip ownership changes don't do that, and many NFS setups are like that. Worth a test, or a line in the note.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

^^ Good catch. Hang on!

@adalundhe adalundhe Nov 19, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added to the README in 7fc7e85. I tested the upgrade with RustFS data written as UID 10001:

  • If the storage applies the new fsGroup, RustFS reads and writes.
  • If the storage skips that change, RustFS can read but not write.
  • If anyuid is kept, RustFS runs as UID 10001 and reads and writes.

So the README says to keep anyuid on storage that skips the change.

content:
name: statusz
containerPort: 4040
- it: leaves pod IDs to OpenShift's SCC

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Optional: nothing checks that the IDs stay on vanilla Kubernetes. I made substrate.pinIDs always return empty and all 65 unit tests still passed. render-manifests.sh --check caught the RustFS change, but k8s-credential-provider.yaml is in PRESERVED_FILES, so nothing covers that pod. A mirror case without capabilities would catch it. If you take the credential-provider suggestion, the render check already covers RustFS and you can skip this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ooof. Yeah, also this. Hang on.

@adalundhe adalundhe Nov 19, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added in add6537. One test checks that RustFS keeps its IDs off OpenShift. Another checks that the credential provider sets no IDs. Your mutation now fails the RustFS test.

kubernetes-secrets is built on distroless static nonroot, which runs as
65532:65532, like ate-controller, ate-api-server and ate-idp-server. Those
set only runAsNonRoot, so the credential provider does the same on every
cluster. OpenShift then needs no capability check for this pod.

Without a pod-wide UID, kubelet writes the projected credential bundle
with the projected volume's default mode, 0644, as it does for the other
three pods.

Signed-off-by: Ada Lundhe <adalundhe@lundhe.audio>
An anyuid grant assigns no fsGroup, so RustFS cannot write a new volume
under it. Existing data moves to the new fsGroup unless the storage skips
ownership changes, in which case keeping anyuid keeps RustFS on UID 10001.

Signed-off-by: Ada Lundhe <adalundhe@lundhe.audio>
A substrate.pinIDs that always returns empty passed every unit test.

Signed-off-by: Ada Lundhe <adalundhe@lundhe.audio>

@codyhartsook codyhartsook left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm

@adalundhe
adalundhe merged commit fd66419 into main Nov 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants