Tutorial: Scale applications in AKS enabled by Azure Arc

Applies to: AKS on Azure Stack HCI 22H2, AKS on Windows Server

If you completed the previous tutorials, you should have a working Kubernetes cluster in AKS, and also deployed the sample Azure Voting app.

This tutorial, part five of seven, describes how to scale out the pods in the app. You'll learn how to:

  • Scale the Kubernetes nodes
  • Manually scale Kubernetes pods that run your application

In later tutorials, the Azure Vote application is updated to a new version.

Before you begin

Previous tutorials described how to package an application into a container image, upload the image to Azure Container Registry, and create a Kubernetes cluster. The application was then deployed to the cluster. If you haven't completed these steps, start with Tutorial 1 - Prepare an application for AKS hybrid.

Manually scale pods

Previous tutorials described how to deploy the Azure Vote front-end and Redis instance in order to create a single replica. To see the number and state of pods in your cluster, use the following kubectl get command:

kubectl get pods

The following example output shows one front-end pod and one back-end pod:

NAME                               READY     STATUS    RESTARTS   AGE
azure-vote-back-2549686872-4d2r5   1/1       Running   0          31m
azure-vote-front-848767080-tf34m   1/1       Running   0          31m

To manually change the number of pods in the azure-vote-front deployment, use the kubectl scale command. The following example increases the number of front-end pods to 5:

kubectl scale --replicas=5 deployment/azure-vote-front

Run kubectl get pods again to verify that the command successfully created the additional pods. After a minute or so, the pods are available in your cluster:

kubectl get pods
                                    READY     STATUS    RESTARTS   AGE
azure-vote-back-2606967446-nmpcf    1/1       Running   0          15m
azure-vote-front-3309479140-2hfh0   1/1       Running   0          3m
azure-vote-front-3309479140-bzt05   1/1       Running   0          3m
azure-vote-front-3309479140-fvcvm   1/1       Running   0          3m
azure-vote-front-3309479140-hrbf2   1/1       Running   0          15m
azure-vote-front-3309479140-qphz8   1/1       Running   0          3m

Scale the worker nodes in the node pool

If you created your Kubernetes cluster using the commands in the previous tutorial, your deployment has a cluster called mycluster with one Linux node pool called linuxnodepool, which has a node count of 1.

Use the Set-AksHciNodePool command to scale the node pool. The following example scales the node pool from 1 to 3 Linux nodes:

Set-AksHciNodePool -clusterName mycluster -name linuxnodepool -count 3

If you want to scale the control plane nodes, use the Set-AksHciCluster command.

Note

The Set-AksHciNodePool command is used to scale worker nodes in a node pool. In earlier AKS versions, which didn't support node pools in workload clusters, the Set-AksHciCluster command was used. You can only use Set-AksHciCluster to scale worker nodes in clusters created with the old parameter set in New-AksHciCluster.

Run the following command to confirm that scaling was successful:

Get-AksHciNodePool -clusterName mycluster
ClusterName  : mycluster
NodePoolName : linuxnodepool
Version      : v1.20.7
OsType       : Linux
NodeCount    : 3
VmSize       : Standard_K8S3_v1
Phase        : Deployed

Next steps

In this tutorial, you used different scaling features in your Kubernetes cluster. You learned how to:

  • Manually scale Kubernetes pods that run your application
  • Manually scale the Kubernetes nodes

Advance to the next tutorial to learn how to update an application in Kubernetes.