Tutorial - Scale applications in Azure Kubernetes Service (AKS)
Artikkeli
If you followed the previous tutorials, you have a working Kubernetes cluster and Azure Store Front app.
In this tutorial, part six of seven, you scale out the pods in the app, try pod autoscaling, and scale the number of Azure VM nodes to change the cluster's capacity for hosting workloads. You learn how to:
Scale the Kubernetes nodes.
Manually scale Kubernetes pods that run your application.
Configure autoscaling pods that run the app front end.
Before you begin
In previous tutorials, you packaged an application into a container image, uploaded the image to Azure Container Registry, created an AKS cluster, deployed an application, and used Azure Service Bus to redeploy an updated application. If you haven't completed these steps and want to follow along, start with Tutorial 1 - Prepare application for AKS.
This tutorial requires Azure CLI version 2.34.1 or later. Run az --version to find the version. If you need to install or upgrade, see Install Azure CLI.
This tutorial requires Azure PowerShell version 5.9.0 or later. Run Get-InstalledModule -Name Az to find the version. If you need to install or upgrade, see Install Azure PowerShell.
Manually scale pods
View the pods in your cluster using the kubectl get command.
Konsoli
kubectl get pods
The following example output shows the pods running the Azure Store Front app:
Tuloste
NAME READY STATUS RESTARTS AGE
order-service-848767080-tf34m 1/1 Running 0 31m
product-service-4019737227-2q2qz 1/1 Running 0 31m
store-front-2606967446-2q2qz 1/1 Running 0 31m
Manually change the number of pods in the store-front deployment using the kubectl scale command.
To use the horizontal pod autoscaler, all containers must have defined CPU requests and limits, and pods must have specified requests. In the aks-store-quickstart deployment, the front-end container requests 1m CPU with a limit of 1000m CPU.
These resource requests and limits are defined for each container, as shown in the following condensed example YAML:
Create a manifest file to define the autoscaler behavior and resource limits, as shown in the following condensed example manifest file aks-store-quickstart-hpa.yaml:
Apply the autoscaler manifest file using the kubectl apply command.
Konsoli
kubectl apply -f aks-store-quickstart-hpa.yaml
Check the status of the autoscaler using the kubectl get hpa command.
Konsoli
kubectl get hpa
After a few minutes, with minimal load on the Azure Store Front app, the number of pod replicas decreases to three. You can use kubectl get pods again to see the unneeded pods being removed.
If you created your Kubernetes cluster using the commands in the previous tutorials, your cluster has two nodes. If you want to increase or decrease this amount, you can manually adjust the number of nodes.
The following example increases the number of nodes to three in the Kubernetes cluster named myAKSCluster. The command takes a couple of minutes to complete.
Liity tapaamissarjaan ja luo skaalattavia tekoälyratkaisuja, jotka perustuvat reaalimaailman käyttötapauksiin muiden kehittäjien ja asiantuntijoiden kanssa.
Tämä moduuli kattaa Azure Kubernetes -palvelun (AKS) skaalaussovellukset, kuten podien tai solmujen manuaalisen skaalauksen ja integroimisen Azure-säilön esiintymiin (ACI).