CLI Scope
The CLI Scope is the third type of scope available. It overrides the Default Scope and ENV Scope but it can be overridden by the Namespace Scope or Workload Scope. It is used to set values and runtime configurations
Values
At CLI Scope, the following values can be configured using arguments to apply global scaling policies across targeted resources. These global settings can be overridden by more specific scopes in the hierarchy.
- --upscale-period
- --default-uptime
- --downscale-period
- --default-downtime
- --force-downtime
- --force-uptime
- --downtime-replicas
- --grace-period
- --explicit-include
- --scale-children
--explicit-include
will set the exclude value to true
on the cli scope.
This will exclude every workload unless more specific scopes (e.g.: namespace scope,
workload scope) specify exclude to false
.
The values set by the cli arguments will take precedence over their respective environment variables if they are both set.
Runtime Configuration
At the CLI Scope, the following runtime configurations can be configured using arguments to set and control various behavioral aspects of the Downscaler (e.g. scan interval, retries, debug mode, ...)
- --dry-run
- --debug
- --once
- --interval
- --namespace
- --include-resources
- --exclude-namespaces
- --exclude-deployments
- --matching-labels
- --deployment-time-annotation
- --leader-election
- --max-retries-on-conflict
- -k (kubeconfig)
The runtime configurations set by the cli arguments will take precedence over their respective environment variables if they are both set.
Usage
The CLI arguments can be set in different ways, depending on your setup. You can find some examples below
The value of a boolean cli flags can be omitted. This will set its value to true.
Via Helm Chart values.yaml
Some arguments already have predefined fields inside the values.yaml file to make configuring them easier. Here is a list containing all the fields that configure their respective cli arguments:
includedResources
directly sets--include-resources
constrainedNamespaces
directly sets--namespace
All other arguments can be used via the arguments
field.
# ...
arguments:
- --interval 2m
- --downscale-period "Sat-Sun 00:00-24:00 Europe/Paris"
- --include-resources=deployments,jobs,scaledobjects,cronjobs
# ...
Via Deployment
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 CLI Scope inside the args section of the go-kube-downscaler
container in the deployment.
# ...
containers:
- name: go-kube-downscaler
image: "ghcr.io/caas-team/gokubedownscaler"
imagePullPolicy: Always
args:
- --include-resources=deployments,jobs,scaledobjects,cronjobs
- --exclude-deployments=my-deployment
- --max-retries-on-conflict=3
- --downtime-replicas=2
- --debug
# ...
Binary or Go Run
# go build cmd/kubedownscaler -o kubedownscaler
kubedownscaler --dry-run --namespace=my-namespace
go run cmd/kubedownscaler --explicit-include=true --interval 60s --exclude-namespaces "kube-.*"