Skip to content

Conversation

@tolusha
Copy link
Contributor

@tolusha tolusha commented Aug 21, 2025

What does this PR do?

Add hostUsers field to DWOC

What issues does this PR fix or reference?

#1492

Is it tested? How?

OpenShift

  1. Enable UserNamespacesSupport feature on the cluster
oc patch FeatureGate cluster --type merge --patch '{"spec":{"featureSet":"CustomNoUpgrade","customNoUpgrade":{"enabled":["UserNamespacesSupport", "UserNamespacesPodSecurityStandards"]}}}'

Wait for a while (sleep 15m)

  1. Deploy DWO
oc create namespace devworkspace-controller
sed 's#quay.io/devfile/devworkspace-controller:next#quay.io/abazko/devworkspace-controller:1492#g' deploy/deployment/openshift/combined.yaml | oc apply -f -
  1. Create DWOC
oc apply -f - <<EOF
apiVersion: controller.devfile.io/v1alpha1
kind: DevWorkspaceOperatorConfig
metadata:
  name: devworkspace-operator-config
  namespace: devworkspace-controller
config:
  workspace:
    hostUsers: false
    podSecurityContext:
      runAsGroup: 1001  # 65536 is a max id inside a user namespace
      runAsUser: 1001    # 65536 is a max id inside a user namespace
    serviceAccount:
      serviceAccountName: user-sa
EOF
  1. Create SCC
oc apply -f - <<EOF
apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata:
  name: user-namespace
priority: null
allowPrivilegeEscalation: true
fsGroup:          
  type: MustRunAs     
  ranges:          
  - min: 1000             
    max: 65534
runAsUser:       
  type: MustRunAsRange                                                                     
  uidRangeMin: 1000
  uidRangeMax: 65534 
seLinuxContext:              
  type: MustRunAs     
  seLinuxOptions:                      
    type: container_engine_t
supplementalGroups:
  type: MustRunAs
  ranges:
  - min: 1000
    max: 65534                
userNamespaceLevel: RequirePodLevel
EOF
  1. Create a user namespace
oc create namespace test
  1. Create RBAC
oc create role user-sa-scc --verb=use --resource=scc --resource-name=user-namespace -n test
oc create rolebinding user-sa-scc --role=user-sa-scc --serviceaccount=test:user-sa --namespace=test

oc create clusterrole dw-scc --verb=use,get,update --resource=scc --resource-name=user-namespace 
oc create clusterrolebinding dw-scc --clusterrole=dw-scc --serviceaccount=devworkspace-controller:devworkspace-controller-serviceaccount
  1. Create DW
oc apply -f - <<EOF
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
  name: test
  namespace: test
spec:
  started: true
  template:
    attributes:
      controller.devfile.io/storage-type: ephemeral
    components:
      - name: tooling-container
        container:
          image: quay.io/devfile/universal-developer-image:ubi9-latest
          cpuLimit: 100m
          cpuRequest: 100m
EOF
  1. Check that pod is up and running
  2. Check hostUsers field
% oc get pod -n test -o yaml -o jsonpath="{.items[0].spec.hostUsers}"
false
  1. Stop DW
oc patch devworkspace test --type merge --patch '{"spec":{"started":false}}' -n test
  1. Update DWOC
oc replace -f - <<EOF
apiVersion: controller.devfile.io/v1alpha1
kind: DevWorkspaceOperatorConfig
metadata:
  name: devworkspace-operator-config
  namespace: devworkspace-controller
config:
  workspace:
    hostUsers: true
    serviceAccount:
      serviceAccountName: user-sa
EOF
  1. Start DW
oc patch devworkspace test --type merge --patch '{"spec":{"started":true}}' -n test
  1. Check hostUsers field
% oc get pod -n test -o yaml -o jsonpath="{.items[0].spec.hostUsers}"
true

PR Checklist

  • E2E tests pass (when PR is ready, comment /test v8-devworkspace-operator-e2e, v8-che-happy-path to trigger)
    • v8-devworkspace-operator-e2e: DevWorkspace e2e test
    • v8-che-happy-path: Happy path for verification integration with Che

@openshift-ci
Copy link

openshift-ci bot commented Aug 21, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added lgtm and removed lgtm labels Aug 21, 2025
@tolusha tolusha marked this pull request as ready for review August 26, 2025 11:18
@tolusha tolusha requested a review from rohanKanojia August 26, 2025 11:18
Copy link
Collaborator

@dkwon17 dkwon17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a small comment

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
@openshift-ci
Copy link

openshift-ci bot commented Aug 27, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: akurinnoy, rohanKanojia, tolusha
Once this PR has been reviewed and has the lgtm label, please assign dkwon17 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tolusha tolusha merged commit 6f01ac3 into main Aug 27, 2025
11 checks passed
@tolusha tolusha deleted the 1492 branch August 27, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants