Repository navigation
charts: let OpenShift's SCC assign pod IDs - #180
Conversation
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>
The README already says how to render for OpenShift without a cluster. Signed-off-by: Ada Lundhe <adalundhe@lundhe.audio>
codyhartsook
left a comment
There was a problem hiding this comment.
🤖 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.
| {{- if include "substrate.pinIDs" . }} | ||
| runAsUser: 65532 | ||
| runAsGroup: 65532 | ||
| {{- end }} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
anyuidis 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Ooof. Yeah, also this. Hang on.
There was a problem hiding this comment.
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>
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 onlyrunAsNonRoot: trueon 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 templatecannot see the cluster, so the README says to pass--api-versions security.openshift.io/v1when rendering for OpenShift.The README also covers the RustFS SCC grant on upgrade: remove an
anyuidgrant 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/andmanifests/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
anyuidornonroot-v2added for the pods this change touches. That is the setting the fix targets.main, and the credential provider drops only itsrunAsUserandrunAsGroup. With--api-versions security.openshift.io/v1, RustFS drops its pinned IDs too.substrate.pinIDsthat always returns empty fails the first;main's credential-provider and RustFS templates each fail at least one./logs.anyuidgrant, 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 --checkandhelm unittest charts/substratepass.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.mainrenders, for example.spec.securityContext.fsGroup: Invalid value: [10001]: 10001 is not an allowed groupfor RustFS.Evidence: OpenShift Local 5.0.0 (4.21.14 gave the same result)
The SCC that admitted each pod, from its
openshift.io/sccannotation. restricted-v2 is the only SCC either ServiceAccount can use:The RustFS pod spec from
main, created through a ReplicaSet in a namespace where restricted-v2 is the only SCC:AI use: AI-assisted with Claude Code, and a second agent session reviewed it adversarially. I reviewed and tested it.
🤖 Generated with Claude Code