Skip to main content
Version: Next 🚧

Basic Night Time Saving

One of the easiest ways and most common use cases for the Downscaler is using it for night time saving.

To achieve this configuration we will use relative timespans.

A good time to start saving resources at night could be from 6:00 PM to 8:00 AM during weekdays and on weekends. Depending on your use case you can apply the night time saving cluster-wide or on either namespace or workload level.

At the end of this guide you will also find how to manage exclusions if you want to exclude some workloads or entire namespaces from this configuration.

Cluster-Wide

In order to apply the wanted downtime cluster-wide the GoKubeDownscaler has to know what downtime to use.

This can be done by either using an environment variable or a cli argument for the GoKubeDownscaler.

If you want to add a cluster-wide downtime with environment variables you can add them inside the values.yaml file.

There you have to add it to the configMap.extraConfig field:

values.yaml
# ...

configMap:
name: go-kube-downscaler
extraConfig: |
DEFAULT_DOWNTIME: "Mon-Fri 18:00-08:00 UTC, Sat-Sun 00:00-24:00 UTC"

# ...

After setting the variable in one of the two ways all workloads in your cluster will be scaled down on every weekday from 6:00 PM to 8:00 AM and on weekends.

Namespace Level

To set this up for all workloads in a namespace you have to annotate the namespace with the wanted time span.

This can be done using a kubectl command or by editing the namespace's yaml manifest.

Adding the downtime with kubectl is a single command:

kubectl annotate ns my-namespace downscaler/downtime="Mon-Fri 18:00-08:00 UTC, Sat-Sun 00:00-24:00 UTC"

Now all workloads in my-namespace will be scaled down on every weekday from 6:00 PM to 8:00 AM and on weekends.

Workload Level

To set this up for individual workloads you have to set an annotation on each workload you want to scale down.

This can also be done by either using a kubectl command or by editing the workload's yaml manifest.

For demo purposes we will showcase this with a deployment.

Adding the downtime with kubectl is a single command:

kubectl annotate deployment my-deployment downscaler/downtime="Mon-Fri 18:00-08:00 UTC, Sat-Sun 00:00-24:00 UTC"

Now your deployment my-deployment will be scaled down on every weekday from 6:00 PM to 8:00 AM and on weekends.

Managing Exclusions

Exclusions can be made with the same granularity using environment variables, cli arguments or annotations at namespace or workload level.

If you want to add cluster-wide exclusions with environment variables you can add them inside the values.yaml file.

There you have to add it to the configMap.extraConfig field:

values.yaml
# ...

configMap:
name: go-kube-downscaler
extraConfig: |
DEFAULT_DOWNTIME: "Mon-Fri 18:00-08:00 UTC, Sat-Sun 00:00-24:00 UTC"
EXCLUDE_NAMESPACES: "^(kube-system|istio-system|karpenter|prometheus|.*prod.*)$"

# ...

info

For more information about the scaling algorithm check out the scope documentation. You will find a detailed explanation of how the GoKubeDownscaler evaluates the downtime and decides when to scale down or up workloads.