Прочетете на английски Редактиране

Споделяне чрез


Resize Azure Kubernetes Service (AKS) clusters

In this article, you learn how to resize an Azure Kubernetes Service (AKS) cluster. It's important to right-size your clusters to optimize costs and performance. You can manually resize a cluster by adding or removing the nodes to meet the needs of your applications. You can also autoscale your cluster to automatically adjust the number of nodes in response to changing demands.

Cluster right-sizing

When you create an AKS cluster, you specify the number of nodes and the size of the nodes, which determines the compute capacity of the cluster. Oversized clusters can lead to unnecessary costs, while undersized clusters can lead to performance issues. You can adjust the number and size of the nodes in the cluster to right-size the cluster to meet the needs of your applications.

Consider the following factors when right-sizing your cluster:

  • Resource requirements: Understand the resource requirements of your applications to determine the number of nodes and the size of the nodes needed to run your workloads.
  • Performance requirements: Determine the performance requirements of your applications to ensure that the cluster can meet the demands of your workloads.
  • Cost considerations: Optimize costs by right-sizing your cluster to avoid unnecessary costs associated with oversized clusters.
  • Application demands: Monitor the demands of your applications to adjust the size of the cluster in response to changing demands.
  • Infrastructure constraints: Consider the infrastructure constraints of your environment, such as capacity or reserved instance limiting to specific SKUs, to ensure that the cluster can be right-sized within the limits of your environment.

Monitor cluster performance and cost

Closely monitor the performance and cost of your clusters to ensure they're right-sized to meet the needs of your application and make adjustments as needed. You can use the following resources for monitoring:

When to resize a cluster

You might want to resize a cluster in scenarios such as the following:

  • If you see that CPU and memory usage is consistently low, consider downsizing the cluster. If usage is consistently high, make sure you have autoscaling enabled and increase the maximum node count if necessary.
  • The cost analysis add-on for AKS shows you details about node usage and cost that indicate you might benefit from cluster resizing. For example, if you see that your nodes have a high idle cost with a low usage cost, you might consider resizing your cluster to reduce costs.
  • The Metrics Server VPA shows you that your requests and/or limits are too high or low based on historical usage. You can use this information to adjust your cluster size to better match your workload.
  • You experience performance issues such as resource starvation. This might be a result of the cluster being undersized for the demands of your applications.

What happens when I resize a cluster?

Increasing cluster size

You can increase the size of an AKS cluster by adding nodes to the cluster. You can add nodes to the cluster manually or configure autoscaling to automatically adjust the number of nodes in response to changing demands.

When you increase the size of a cluster, the following changes occur:

  • New node instances are created using the same configuration as the existing nodes in the cluster.
  • New pods might be scheduled on the new nodes to distribute the workload across the cluster.
  • Existing pods don't move to the new nodes unless they are rescheduled due to node failures or other reasons.

Decreasing cluster size

You can decrease the size of an AKS cluster by removing nodes from the cluster. When you remove nodes from the cluster, the nodes are automatically drained and removed from the cluster. You can remove nodes from the cluster manually or configure autoscaling to automatically adjust the number of nodes in response to changing demands.

When you decrease the size of a cluster, the following changes occur:

  • AKS gracefully terminates the nodes and drains the pods running on the nodes before removing the nodes from the cluster.
  • Any pods managed by a replication controller are rescheduled on other node instances in the cluster.
  • Any pods that aren't managed by a replication controller aren't restarted.

Manually resize an AKS cluster

  • Resize an AKS cluster using the az aks scale command with the --node-count and --nodepool-name parameters.

    Azure CLI
    az aks scale --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --node-count $NUM_NODES --nodepool-name $NODE_POOL_NAME
    

    Repeat this command for each node pool in the cluster that you want to resize. If your cluster has only one node pool, you can omit the --nodepool-name parameter.

Automatically resize an AKS cluster

Use the cluster autoscaler to automatically resize your node pools in response to changing demands.

For more information, see the Cluster autoscaling in Azure Kubernetes Service (AKS) overview. To configure cluster autoscaling in AKS, see Use the cluster autoscaler in Azure Kubernetes Service (AKS).

Next steps

In this article, you learned how to right-size an AKS cluster. To learn more about managing AKS clusters, see the following articles: