Skip to main content

Env Scope

The Env Scope is the second type of scope available. It overrides the Default Scope, but it can be overridden by the CLI Scope, Namespace Scope or Workload Scope It is used to set values and runtime configurations

Values

At the environment scope, the following environment variable values can be configured to apply global scaling policies across targeted resources. These global settings can be overridden by more specific scopes in the hierarchy.

Runtime Configuration

At the environment scope, the following environment variable runtime configurations are used to control which namespaces or workloads should be excluded from scaling policies.

note

The runtime configuration set at the CLI Scope will take precedence over their respective environment variables if they are both set.

info

EXCLUDE_DEPLOYMENTS, despite its name, is not limited to target deployments. This variable can be used to exclude any workload type

Usage

The Env Scope can be set in different ways, depending on your setup. You can find some examples below

Via Helm Chart values.yaml

You can set the Env Scope in the Helm Chart by using the configMap.extraConfig field.

values.yaml
# ...

configMap:
name: go-kube-downscaler
extraConfig: |
DEFAULT_DOWNTIME: "Mon-Fri 20:00-08:00 Asia/Tokyo, Sat-Sun 00:00-24:00 Asia/Tokyo"
EXCLUDE_NAMESPACES: "my-namespace, example-.*"
EXCLUDE_DEPLOYMENTS: "my-deployment"

# ...
warning

By default these config changes apply automatically.

However, if you set forceRestartOnConfigChange to false, you will need to restart the Downscaler pods manually.

Via ConfigMap

If you are not working directly with Helm but rather with a raw Kubernetes manifest generated using the Helm Template command, you can set the Env Scope inside the used ConfigMap

ConfigMap
apiVersion: v1
data:
DEFAULT_UPTIME: "Mon-Fri 10:00-19:00 Europe/Rome"
EXCLUDE_NAMESPACES: "kube-downscaler,kube-system,default"
EXCLUDE_DEPLOYMENTS: "my-deployment"
kind: ConfigMap
metadata:
name: go-kube-downscaler
namespace: go-kube-downscaler
warning

After the first installation, each time you want to change the ConfigMaps environment variables you need to restart the Downscaler pods, otherwise the changes will not be applied.

Binary or Go Run

If you are using the Downscaler outside a Kubernetes cluster, environment variables can be written in a .env file and then applied to the environment variables of the current shell by running the command dotenv

.env
DEFAULT_UPTIME: "Mon-Fri 08:00-20:00 Pacific/Fiji"
EXCLUDE_DEPLOYMENTS: "my-deployment, example-.*"