Configuring the cluster autoscaler

Bases de conocimiento

Configuring the cluster autoscaler


Icons/System/eye-open Created with Sketch. 271 visualizaciones 17.05.2022 Cloud / Managed Kubernetes Service

Objective

OVHcloud Managed Kubernetes service provides you Kubernetes clusters without the hassle of installing or operating them.

During the day-to-day life of your cluster, you may want to dynamically adjust the size of your cluster to accommodate to your workloads. The cluster autoscaler simplifies the task by scaling up or down your OVHcloud Managed Kubernetes cluster to meet the demand of your workloads.

This guide follows up the Using the cluster autoscaler guide, and it will cover a description of the cluster autoscaler configuration.

Requirements

Instructions

Cluster autoscaler configuration

When the autoscaler is enabled on a node pool, it uses a default configuration.

Here you have a description of the parameters used in the autoscaler configuration, and their default value:

SettingDescriptionDefault value
scan-intervalHow often cluster is reevaluated for scale up or down10 seconds
scale-down-delay-after-addHow long after scale up that scale down evaluation resumes10 minutes
scale-down-delay-after-deleteHow long after node deletion that scale down evaluation resumesscan-interval
scale-down-delay-after-failureHow long after scale down failure that scale down evaluation resumes3 minutes
scale-down-unneeded-timeHow long a node should be unneeded before it is eligible for scale down10 minutes
scale-down-unready-timeHow long an unready node should be unneeded before it is eligible for scale down20 minutes
scale-down-utilization-thresholdNode utilization level, defined as sum of requested resources divided by capacity, below which a node can be considered for scale down0.5
max-graceful-termination-secMaximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node600 seconds
balance-similar-node-groupsDetects node pools with the same instance type and the same set of labels and balances the number of nodes between themfalse
expanderType of node pool expander to be used in scale up. Possible values: most-pods, random, least-waste, priorityrandom
skip-nodes-with-local-storageIf true cluster autoscaler will never delete nodes with pods with local storage, for example, EmptyDir or HostPathfalse
skip-nodes-with-system-podsIf true cluster autoscaler will never delete nodes with pods from kube-system (except for DaemonSet or mirror pods)false
max-empty-bulk-deleteMaximum number of empty nodes that can be deleted at the same time10 nodes
new-pod-scale-up-delayFor scenarios like burst/batch scale where you don't want the cluster autoscaler to act before the kubernetes scheduler could schedule all the pods, you can tell the CA to ignore unscheduled pods before they're a certain age.0 seconds
max-total-unready-percentageMaximum percentage of unready nodes in the cluster. After this percentage is exceeded, the CA halts operations45%
max-node-provision-timeMaximum time the autoscaler waits for a node to be provisioned15 minutes
ok-total-unready-countNumber of allowed unready nodes, irrespective of max-total-unready-percentage3 node

You can get more information on those parameters on the Kubernetes autoscaler documentation.

If you consider we should reevaluate the default value and/or prioritize the possible customization of one of those parameters, you are welcome to create an issue on our Public roadmap.

Configuring the autoscaler

The easiest way to enable the autoscaler is using the Kubernetes API, for example using kubectl.

Using Kubernetes API

When the autoscaler is enabled on a node pool, it uses a default configuration.

To list node pools, you can use:

kubectl get nodepools

You can change several parameters values through kubectl command:

kubectl patch nodepool <your_nodepool_name> --type="merge" --patch='{"spec": {"autoscaling": {"scaleDownUnneededTimeSeconds": <a_value>, "scaleDownUnreadyTimeSeconds": <another_value>, "scaleDownUtilizationThreshold": "<and_another_one>"}}}'

In my example cluster:

$ kubectl get nodepool nodepool-b2-7 -o json | jq .spec
{
  "antiAffinity": false,
  "autoscale": true,
  "autoscaling": {
    "scaleDownUnneededTimeSeconds": 600,
    "scaleDownUnreadyTimeSeconds": 1200,
    "scaleDownUtilizationThreshold": "0.5"
  },
  "desiredNodes": 3,
  "flavor": "b2-7",
  "maxNodes": 100,
  "minNodes": 0,
  "monthlyBilled": false
}
$ kubectl patch nodepool nodepool-b2-7 --type="merge" --patch='{"spec": {"autoscaling": {"scaleDownUnneededTimeSeconds": 900, "scaleDownUnreadyTimeSeconds": 1500, "scaleDownUtilizationThreshold": "0.7"}}}'
nodepool.kube.cloud.ovh.com/nodepool-b2-7 patched
$ kubectl get nodepool nodepool-b2-7 -o json | jq .spec
{
  "antiAffinity": false,
  "autoscale": true,
  "autoscaling": {
    "scaleDownUnneededTimeSeconds": 900,
    "scaleDownUnreadyTimeSeconds": 1500,
    "scaleDownUtilizationThreshold": "0.7"
  },
  "desiredNodes": 3,
  "flavor": "b2-7",
  "maxNodes": 100,
  "minNodes": 0,
  "monthlyBilled": false
}

For the moment, only these following parameters are editable:

  • autoscale
  • autoscaling
  • desiredNodes
  • minNodes
  • maxNodes

If you consider that we should prioritize the possible customization of other autoscaling parameters, you are welcome to create an issue on our Public roadmap.

Go further

To have an overview of OVHcloud Managed Kubernetes service, you can go to the OVHcloud Managed Kubernetes page.

Otherwise to skip it and learn more about using your Kubernetes cluster the practical way, we invite you to look at our tutorials .

  • If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for assisting you on your specific use case of your project.

  • Join our community of users.

Artículos relacionados