Delivering modern cloud-native applications with open source technologies on Azure Kubernetes Service
In this lab we will scale our application in various ways including scaling our deployment and the AKS cluster.
In this step, we will scale our deployment manually
kubectl scale deployment service-tracker-ui -n hackfest --replicas=3
Note: the
replicas
parameter could be a part of the Helm chart and updated with ahelm upgrade
command. Based on our deployment method, this is more appropriate.
Validate the number of pods is now 3
The Kubernetes Horizontal Pod Autoscaler (HPA) automatically scales the number of pods in a replication controller, deployment or replica set based on observed CPU utilization (or, with custom metrics support, on some other application-provided metrics)
Review hpa.yaml
Deploy the hpa resource
kubectl apply -f labs/scaling/hpa.yaml -n hackfest
Validate the number of pods is now 5 which is our minReplicas
set with the HPA
We could generate traffic to our front end enough to drive CPU utilization up and the HPA would auto-scale up to 10 max
Scaling is super simple and can be performed in the portal or via the CLI:
az aks scale --name $CLUSTERNAME --resource-group $RGNAME --node-count 5
Validate that 5 nodes are now available in the cluster
As resource demands increase, the cluster autoscaler allows your cluster to grow to meet that demand based on constraints you set. The cluster autoscaler (CA) does this by scaling your agent nodes based on pending pods.
Note: The AKS Cluster Autoscaler is currently in preview.