Configure automatic cleanup of inactive workspaces

For large Kubernetes deployments, particularly those involving a high number of custom resources such as DevWorkspace objects, which represent CDEs, etcd can become a significant performance bottleneck. Configure the DevWorkspace Operator pruner to automatically delete workspaces that have not been started within a configurable retention period.

Based on the load testing for 6,000 DevWorkspace objects, storage consumption for etcd was approximately 2.5GB.

Prerequisites
  • An active kubectl session with administrative permissions to the destination Kubernetes cluster. See Overview of kubectl.

  • DevWorkspace Operator version 0.34.0 or later is installed on the cluster.

Procedure
  1. Configure the DevWorkspaceOperatorConfig object to enable the cleanup cron job:

    apiVersion: controller.devfile.io/v1alpha1
    kind: DevWorkspaceOperatorConfig
    metadata:
      name: devworkspace-operator-config
      namespace: eclipse-che
    config:
      workspace:
        cleanupCronJob:
          enabled: true
          dryRun: false
          retainTime: 2592000
          schedule: "0 0 1 * *"
    retainTime

    The number of seconds a workspace must be inactive before it is marked for deletion. The default value 2592000 equals 30 days.

    schedule

    A cron expression that defines how often the pruner runs. The default value "0 0 1 * *" runs the pruner once per month.

  2. Optional: To preview which workspaces would be deleted without removing them, set dryRun to true.

Verification
  • Verify that the cleanup cron job is scheduled:

    $ kubectl get cronjobs -n eclipse-che