Control which nodes run workspaces

Control which nodes run OpenShift Dev Spaces workspace Pods by setting nodeSelector and tolerations for compliance, hardware affinity, or zone isolation.

Before you begin

Procedure

  1. Set nodeSelector in the CheCluster Custom Resource to schedule workspace Pods on specific nodes:
    spec:
      devEnvironments:
        nodeSelector:
          <key>: <value>

    This section must contain a set of key=value pairs for each node label to form the nodeSelector rule.

  2. Set tolerations in the CheCluster Custom Resource to allow workspace Pods to be scheduled on tainted nodes. Tolerations work in the opposite way to nodeSelector. Instead of specifying which nodes the Pod is scheduled on, you specify which nodes the Pod cannot be scheduled on.
    spec:
      devEnvironments:
        tolerations:
          - effect: NoSchedule
            key: <key>
            value: <value>
            operator: Equal
    Important:

    nodeSelector must be configured during OpenShift Dev Spaces installation. This prevents existing workspaces from failing to run due to volumes affinity conflict caused by existing workspace PVC and Pod being scheduled in different zones.

    On large, multizone clusters, Pods and PVCs can be scheduled in different zones. To avoid this, create an additional StorageClass object (pay attention to the allowedTopologies field) to coordinate the PVC creation process.

    Pass the name of this newly created StorageClass to OpenShift Dev Spaces through the CheCluster Custom Resource.

Results

  • Verify the nodeSelector or tolerations configuration in the CheCluster Custom Resource:
    oc get checluster devspaces -n openshift-devspaces -o jsonpath='{.spec.devEnvironments.nodeSelector}'