Skip to content

Commit a3db149

Browse files
authored
Merge pull request #103185 from zr-msft/aks-ca-params
[AKS] added cluster autoscaler profile
2 parents 722c64d + 784638a commit a3db149

File tree

1 file changed

+94
-10
lines changed

1 file changed

+94
-10
lines changed

articles/aks/cluster-autoscaler.md

Lines changed: 94 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ms.author: mlearned
1414

1515
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.
1616

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.
1818

1919
## Before you begin
2020

@@ -102,6 +102,90 @@ The above example updates cluster autoscaler on the single node pool in *myAKSCl
102102
103103
Monitor the performance of your applications and services, and adjust the cluster autoscaler node counts to match the required performance.
104104

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:
108+
109+
| Setting | Description | Default value |
110+
|----------------------------------|------------------------------------------------------------------------------------------|---------------|
111+
| 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+
105189
## Disable the cluster autoscaler
106190

107191
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
125209

126210
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.
127211

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.
129213

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".
131215
1. Click on the "Logs" section on your cluster via the Azure portal.
132216
1. Input the following example query into Log Analytics:
133217

@@ -136,11 +220,11 @@ AzureDiagnostics
136220
| where Category == "cluster-autoscaler"
137221
```
138222

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.
140224

141225
![Log Analytics logs](media/autoscaler/autoscaler-logs.png)
142226

143-
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.
144228

145229
```
146230
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
181265
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].
182266

183267
<!-- LINKS - internal -->
268+
[aks-faq]: faq.md
269+
[aks-scale-apps]: tutorial-kubernetes-scale.md
270+
[aks-support-policies]: support-policies.md
184271
[aks-upgrade]: upgrade-cluster.md
272+
[autoscaler-profile-properties]: #using-the-autoscaler-profile
185273
[azure-cli-install]: /cli/azure/install-azure-cli
186274
[az-aks-show]: /cli/azure/aks#az-aks-show
187275
[az-extension-add]: /cli/azure/extension#az-extension-add
188-
[aks-scale-apps]: tutorial-kubernetes-scale.md
276+
[az-extension-update]: /cli/azure/extension#az-extension-update
189277
[az-aks-create]: /cli/azure/aks#az-aks-create
190278
[az-aks-scale]: /cli/azure/aks#az-aks-scale
191279
[az-feature-register]: /cli/azure/feature#az-feature-register
192280
[az-feature-list]: /cli/azure/feature#az-feature-list
193281
[az-provider-register]: /cli/azure/provider#az-provider-register
194-
[aks-support-policies]: support-policies.md
195-
[aks-faq]: faq.md
196-
[az-extension-add]: /cli/azure/extension#az-extension-add
197-
[az-extension-update]: /cli/azure/extension#az-extension-update
198282

199283
<!-- LINKS - external -->
200284
[az-aks-update]: https://github.com/Azure/azure-cli-extensions/tree/master/src/aks-preview

0 commit comments

Comments
 (0)