Configure Cluster Autoscaler for Azure Kubernetes Service (AKS) - Exam AZ-104

Configure Cluster Autoscaler for Azure Kubernetes Service (AKS)

Question

You have an Azure Kubernetes Service (AKS) cluster named AKS1.

You need to configure cluster autoscaler for AKS1.

Which two tools should you use? Each correct answer presents a complete solution.

NOTE: Each correct selection is worth one point.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

AB

A: The following example uses the kubectl autoscale command to autoscale the number of pods in the azure-vote-front deployment. If average CPU utilization across all pods exceeds 50% of their requested usage, the autoscaler increases the pods up to a maximum of 10 instances. A minimum of 3 instances is then defined for the deployment: kubectl autoscale deployment azure-vote-front --cpu-percent=50 --min=3 --max=10

B: Use the az aks update command to enable and configure the cluster autoscaler on the node pool for the existing cluster.

https://docs.microsoft.com/en-us/azure/aks/tutorial-kubernetes-scale https://docs.microsoft.com/en-us/azure/aks/cluster-autoscaler

The correct answers for this question are A. the kubectl command and B. the az aks command.

Explanation:

Cluster autoscaler is an add-on that automatically adjusts the number of nodes in a Kubernetes cluster based on the resource demands of running pods. This ensures that there are enough resources available for all pods to run without wasting resources by running idle nodes.

To configure cluster autoscaler for an Azure Kubernetes Service (AKS) cluster, you can use either the kubectl command or the az aks command.

A. The kubectl command:

The kubectl command is a command-line tool used to deploy and manage applications on Kubernetes clusters. To configure cluster autoscaler using kubectl, you need to create a Kubernetes manifest file that defines the cluster autoscaler deployment and its configuration. This manifest file can then be applied to the AKS cluster using the kubectl apply command.

For example, the following YAML file defines a cluster autoscaler deployment with the minimum and maximum number of nodes set to 1 and 5, respectively:

yaml
apiVersion: apps/v1 kind: Deployment metadata: name: cluster-autoscaler spec: replicas: 1 selector: matchLabels: app: cluster-autoscaler template: metadata: labels: app: cluster-autoscaler spec: containers: - name: cluster-autoscaler image: k8s.gcr.io/autoscaling/cluster-autoscaler:v1.19.1 command: - ./cluster-autoscaler - --v=4 - --stderrthreshold=info - --cloud-provider=azure - --skip-nodes-with-local-storage=false - --nodes=<minimum number of nodes>:<maximum number of nodes>:<AKS node pool name> env: - name: AZURE_SUBSCRIPTION_ID value: <Azure subscription ID> - name: AZURE_TENANT_ID value: <Azure tenant ID> - name: AZURE_CLIENT_ID value: <Azure client ID> - name: AZURE_CLIENT_SECRET value: <Azure client secret>

Once you have created the YAML file, you can apply it to the AKS cluster using the following command:

php
kubectl apply -f <filename>.yaml

B. The az aks command:

The az aks command is a command-line tool used to create and manage AKS clusters. To configure cluster autoscaler using the az aks command, you need to enable the cluster autoscaler feature when creating the AKS cluster or update an existing cluster to enable the feature.

To enable cluster autoscaler when creating a new AKS cluster, you can use the following command:

css
az aks create --resource-group <resource group name> --name <AKS cluster name> --node-count <initial node count> --enable-cluster-autoscaler --min-count <minimum node count> --max-count <maximum node count> --node-vm-size <VM size>

To update an existing AKS cluster to enable cluster autoscaler, you can use the following command:

css
az aks update --resource-group <resource group name> --name <AKS cluster name> --enable-cluster-autoscaler --min-count <minimum node count> --max-count <maximum node count>

In both cases, the --min-count and --max-count options specify the minimum and maximum number of nodes that the cluster autoscaler can scale the AKS cluster to.

In conclusion, both the kubectl command and the az aks command can be used to configure cluster autoscaler for an AKS