Skip to main content

Scopes And Scaling

Scopes

Scopes are levels that hold behavioral and scaling configurations. These configurations can be divided into two categories:

  • Runtime Configurations: define how the Downscaler itself operates, controlling aspects like which namespaces and workload types it should target, frequency of scans, retries, whether debugging information is enabled and more. Runtime Configurations do not dictate how and when individual workloads are scaled.
  • Values: define the scaling behavior of targeted workloads, specifying how and when they should be scaled up or down.

Available Scopes

The scopes are organized in a hierarchy, with each scope having its own set of configurations. The available scopes are:

  • Default Scope: contains only the default values.
  • Env Scope: contains the values and runtime configurations set by the environment variables.
  • CLI Scope: contains the values and runtime configurations set by the CLI arguments.
  • Namespace Scope: contains only the values set by the annotations on the namespace.
  • Workload Scope: contains only the values set by the annotations on the workload.

The hierarchy of scopes is important because it determines which configurations take precedence when a particular configuration is defined in multiple scopes. It can be visualized as pyramid, with the Default Scope at the bottom and the Workload Scope at the top. Each scope can override the configurations of the scopes below it in the hierarchy.

Scaling Algorithm

The scaling algorithm uses the values set in the scopes to determine how and when to scale workloads. The resulting value is always the one set by the most specific scope that has set that value.

This means, as specified before, that Workload Scope > Namespace Scope > CLI Scope > ENV Scope > Default Scope.

When computing scopes, exclusion values always take precedence, meaning that: no matter what the scaling values are across any other scope, if a scope contains an exclusion the result will be an exclusion.

The diagram below illustrates how scaling is determined for a workload:

Cells ending with:

  • × are not taken into account
  • « are the cell the value was taken from
  • ↑ are empty and are not taken into account
ExcludeDowntimeReplicas
Defaultfalse ×- ×0 «
Environment- ×Mon-Fri 8-20 ×- ↑
CLI- ×- ×- ↑
Namespacetrue «- ×- ↑
Workload- ↑Sat-Sun 0-24 «- ↑
ResulttrueSat-Sun 0-240
Reading the Diagram

In the diagram above the downtime period is taken from the workload scope, however the resource will be excluded since the namespace Scope has the exclude value set to true.