Skip to main content
Version: 1.27

Garbage Collector

The Okteto Garbage Collector (GC) allows Admins to optimize infrastructure usage by automatically scaling down or deleting inactive Namespaces and Preview Environments, helping control costs and improve resource efficiency.

Enabling the Garbage Collector

The Garbage Collector is enabled by default in Okteto installations. If your GC has been disabled, navigate to Admin → Garbage Collector and flip the toggle to "Enabled" to begin using it. Once enabled, the GC automatically scales idle environments to zero and deletes unused Namespaces and Preview Environments based on your configured settings.

Configuring the Sleep and Delete Periods

Admins can set custom sleep and delete periods for both Namespaces and Preview Environments:

  • Sleep Period: The amount of time, in hours, that an environment must remain idle before the GC scales it down to zero
  • Delete Period: The number of days an environment must stay in a sleeping state before the GC permanently deletes it

Default Values:

  • Namespaces

    • Sleep period: 3h
    • Delete period: 14 days
  • Preview Environments

    • Sleep period: 1h
    • Delete period: 7 days

wake a sleeping resource

Manually Sleeping Resources

The Okteto Garbage Collector automatically scales inactive applications to zero if they haven't been used for longer than the sleep period set to automatically save resources in your cluster.

Additionally, Namespaces can be manually scaled to zero by navigating to Admin -> Namespaces and clicking on the three dots on the right side of the Namespace that you wish to sleep.

wake a sleeping resource

Inactive Applications and Resources

Okteto considers an application inactive if a user hasn't performed any of the following tasks during the sleep period. The following events are considered activity that will prevent an application from being marked as inactive or will wake a sleeping namespace:

  • Deploying a Kubernetes Deployment or StatefulSet with kubectl or similar tools
  • Running okteto deploy
  • Running okteto up
  • Maintaining an active okteto up session. If the upSessionByLastSyncedFile setting is enabled, this only counts if files are actively being synced (based on the last synced file)
  • Upgrade or redeploy via the UI or the command line

Service accounts, config maps, secrets, or volumes you create will be unaffected by the sleep operation.

Additionally, if you are using the Okteto Nginx Ingress Controller, incoming requests will automatically wake a sleeping namespace. However, note that these incoming requests do not count as activity to reset the inactivity counter and keep the namespace awake. The auto-wake behavior for incoming requests can also be disabled by configuring the autowake field.

Manually Wake Sleeping Resources

Okteto's UI will notify you when there are sleeping applications in your namespace. Press the Wake all button to activate all sleeping resources at once.

wake a sleeping resource

Delete Unused Namespaces

Namespaces and all the resources and data contained within will be deleted if they stay sleeping for longer than the delete period.

This only affects Non-Personal Namespaces, Personal Namespaces are not automatically deleted when idle.

Persistent resources
ScaleEnterpriseSelf-Hosted

In case you are interested in the Garbage Collector but you want to skip a specific Namespace, you can mark it as persistent. To do so, you can add the label dev.okteto.com/persistent to it or use the admin view.

In case you want more granularity and only want to persist specific deployments or statefulsets within a Namespace, you can include the label dev.okteto.com/persistent on those resources. In that case, the Garbage Collector will ignore only those specific resources while sleeping the rest of the Namespace.

Helm Configuration Steps
ScaleEnterpriseSelf-Hosted

You can set the sleep and delete periods in the Admin Dashboard following the instructions above.

If you are using Okteto Self-Hosted, you can also configure this in the Helm Chart along with options like a Slack webhook for notifications when resources are scaled to zero.