You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/aks/cluster-autoscaler.md
+94-10Lines changed: 94 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ ms.author: mlearned
14
14
15
15
To keep up with application demands in Azure Kubernetes Service (AKS), you may need to adjust the number of nodes that run your workloads. The cluster autoscaler component can watch for pods in your cluster that can't be scheduled because of resource constraints. When issues are detected, the number of nodes in a node pool is increased to meet the application demand. Nodes are also regularly checked for a lack of running pods, with the number of nodes then decreased as needed. This ability to automatically scale up or down the number of nodes in your AKS cluster lets you run an efficient, cost-effective cluster.
16
16
17
-
This article shows you how to enable and manage the cluster autoscaler in an AKS cluster.
17
+
This article shows you how to enable and manage the cluster autoscaler in an AKS cluster.
18
18
19
19
## Before you begin
20
20
@@ -102,6 +102,90 @@ The above example updates cluster autoscaler on the single node pool in *myAKSCl
102
102
103
103
Monitor the performance of your applications and services, and adjust the cluster autoscaler node counts to match the required performance.
104
104
105
+
## Using the autoscaler profile
106
+
107
+
You can also configure more granular details of the cluster autoscaler by changing the default values in the cluster-wide autoscaler profile. For example, a scale down event happens after nodes are under-utilized after 10 minutes. If you had workloads that ran every 15 minutes, you may want to change the autoscaler profile to scale down under utilized nodes after 15 or 20 minutes. When you enable the cluster autoscaler, a default profile is used unless you specify different settings. The cluster autoscaler profile has the following settings that you can update:
| scan-interval | How often cluster is reevaluated for scale up or down | 10 seconds |
112
+
| scale-down-delay-after-add | How long after scale up that scale down evaluation resumes | 10 minutes |
113
+
| scale-down-delay-after-delete | How long after node deletion that scale down evaluation resumes | scan-interval |
114
+
| scale-down-delay-after-failure | How long after scale down failure that scale down evaluation resumes | 3 minutes |
115
+
| scale-down-unneeded-time | How long a node should be unneeded before it is eligible for scale down | 10 minutes |
116
+
| scale-down-unready-time | How long an unready node should be unneeded before it is eligible for scale down | 20 minutes |
117
+
| scale-down-utilization-threshold | Node utilization level, defined as sum of requested resources divided by capacity, below which a node can be considered for scale down | 0.5 |
118
+
| max-graceful-termination-sec | Maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node. | 600 seconds |
119
+
120
+
> [!IMPORTANT]
121
+
> The cluster autoscaler profile affects all node pools that use the cluster autoscaler. You can't set an autoscaler profile per node pool.
122
+
123
+
### Install aks-preview CLI extension
124
+
125
+
To set the cluster autoscaler settings profile, you need the *aks-preview* CLI extension version 0.4.30 or higher. Install the *aks-preview* Azure CLI extension using the [az extension add][az-extension-add] command, then check for any available updates using the [az extension update][az-extension-update] command:
126
+
127
+
```azurecli-interactive
128
+
# Install the aks-preview extension
129
+
az extension add --name aks-preview
130
+
131
+
# Update the extension to make sure you have the latest version installed
132
+
az extension update --name aks-preview
133
+
```
134
+
135
+
### Set the cluster autoscaler profile on an existing AKS cluster
136
+
137
+
Use the [az aks update][az-aks-update] command with the *cluster-autoscaler-profile* parameter to set the cluster autoscaler profile on your cluster. The following example configures the scan interval setting as 30s in the profile.
138
+
139
+
```azurecli-interactive
140
+
az aks update \
141
+
--resource-group myResourceGroup \
142
+
--name myAKSCluster \
143
+
--cluster-autoscaler-profile scan-interval=30s
144
+
```
145
+
146
+
When you enable the cluster autoscaler on node pools in the cluster, those clusters will also use the cluster autoscaler profile. For example:
147
+
148
+
```azurecli-interactive
149
+
az aks nodepool update \
150
+
--resource-group myResourceGroup \
151
+
--cluster-name myAKSCluster \
152
+
--name mynodepool \
153
+
--enable-cluster-autoscaler \
154
+
--min-count 1 \
155
+
--max-count 3
156
+
```
157
+
158
+
> [!IMPORTANT]
159
+
> When you set the cluster autoscaler profile, any existing node pools with the cluster autoscaler enabled will start using the profile immediately.
160
+
161
+
### Set the cluster autoscaler profile when creating an AKS cluster
162
+
163
+
You can also use the *cluster-autoscaler-profile* parameter when you create your cluster. For example:
164
+
165
+
```azurecli-interactive
166
+
az aks create \
167
+
--resource-group myResourceGroup \
168
+
--name myAKSCluster \
169
+
--node-count 1 \
170
+
--enable-cluster-autoscaler \
171
+
--min-count 1 \
172
+
--max-count 3 \
173
+
--cluster-autoscaler-profile scan-interval=30s
174
+
```
175
+
176
+
The above command creates an AKS cluster and defines the scan interval as 30 seconds for the cluster-wide autoscaler profile. The command also enables the cluster autoscaler on the initial node pool, sets the minimum node count to 1 and the maximum node count to 3.
177
+
178
+
### Reset cluster autoscaler profile to default values
179
+
180
+
Use the [az aks update][az-aks-update] command to reset the cluster autoscaler profile on your cluster.
181
+
182
+
```azurecli-interactive
183
+
az aks update \
184
+
--resource-group myResourceGroup \
185
+
--name myAKSCluster \
186
+
--cluster-autoscaler-profile ""
187
+
```
188
+
105
189
## Disable the cluster autoscaler
106
190
107
191
If you no longer wish to use the cluster autoscaler, you can disable it using the [az aks update][az-aks-update] command, specifying the *--disable-cluster-autoscaler* parameter. Nodes aren't removed when the cluster autoscaler is disabled.
@@ -125,9 +209,9 @@ To diagnose and debug autoscaler events, logs and status can be retrieved from t
125
209
126
210
AKS manages the cluster autoscaler on your behalf and runs it in the managed control plane. Master node logs must be configured to be viewed as a result.
127
211
128
-
To configure logs to be pushed from the cluster autoscaler into Log Analytics follow these steps.
212
+
To configure logs to be pushed from the cluster autoscaler into Log Analytics, follow these steps.
129
213
130
-
1.Setup a rule for diagnostic logs to push cluster-autoscaler logs to Log Analytics. [Instructions are detailed here](https://docs.microsoft.com/azure/aks/view-master-logs#enable-diagnostics-logs), ensure you check the box for `cluster-autoscaler` when selecting options for "Logs".
214
+
1.Set up a rule for diagnostic logs to push cluster-autoscaler logs to Log Analytics. [Instructions are detailed here](https://docs.microsoft.com/azure/aks/view-master-logs#enable-diagnostics-logs), ensure you check the box for `cluster-autoscaler` when selecting options for "Logs".
131
215
1. Click on the "Logs" section on your cluster via the Azure portal.
132
216
1. Input the following example query into Log Analytics:
133
217
@@ -136,11 +220,11 @@ AzureDiagnostics
136
220
| where Category == "cluster-autoscaler"
137
221
```
138
222
139
-
You should see logs similar to the following returned as long as there are logs to retrieve.
223
+
You should see logs similar to the following example as long as there are logs to retrieve.
The cluster autoscaler will also write out health status to a configmap named `cluster-autoscaler-status`. To retrieve these logs execute the following `kubectl` command. A health status will be reported for each node pool configured with the cluster autoscaler.
227
+
The cluster autoscaler will also write out health status to a configmap named `cluster-autoscaler-status`. To retrieve these logs, execute the following `kubectl` command. A health status will be reported for each node pool configured with the cluster autoscaler.
144
228
145
229
```
146
230
kubectl get configmap -n kube-system cluster-autoscaler-status -o yaml
@@ -181,20 +265,20 @@ If you wish to re-enable the cluster autoscaler on an existing cluster, you can
181
265
This article showed you how to automatically scale the number of AKS nodes. You can also use the horizontal pod autoscaler to automatically adjust the number of pods that run your application. For steps on using the horizontal pod autoscaler, see [Scale applications in AKS][aks-scale-apps].
0 commit comments