Limit the number of workspaces that a user can keep

Limit the number of workspaces a user can keep in the dashboard to reduce demand on the cluster. By default, users can keep an unlimited number of workspaces.

Before you begin

Procedure

  1. Get the name of the OpenShift Dev Spaces namespace. The default is openshift-devspaces.
    $ oc get checluster --all-namespaces \
      -o=jsonpath="{.items[*].metadata.namespace}"
  2. Configure the maxNumberOfWorkspacesPerUser in the CheCluster Custom Resource:
    spec:
      devEnvironments:
        maxNumberOfWorkspacesPerUser: <kept_workspaces_limit>

    where:

    <kept_workspaces_limit>
    The maximum number of workspaces per user. The default value, -1, allows users to keep an unlimited number of workspaces. Use a positive integer to set the maximum number of workspaces per user.
  3. Apply the change:
    $ oc patch checluster/devspaces -n openshift-devspaces \
    --type='merge' -p \
    '{"spec":{"devEnvironments":{"maxNumberOfWorkspacesPerUser": <kept_workspaces_limit>}}}'

    where:

    -n
    The OpenShift Dev Spaces namespace that you got in step 1.

Results

  • Verify the maxNumberOfWorkspacesPerUser value in the CheCluster Custom Resource:
    $ oc get checluster devspaces -n openshift-devspaces -o jsonpath='{.spec.devEnvironments.maxNumberOfWorkspacesPerUser}'