-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runAsUser: 1000 in securityContext causes error in Openshift #1003
Comments
Are you having issues clearing that default? Although Helm's default value system is cumbersome to work with, an explicit
As #909 states, this doesn't have anything to do the reason mentioned in #1003
This is for compliance with Kubernetes 1.23+ default Restricted security policy (under "Running as Non-root user") to not run as root. Although docs state that nil should be allowed, the full story is more complex. The code check for this has failure cases for nil UID. IIRC in practical testing I could not deploy into a restricted-enforced environment without adding the explicit run as user. I'm not familiar with how the username input to that verification function is derived, I expect it's looking at the container metadata and seeing the |
We are using the chart as subchart. Setting the runAsUser=null results in the default value 1000 being used. |
Testing confirms we do indeed hit that restriction if we remove this. To demonstrate, I created a restricted namespace and installed several configurations into it and
Removing it actually breaks even the unrestricted install. The check actually confirms whether the container complies with its
In the restricted namespace you'll get the same failure if you install with
So AFAICT nulling the setting is the only option if we don't want to remove restricted compliance and further indicate that the container may run as root. The implementation of the check suggests that there may be a way to create a container with no user that then passes the check, but I suspect that's not actually possible and is just an entirely hypothetical situation the code can handle. I've asked SIG Auth if they know otherwise, but in any case I think it's likely we'd clear the user from the container image build. |
Fascinating. The subchart implementation never fails to amaze: helm/helm#12637 It looks like the Pod enforcement can indeed permit
Having built that, in the unrestricted namespace:
The controller already uses a numeric USER argument, so it doesn't need a custom image. It looks like you should also be able to instruct OpenShift that some given range of UIDs is acceptable for a namespace (or project). Is that an option? It's probably simpler than maintaining a custom image, even if it's a simple one. https://www.ibm.com/docs/en/cloud-paks/cp-management/2.2.x?topic=collection-adding-user-id-group-id-in-dockerfile Some of that content suggests you can maybe set this permitted range at the Deployment level, but I'm not sure. If that's actually allowed, we could probably add those annotations to the chart resources. |
Thx for your efforts. For the time being we will set the runAsUser explicitly, even if it could change after recreation of the project. |
Openshift does dynamically attribute defined user ranges. Therefore the user 1000 is in general not a valid user.
In version 1.6 it was removed already (### Removal of default security context UID setting) , but was reintroduced with #909.
The securityContext can be defined without the runAsUser and everything works fine.
The text was updated successfully, but these errors were encountered: