-
Notifications
You must be signed in to change notification settings - Fork 97
feat: Support nested containers #2046
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
Conversation
|
Skipping CI for Draft Pull Request. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2046 +/- ##
==========================================
- Coverage 58.22% 50.03% -8.19%
==========================================
Files 90 94 +4
Lines 12401 12506 +105
==========================================
- Hits 7220 6258 -962
- Misses 4679 5821 +1142
+ Partials 502 427 -75 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for nested containers by introducing container run capabilities to complement the existing container build capabilities. This extends the security configuration options for workspaces to allow more granular control over container permissions.
- Container run capabilities with dedicated SecurityContextConstraints and RBAC
- Consolidation of container capabilities logic into a unified reconciler
- Extension of annotation merging for workspace pods
Reviewed Changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
api/v2/checluster_types.go |
Adds container run configuration types and capability check methods |
pkg/deploy/container-capabilities/ |
New unified reconciler replacing separate container build logic |
pkg/deploy/dev-workspace-config/dev_workspace_config.go |
Updates workspace config with container run capabilities support |
pkg/common/diffs/diffs.go |
Adds RBAC diff options for consistent role/binding comparisons |
pkg/common/k8s-client/ |
Removes owner reference parameters from Sync/Create methods |
| Various CRD files | Updates custom resource definitions with new container run fields |
Comments suppressed due to low confidence (3)
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
pkg/deploy/container-capabilities/container_capabilities_test.go
Outdated
Show resolved
Hide resolved
helmcharts/next/crds/checlusters.org.eclipse.che.CustomResourceDefinition.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
|
/retest |
1 similar comment
|
/retest |
|
@cgruver could you please review? due to scc nature once the nested container toggle is enabled on CR level, it would not be possible to start old workspaces. |
|
/retest |
1 similar comment
|
/retest |
|
I tested with the steps mentioned above and can confirm it's working as expected: I used Steps Performed
$ podman build .
STEP 1/2: FROM python:3.12
Resolved "python" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/python:3.12...
Getting image source signatures
Copying blob 41837409009d done |
Copying blob cae3b572364a done |
Copying blob f0c9d6d993ac done |
Copying blob bd090f42c4b7 done |
Copying blob a2ade626d67a done |
Copying blob 6e8f84dd3b31 done |
Copying blob 93ead2e1dc36 done |
Copying config 2b819d06d0 done |
Writing manifest to image destination
STEP 2/2: WORKDIR /usr/local/app
COMMIT
--> d30325a8936d
d30325a8936d2560a3363ab95ef4ee8574631a0b0a3283e0790a1b8e26e873ef✔️ Image built successfully, pulled layers from Docker Hub.
$ podman run -d --rm --name webserver -p 8080:80 quay.io/libpod/banner
Trying to pull quay.io/libpod/banner:latest...
Getting image source signatures
Copying blob 92ec11331c38 done |
Copying blob 64dc81575282 done |
Copying blob 2408cc74d12b done |
Copying blob ef4966331ce5 done |
Copying config 5ba9aec95f done |
Writing manifest to image destination
6da58ee669a3ce0ca9abceb6794e0d28e863597c1edeb594bb3d16a7dfb1562c✔️ Container started and is running as expected.
✔️ UID/GID remapping confirms correct user namespace setup. |
|
I was able to verify the testing steps. I've also tested this following scenario:
|
| DevWorkspaceOperatorName = "devworkspace-operator" | ||
| DevWorkspaceServiceAccountName = "devworkspace-controller-serviceaccount" | ||
| DefaultContainerBuildSccName = "container-build" | ||
| DefaultContainerRunSccName = "container-run" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tolusha, wondering if we need to create a new SCC? maybe we can simply fall back on restricted-v3 or nested-container, that are specifically designed for use with user namespaces according to the RNs - https://docs.redhat.com/en/documentation/openshift_container_platform/4.20/html-single/release_notes/index#ocp-release-notes-machine-config-operator-namespace_release-notes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I have to test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, please check, but my understanding is that for the default arbitrary / random UID is used, and we want it to be 1000 for pre-configuring /etc/subuid, /etc/subgid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I prefer to use a custom SCC that pre-determines the UID/GID of the workspace. That allows you to lock down all of the /etc files instead of having to modify them at run time.
I updated my reference if that is helpful - https://github.com/cgruver/ocp-4-20-nested-containers
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
84dcfb3 to
22e816b
Compare
|
/retest |
| // So, remove priority. See details https://issues.redhat.com/browse/CRW-3894 | ||
| scc.Priority = nil | ||
|
|
||
| if err := ctx.ClusterAPI.NonCachingClientWrapper.Sync( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, when should we use NonCachingClientWrapper or ClientWrapper?
From what I understand ClientWrapper might read from the cache for get actions, is that the only difference here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that's the only difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't cache SCC, that's why we need to use noncaching client
|
/retest |
ibuziuk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tolusha great job. Please, provide the docs and cross-link it with https://docs.redhat.com/en/documentation/openshift_container_platform/4.20/html-single/release_notes/index#ocp-release-notes-machine-config-operator-namespace_release-notes
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dkwon17, ibuziuk, mkuznyetsov, tolusha The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |

What does this PR do?
This PR enables running nested containers by leveraging Linux kernel user namespaces for isolation.
See for details: https://github.com/cgruver/ocp-4-18-nested-container-tech-preview?tab=readme-ov-file
Added configuration (with defaults values):
IMPORTANT
Previously created workspace can't be started, see eclipse-che/che#23605
Screenshot/screencast of this PR
What issues does this PR fix or reference?
https://issues.redhat.com/browse/CRW-8320
How to test this PR?
OpenShift
build/scripts/docker-run.sh /bin/bash -c "oc login --token=<...> --server=<...> --insecure-skip-tls-verify=true && build/scripts/olm/test-catalog-from-sources.sh"chectl dashboard:openOpens Start / stop a workspace
Enable container run capabilities
oc patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/devEnvironments/disableContainerRunCapabilities", "value": false}]"Start another workspace
Try podman build & podman run commands in the terminal
podman build:
podman run:
/etc/sub*idfilesPR Checklist
As the author of this Pull Request I made sure that:
What issues does this PR fix or referenceandHow to test this PRcompletedReviewers
Reviewers, please comment how you tested the PR when approving it.