Chapter 5. Configure autoscaling


Configure autoscaling for OpenShift Dev Spaces container replicas and for cluster nodes running workspaces.

Define a Kubernetes HorizontalPodAutoscaler (HPA) resource for OpenShift Dev Spaces operands to ensure high availability and handle varying workloads. The HPA dynamically adjusts the number of replicas based on specified metrics.

Prerequisites

Procedure

  1. Create an HPA resource for a deployment, specifying the target metrics and desired replica count.

    apiVersion: autoscaling/v2
    kind: HorizontalPodAutoscaler
    metadata:
      name: scaler
      namespace: openshift-devspaces
    spec:
      scaleTargetRef:
        apiVersion: apps/v1
        kind: Deployment
        name: <deployment_name>
      ...

    where:

    <deployment_name>

    One of the following deployments:

    • devspaces
    • che-gateway
    • devspaces-dashboard
    • plugin-registry
    • devfile-registry

      For example:

      apiVersion: autoscaling/v2
      kind: HorizontalPodAutoscaler
      metadata:
        name: devspaces-scaler
        namespace: openshift-devspaces
      spec:
        scaleTargetRef:
          apiVersion: apps/v1
          kind: Deployment
          name: devspaces
        minReplicas: 2
        maxReplicas: 5
        metrics:
          - type: Resource
            resource:
              name: cpu
              target:
                type: Utilization
                averageUtilization: 75

      In this example, the HPA targets the devspaces deployment with a minimum of 2 replicas, a maximum of 5 replicas, and scales based on CPU utilization.

Verification

  • Verify that the HPA resource is created and targeting the correct deployment:

    oc get hpa -n openshift-devspaces

5.2. Configure machine autoscaling

Configure OpenShift Dev Spaces startup timeouts and pod annotations to work with the cluster autoscaler, preventing workspace disruptions when nodes are added or removed.

When the autoscaler adds a new node, workspace startup can take longer than usual until node provisioning is complete. When the autoscaler removes a node, workspace pods should not be evicted because eviction can cause interruptions and loss of unsaved data.

Prerequisites

  • You have an active oc session with administrative permissions to the destination OpenShift cluster. See Getting started with the CLI.
  • You have the cluster autoscaler enabled on the OpenShift cluster.

Procedure

  1. Set the startup timeout and event handling in the CheCluster Custom Resource to handle autoscaler node additions:

    spec:
      devEnvironments:
        startTimeoutSeconds: 600
        ignoredUnrecoverableEvents:
          - FailedScheduling

    where:

    startTimeoutSeconds
    Set to at least 600 seconds to allow time for a new node to be provisioned during workspace startup.
    ignoredUnrecoverableEvents
    Ignore the FailedScheduling event to allow workspace startup to continue when a new node is provisioned. This setting is enabled by default.
  2. Add the safe-to-evict annotation to the CheCluster Custom Resource to prevent workspace pod eviction when the autoscaler removes a node:

    spec:
      devEnvironments:
        workspacesPodAnnotations:
          cluster-autoscaler.kubernetes.io/safe-to-evict: "false"

Verification

  • Start a workspace and verify that the workspace pod contains the cluster-autoscaler.kubernetes.io/safe-to-evict: "false" annotation:

    $ oc get pod <workspace_pod_name> -o jsonpath='{.metadata.annotations.cluster-autoscaler\.kubernetes\.io/safe-to-evict}'
    false
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top