Search code examples
azurekubernetesscaling

Correct way to scale an Azure Kubernetes Cluster under specific conditions


Here is the gist of a question that I got on Azure Kubernetes Cluster Scaling: An AKS cluster is defined with a max of 32 nodes. Occasionally, it needs more than 32 nodes, pick two best choices from the following four:

Cluster autoscaler
Container Instances
Horizontal Pod Scaler
Manual Scaling

Here is a link to the relevant documentation from Microsoft Azure site:

https://learn.microsoft.com/en-us/azure/aks/concepts-scale

Having gone through it, I still can't figure out which two are the best choices. As I see it, both Cluster autoscaler and Horizontal Pod Scaler can work together to automate scaling, but they must obey the 32 max node limit defined at the deployment time? Otherwise, you have to work with Container Instances and Manual Scaling?

I don't have enough real-life experience trying to answer this scenario. Can someone with more experience advise?


Solution

  • To autoscale the AKS, the best way is to use the autoscale both in the AKS cluster and the HPA. The HPA is the autoscale for the pods and the AKS cluster autoscale is for the nodes.

    HPA is set to meet the requirement that you define for the pods: in which condition the number of the pods should increase or decrease. And the AKS autoscale, it's an automatic rule that will increase the number of the nodes if the resources are not enough, or decrease the number of the nodes if the need of the resources is less than the existing. Cluster autoscaler is typically used alongside the horizontal pod autoscaler and it also shows in Cluster autoscaler as below:

    Cluster autoscaler is typically used alongside the horizontal pod autoscaler. When combined, the horizontal pod autoscaler increases or decreases the number of pods based on application demand, and the cluster autoscaler adjusts the number of nodes as needed to run those additional pods accordingly.

    For the limitation, there will be three points:

    1. the min and max number of the pods you set for the autoscale rules to meed the requirement.
    2. the min and max number of the AKS cluster nodes you set for the autoscale rules, actually, this is set for needed of resources and you can also limit the cost through these settings.
    3. the limitation for the number of the nodes in the AKS cluster. According to this, the max number of the AKS nodes must not more than 100.

    Hope this will help you understand the autoscale in AKS. Any more questions, please let me know.