Skip to content

Commit dd0065d

Browse files
authored
feat: Nested containers (#2046)
Signed-off-by: Anatolii Bazko <[email protected]>
1 parent 678d590 commit dd0065d

38 files changed

+2799
-731
lines changed

.devfile.Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM quay.io/devfile/universal-developer-image:ubi8-latest
22

33
#install Go 1.19
4-
RUN cd /tmp && wget https://go.dev/dl/go1.19.13.linux-amd64.tar.gz && \
5-
mkdir $HOME/go1.19 && \
6-
tar -xvzf go1.19.13.linux-amd64.tar.gz -C $HOME/go1.19 --strip-components 1 && \
7-
if ! grep -q "export PATH=\$HOME/go1.19/bin:\$PATH" $HOME/.bashrc; then echo "export PATH=\$HOME/go1.19/bin:\$PATH" >> $HOME/.bashrc; fi
4+
RUN cd /tmp && wget https://go.dev/dl/go1.24.7.linux-amd64.tar.gz && \
5+
mkdir $HOME/go1.24.7 && \
6+
tar -xvzf go1.24.7.linux-amd64.tar.gz -C $HOME/go1.19 --strip-components 1 && \
7+
if ! grep -q "export PATH=\$HOME/go1.19/bin:\$PATH" $HOME/.bashrc; then echo "export PATH=\$HOME/go1.24.7/bin:\$PATH" >> $HOME/.bashrc; fi
88

99
# install chectl
1010
RUN tag=$(curl https://api.github.com/repos/che-incubator/chectl/tags | jq -r '.[0].name') && \
@@ -14,4 +14,4 @@ RUN tag=$(curl https://api.github.com/repos/che-incubator/chectl/tags | jq -r '.
1414
if ! grep -q "export PATH=\$HOME/chectl/bin:\$PATH" $HOME/.bashrc; then echo "export PATH=\$HOME/chectl/bin:\$PATH" >> $HOME/.bashrc; fi
1515

1616
# install goimports
17-
RUN $HOME/go1.19/bin/go install golang.org/x/tools/cmd/goimports@latest
17+
RUN $HOME/go1.24.7/bin/go install golang.org/x/tools/cmd/goimports@latest

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ARG SKIP_TESTS="false"
1818
USER root
1919

2020
### Start installing go
21-
ENV GO_VERSION=1.23.8
21+
ENV GO_VERSION=1.24.7
2222
ENV GOROOT=/usr/local/go
2323
ENV PATH=$PATH:$GOROOT/bin
2424
RUN dnf install unzip gcc -y

api/v2/checluster_types.go

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"strconv"
2020
"strings"
2121

22+
"k8s.io/utils/pointer"
23+
2224
ctrl "sigs.k8s.io/controller-runtime"
2325

2426
defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults"
@@ -45,7 +47,7 @@ type CheClusterSpec struct {
4547
// +optional
4648
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=1
4749
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Development environments"
48-
// +kubebuilder:default:={storage: {pvcStrategy: per-user}, defaultNamespace: {template: <username>-che, autoProvision: true}, secondsOfInactivityBeforeIdling:1800, secondsOfRunBeforeIdling:-1, startTimeoutSeconds:300, maxNumberOfWorkspacesPerUser:-1}
50+
// +kubebuilder:default:={storage: {pvcStrategy: per-user}, defaultNamespace: {template: <username>-che, autoProvision: true}, secondsOfInactivityBeforeIdling:1800, secondsOfRunBeforeIdling:-1, startTimeoutSeconds:300, maxNumberOfWorkspacesPerUser:-1, disableContainerRunCapabilities:true}
4951
DevEnvironments CheClusterDevEnvironments `json:"devEnvironments"`
5052
// Che components configuration.
5153
// +optional
@@ -149,12 +151,23 @@ type CheClusterDevEnvironments struct {
149151
//
150152
// +optional
151153
DisableContainerBuildCapabilities *bool `json:"disableContainerBuildCapabilities,omitempty"`
154+
// Disables container run capabilities.
155+
// Can be enabled on OpenShift version 4.20 or later.
156+
// When set to `false`, the value from `devEnvironments.security.containerSecurityContext`
157+
// is ignored, and instead the SecurityContext defined in
158+
// `devEnvironments.containerRunConfiguration.containerSecurityContext` is applied.
159+
// +optional
160+
// +kubebuilder:default:=true
161+
DisableContainerRunCapabilities *bool `json:"disableContainerRunCapabilities,omitempty"`
152162
// Workspace security configuration.
153163
// +optional
154164
Security WorkspaceSecurityConfig `json:"security,omitempty"`
155165
// Container build configuration.
156166
// +optional
157167
ContainerBuildConfiguration *ContainerBuildConfiguration `json:"containerBuildConfiguration,omitempty"`
168+
// Container run configuration.
169+
// +optional
170+
ContainerRunConfiguration *ContainerRunConfiguration `json:"containerRunConfiguration,omitempty"`
158171
// ServiceAccount to use by the DevWorkspace operator when starting the workspaces.
159172
// +optional
160173
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
@@ -559,9 +572,10 @@ type WorkspaceSecurityConfig struct {
559572
// If set, defined values are merged into the default PodSecurityContext configuration.
560573
// +optional
561574
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
562-
// Container SecurityContext used by all workspace-related containers.
563-
// If set, defined values are merged into the default Container SecurityContext configuration.
564-
// Requires devEnvironments.disableContainerBuildCapabilities to be set to `true` in order to take effect.
575+
// Defines the SecurityContext applied to all workspace-related containers.
576+
// When set, the specified values are merged with the default SecurityContext configuration.
577+
// This setting takes effect only if both `devEnvironments.disableContainerBuildCapabilities`
578+
// and `devEnvironments.disableContainerRunCapabilities` are set to `true`.
565579
// +optional
566580
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
567581
}
@@ -873,6 +887,26 @@ type ContainerBuildConfiguration struct {
873887
OpenShiftSecurityContextConstraint string `json:"openShiftSecurityContextConstraint,omitempty"`
874888
}
875889

890+
type ContainerRunConfiguration struct {
891+
// Specifies the OpenShift SecurityContextConstraint used to run containers.
892+
// +kubebuilder:validation:Required
893+
// +kubebuilder:default:=container-run
894+
OpenShiftSecurityContextConstraint string `json:"openShiftSecurityContextConstraint,omitempty"`
895+
// Extra annotations applied to all workspace pods, in addition to those defined
896+
// in `devEnvironments.workspacePodAnnotations`. Enables `/dev/fuse` for access to the fuse driver
897+
// and `/dev/net/tun` for safe network access.
898+
// +optional
899+
// +kubebuilder:default:={"io.kubernetes.cri-o.Devices": "/dev/fuse,/dev/net/tun"}
900+
WorkspacesPodAnnotations map[string]string `json:"workspacesPodAnnotations,omitempty"`
901+
// SecurityContext applied to all workspace containers when run capabilities are enabled.
902+
// The default `procMount: "Unmasked"` is set because the pod runs in a user namespace,
903+
// which safely isolates the container's `/proc` from the host. This allows the container
904+
// to modify its own sysctl settings for configuring networking for nested containers.
905+
// +optional
906+
// +kubebuilder:default:={procMount: "Unmasked", allowPrivilegeEscalation: true, capabilities: {add: {"SETGID", "SETUID"}}}
907+
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
908+
}
909+
876910
// Configuration for Traefik within the Che gateway pod.
877911
type Traefik struct {
878912
// The log level for the Traefik container within the gateway pod: `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`, or `PANIC`. The default value is `INFO`
@@ -1068,6 +1102,10 @@ func (c *CheCluster) IsAccessTokenConfigured() bool {
10681102
return c.GetIdentityToken() == constants.AccessToken
10691103
}
10701104

1105+
func (c *CheCluster) IsContainerRunCapabilitiesEnabled() bool {
1106+
return !pointer.BoolDeref(c.Spec.DevEnvironments.DisableContainerRunCapabilities, constants.DefaultDisableContainerRunCapabilities)
1107+
}
1108+
10711109
// IsContainerBuildCapabilitiesEnabled returns true if container build capabilities are enabled.
10721110
// If value is not set in the CheCluster CR, then the default value is used.
10731111
func (c *CheCluster) IsContainerBuildCapabilitiesEnabled() bool {
@@ -1084,10 +1122,6 @@ func (c *CheCluster) IsContainerBuildCapabilitiesEnabled() bool {
10841122
return !disableContainerBuildCapabilitiesParsed
10851123
}
10861124

1087-
func (c *CheCluster) IsOpenShiftSecurityContextConstraintSet() bool {
1088-
return c.Spec.DevEnvironments.ContainerBuildConfiguration != nil && c.Spec.DevEnvironments.ContainerBuildConfiguration.OpenShiftSecurityContextConstraint != ""
1089-
}
1090-
10911125
func (c *CheCluster) IsCheFlavor() bool {
10921126
return defaults.GetCheFlavor() == constants.CheFlavor
10931127
}

api/v2/checluster_webhook.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,37 @@ func (r *CheClusterDefaulter) Default(_ context.Context, obj runtime.Object) err
6767

6868
webhookLogger.Info("Defaulting for CheCluster", "name", cheCluster.GetName())
6969

70-
r.setContainerBuildConfiguration(cheCluster)
70+
r.setDisableContainerRunCapabilities(cheCluster)
71+
r.setContainerRunConfiguration(cheCluster)
72+
7173
r.setDisableContainerBuildCapabilities(cheCluster)
74+
r.setContainerBuildConfiguration(cheCluster)
75+
7276
return nil
7377
}
7478

7579
func (r *CheClusterDefaulter) setDisableContainerBuildCapabilities(cheCluster *CheCluster) {
76-
// Container build capabilities can be enabled on OpenShift only
7780
if !infrastructure.IsOpenShift() {
7881
cheCluster.Spec.DevEnvironments.DisableContainerBuildCapabilities = pointer.Bool(true)
7982
}
8083
}
8184

82-
// Sets ContainerBuildConfiguration if container build capabilities is enabled.
85+
func (r *CheClusterDefaulter) setDisableContainerRunCapabilities(cheCluster *CheCluster) {
86+
if !infrastructure.IsOpenShift() {
87+
cheCluster.Spec.DevEnvironments.DisableContainerRunCapabilities = pointer.Bool(true)
88+
}
89+
}
90+
91+
// Sets ContainerRunConfiguration if container run capabilities is enabled.
92+
// The defaults will be propagated from the CheCluster CRD
93+
func (r *CheClusterDefaulter) setContainerRunConfiguration(cheCluster *CheCluster) {
94+
if cheCluster.IsContainerRunCapabilitiesEnabled() && cheCluster.Spec.DevEnvironments.ContainerRunConfiguration == nil {
95+
cheCluster.Spec.DevEnvironments.ContainerRunConfiguration = &ContainerRunConfiguration{}
96+
}
97+
}
98+
99+
// Sets ContainerBuildConfiguration if container run capabilities is enabled.
100+
// The defaults will be propagated from the CheCluster CRD
83101
func (r *CheClusterDefaulter) setContainerBuildConfiguration(cheCluster *CheCluster) {
84102
if cheCluster.IsContainerBuildCapabilitiesEnabled() && cheCluster.Spec.DevEnvironments.ContainerBuildConfiguration == nil {
85103
cheCluster.Spec.DevEnvironments.ContainerBuildConfiguration = &ContainerBuildConfiguration{}

api/v2/zz_generated.deepcopy.go

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/scripts/docker-run.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ init() {
2929
build() {
3030
printf "%bBuilding image %b${IMAGE_NAME}${NC}..." "${BOLD}" "${BLUE}"
3131
if docker build -t ${IMAGE_NAME} > docker-build-log 2>&1 -<<EOF
32-
FROM golang:1.23-bookworm
32+
FROM docker.io/golang:1.24-bookworm
3333
RUN apt update && apt install python3-pip skopeo jq rsync unzip -y && \
3434
pip install --break-system-packages yq && \
3535
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
3636
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \
3737
go install golang.org/x/tools/cmd/goimports@latest && \
3838
rm -rf /che-operator/bin
39+
RUN wget https://github.com/okd-project/okd/releases/download/4.19.0-okd-scos.7/openshift-client-linux-4.19.0-okd-scos.7.tar.gz && \
40+
tar -xvf openshift-client-linux-4.19.0-okd-scos.7.tar.gz && \
41+
mv oc /usr/local/bin/
3942
RUN adduser --disabled-password --gecos "" user
4043
ENV GO111MODULE=on
4144
ENV GOPATH=/home/user/go

bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ metadata:
8686
categories: Developer Tools
8787
certified: "false"
8888
containerImage: quay.io/eclipse/che-operator:next
89-
createdAt: "2025-10-14T09:17:53Z"
89+
createdAt: "2025-10-23T08:53:01Z"
9090
description: A Kube-native development solution that delivers portable and collaborative
9191
developer workspaces.
9292
features.operators.openshift.io/cnf: "false"
@@ -108,7 +108,7 @@ metadata:
108108
operatorframework.io/arch.amd64: supported
109109
operatorframework.io/arch.arm64: supported
110110
operatorframework.io/os.linux: supported
111-
name: eclipse-che.v7.111.0-947.next
111+
name: eclipse-che.v7.111.0-948.next
112112
namespace: placeholder
113113
spec:
114114
apiservicedefinitions: {}
@@ -1141,7 +1141,7 @@ spec:
11411141
name: gateway-authorization-sidecar-k8s
11421142
- image: quay.io/che-incubator/header-rewrite-proxy:latest
11431143
name: gateway-header-sidecar
1144-
version: 7.111.0-947.next
1144+
version: 7.111.0-948.next
11451145
webhookdefinitions:
11461146
- admissionReviewVersions:
11471147
- v1

0 commit comments

Comments
 (0)