Turn on autoscaling
Let the cluster autoscaler grow a node group when pods cannot be scheduled and shrink it when nodes are underused, and tune it for the whole cluster.
Replace my-cluster with your cluster's name or id, and workers with the node group's name.
With autoscaling on, the cluster autoscaler changes the group's desiredSize between minSize and
maxSize: pods that cannot be scheduled for lack of room grow the group, and underused nodes are
drained and removed. Each change appears in Activity.
Prerequisites
- Permission for
eks:UpdateNodegroupConfig(oreks:CreateNodegroupfor a new group); for the cluster-wide settings,eks:UpdateClusterConfig. - In the console, also
eks:DescribeClusterandeks:ListNodegroups.
Turn it on for a node group
- Open Kubernetes, open the cluster, then choose Node groups.
- On the node group's row, choose Edit.
- Turn on Autoscaling, and set Minimum and Maximum.
- Choose Save.
dcloud eks nodegroups update my-cluster workers --autoscaling --min-size 1 --max-size 10PATCH /eks/api/clusters/my-cluster/nodegroups/workers
{ "autoscaling": true, "minSize": 1, "maxSize": 10 }resource "dcloud_eks_nodegroup" "workers" {
cluster_id = dcloud_eks_cluster.main.id
name = "workers"
instance_type = "performance-4"
min_size = 1
desired_size = 2
max_size = 10
autoscaling = true
lifecycle {
ignore_changes = [desired_size]
}
}ignore_changes keeps an apply from undoing what the autoscaler set.
A node group created together with its cluster starts with autoscaling off; turn it on this way.
Tune the autoscaler for the cluster
Three settings apply to every node group of the cluster that has autoscaling on:
| Setting | Default | Range | Meaning |
|---|---|---|---|
scaleDownUtilizationThreshold |
0.5 |
0.1–0.9 | A node whose pods request less than this share of CPU and memory may go. |
scaleDownUnneededMinutes |
10 |
1–120 | How long a node must be unneeded before it goes. |
expander |
least-waste |
least-waste, random, most-pods |
Which group grows when several could. |
Not available in Console. The console does not show or change the autoscaler's settings.
dcloud eks clusters update my-cluster \
--autoscaler '{"scaleDownUtilizationThreshold":0.6,"scaleDownUnneededMinutes":15}'PATCH /eks/api/clusters/my-cluster
{ "autoscaler": { "scaleDownUtilizationThreshold": 0.6, "scaleDownUnneededMinutes": 15 } }Set autoscaler on the dcloud_eks_cluster (a JSON string, for example
jsonencode({ scaleDownUtilizationThreshold = 0.6 })) and apply.
Settings you leave out keep their current value.