-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Specify the workspace Pods securityContext (SETGID
and SETUID
) when developers have container build capabilities
#21770
Comments
From what I understand, this issue is about propagating containerOverrides and podOverrides from the Che Cluster CR into the Che-owned DWOC and then having DWO inject these overrides into devworkspaces. Currently, containerOverrides and podOverrides must be specified from an attribute in the devworkspace. There is no DWOC field to automatically inject container and pod overrides into devworkspaces, though this could probably be added (@amisevsk let me know if you have any thoughts on this topic). However, in the example given for this issue, the pod and container overrides are being used to specify the workspace pod and container security contexts. Setting the pod security context for workspaces in the DWOC is already possible and setting the container security context for workspaces in the DWOC will soon be possible. Thus, an alternate solution could be to allow setting the pod and container security contexts from the Che Cluster CR, which then are propagated to the Che-owned DWOC, and used by DWO. spec:
devEnvironments:
containerBuildConfiguration:
containerSecurityContext: {"capabilities":{"add": ["SETGID", "SETUID"]}}
podSecurityContext: {"allowPrivilegeEscalation": false} @l0rd @ibuziuk let me know if you have any thoughts on this alternate proposal. |
PR devfile/devworkspace-operator#953 adds the Note another potentially simpler approach, if our specific goal is supporting Step 1Add CheCluster functionality to provision "known, good" container and pod security context into Che-owned DevWorkspaceOperatorConfig when CheCluster: spec:
devEnvironments:
disableContainerBuildCapabilities: false # Enable container build ...causes Che Operator to add fields to DevWorkspaceOperatorConfig: config:
workspace:
# Whatever Che Operator decides is necessary here, maybe even a full config
containerSecurityContext: {"capabilities":{"add": ["SETGID", "SETUID"]}}
podSecurityContext: {"allowPrivilegeEscalation": false} This provides a starting point for enabling container builds by simply toggling one field in CheCluster Step 2What Andrew is suggesting -- add CheCluster fields to allow further customizing securityContext: spec:
devEnvironments:
disableContainerBuildCapabilities: true/false
containerSecurityContext: <securityContext>
podSecurityContext: <podSecurityContext> Setting containerSecurityContext updates the security contexts propagated to the DWOC and allows for finer-grained configuration in situations where it's necessary, but 90%+ of users ideally don't need to set these fields. |
Another thing I'd like to have clarified @l0rd : podSecurityContext: {"allowPrivilegeEscalation": false} Pod Security Context does not have the So what should be the default Pod Security Context to enable container builds? Perhaps I misunderstood something. |
Right. That was a mistake. I also don't think that setting
Being able to use pods override may be used to enable kata containers (specifying
Agreed. Let's do that in 2 steps. |
@l0rd Thank you for the clarification & feedback :) For now, I think it makes sense for me to follow step 1 of @amisevsk's proposal (i.e. configure the DWOC workspace security contexts based on the value of |
I have done some tests and:
|
The annotation |
@l0rd As mentioned by @amisevsk in the above comment, the |
The attribute is required, as it instructs DWO to grant the workspace's serviceaccount permissions to use the SCC; otherwise pod creation will fail. |
@l0rd last clarification (hopefully 😉): In my testing, the |
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
containerBuildCapability
is enabledSETGID
and SETUID
) when developers have container build capabilities
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Previously-applied workaround is no longer necessary, as SCC selection was fixed with eclipse-che/che#21770. Signed-off-by: Angel Misevski <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]>
* feat: configure workspace security context for container builds Fix eclipse-che/che#21770 Signed-off-by: Andrew Obuchowicz <[email protected]> * Set SCC allowPrivilegeEscalation to true when container build enabled (#1596) * Set SCC allowPrivilegeEscalation to true when container build enabled Running Podman inside a container in OpenShift requires the pod to have allowPrivilegeEscalation: true in its security context. * Fix tests Signed-off-by: Angel Misevski <[email protected]> * fix: set scc priority to null Signed-off-by: Anatolii Bazko <[email protected]> --------- Signed-off-by: Andrew Obuchowicz <[email protected]> Signed-off-by: Angel Misevski <[email protected]> Signed-off-by: Anatolii Bazko <[email protected]> Co-authored-by: Angel Misevski <[email protected]> Co-authored-by: Anatolii Bazko <[email protected]>
Is your enhancement related to a problem? Please describe
Even if the container build is enabled in the CheCluster CR, the required build capabilities (
SETUID
,SETGID
and "allowPrivilegeEscalation": true) are not explicitly requested in the workspaces Pod SecurityContext.This is not an issue if the container-build SCC is the only SCC of the workspaces service accounts.
But, if the workspace ServiceAccount is associated with multiple SCCs, the capabilities of the SCC that requires less privileges are picked. And the developer container won't have
SETUID
andSETGID
capabilities and trying to run a container build will fail.Describe the solution you'd like
The DevWorkspace Operator provides a way to specify Pods security context using a DevWorkspaceOperatorConfiguration (DWOC) CR. When the build capabilities are enabled, Che Operator should apply a DWOC with the security context
{"securityContext":{"capabilities":{"add": ["SETGID", "SETUID"]}, "allowPrivilegeEscalation": true}}
).Additional context
This was initially considered a DWO issue (devfile/devworkspace-operator#884) but the DWO already exposes a mechanism to specify Pods SecurityContext (with the DWOC) so that issue has been closed.
The corresponding OpenShift Dev Spaces issue.
In the future we may allow administrators to specify a custom security context in the CheCluster:
but that's a separate issue.
The text was updated successfully, but these errors were encountered: