叢集自動調度器會根據節點集區中的資源要求 (而非實際資源用量),自動增加或減少節點集區的大小。如果 Pod 物件無法排程,且節點集區的容量不足以滿足要求,叢集自動配置器就會新增節點。
如果節點使用量過低,且所有 Pod 物件都能排程到較少的節點上,叢集自動調度器也會移除節點。如果節點在 10 分鐘後無法正常排除,則強制終止節點。這段時間無法設定。
如果 Pod 要求的資源過少 (例如預設值不足),叢集自動調度資源不會更正此情況。您可以為所有工作負載建立適當的資源要求,協助確保叢集自動配置器盡可能準確地運作。詳情請參閱「管理容器的資源」。
Pod 註解和叢集自動調度器行為
叢集自動配置器在決定如何調度資源時,會考量特定 Pod 註解。舉例來說,叢集自動配置器支援 "cluster-autoscaler.kubernetes.io/safe-to-evict": "false" 等 Pod 註解。如果將這個註解設為「false」,系統就不會在縮減事件期間移除代管 Pod 的節點。瞭解及使用這些註解,有助於微調自動配置器的行為,以符合工作負載需求。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# About cluster autoscaler\n\nThis document describes the cluster autoscaler, which automatically controls the\nsize of your node pools. The cluster autoscaler is enabled when you specify\nminimum and maximum values for the number of nodes in a node pool.\nYou specify those values when you\n[Create a node pool](/kubernetes-engine/multi-cloud/docs/aws/how-to/create-node-pool)\nor [Update a node pool](/kubernetes-engine/multi-cloud/docs/aws/how-to/update-node-pool).\n\nGKE on AWS uses the open-source Kubernetes\ncluster autoscaler.\n\nAutoscale a node pool\n---------------------\n\nThe cluster autoscaler automatically resizes the number of nodes\nin a given node pool, based on the demands of your workloads. You don't need to\nmanually add or remove nodes or over-provision your node pools. Instead, you\nspecify a minimum and maximum size for the node pool, and the rest is automatic.\n\nIf resources need to be deleted or moved while autoscaling your cluster, your\nworkloads might experience transient disruption. For example, if your workload\nconsists of a controller with a single replica, that replica's Pod might be\nrescheduled onto a different node if its current node is deleted. Because of\nthis, you must design your workloads to either tolerate potential disruption or\nensure that critical Pods are not interrupted.\n| **Note:** For autoscaling to function correctly, GKE on AWS deploys the `metrics-server` Deployment with elevated [RBAC permissions](https://kubernetes.io/docs/reference/access-authn-authz/authorization/#determine-the-request-verb) to your nodes, such as the ability to patch and update itself. Additional components, such as `antrea`, `coredns`, and `konnectivity-agent` have specific autoscalers with permissions to scale their component up or down depending on need.\n\nHow the cluster autoscaler works\n--------------------------------\n\nThe cluster autoscaler works on a per-node pool basis. When you use the cluster\nautoscaler to configure a node pool, you specify a minimum and maximum size for\nthe node pool. You can change the minimum and maximum size when you\n[Create a node pool](/kubernetes-engine/multi-cloud/docs/aws/how-to/create-node-pool)\nor [Update a node pool](/kubernetes-engine/multi-cloud/docs/aws/how-to/update-node-pool).\n\nThe cluster autoscaler increases or decreases the size of the node pool\nautomatically, based on the resource requests (rather than actual resource\nutilization) in that node pool. The cluster autoscaler adds nodes if Pod objects\nare unschedulable and there is not enough capacity in the node pool to meet\nrequests.\n\nThe cluster autoscaler also removes nodes if they are underutilized and all Pod\nobjects could be scheduled on a smaller number of nodes. If the node cannot be\ndrained gracefully after 10 minutes, the node is forcibly terminated. This\nperiod is not configurable.\n\nIf a Pod requests too few resources (for example, if the defaults are\ninsufficient), the cluster autoscaler does not correct the situation. You can\nhelp ensure that the cluster autoscaler works as accurately as possible by\ncreating adequate resource requests for all of your workloads. For more\ninformation, see\n[Managing resources for containers](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/).\n\nPod annotations and cluster autoscaler behavior\n-----------------------------------------------\n\nThe cluster autoscaler considers certain Pod annotations when making scaling\ndecisions. For example, the cluster autoscaler supports Pod annotations such as\n`\"cluster-autoscaler.kubernetes.io/safe-to-evict\": \"false\"`. This annotation,\nwhen set to \"false\", prevents the Node hosting the Pod from being removed during\na scale-down event. Understanding and using these annotations can help you\nfine-tune the autoscaler's behavior to meet your workload requirements.\n\nFor more information about Pod annotations and their effects on the cluster\nautoscaler, see the following resources:\n\n- [What types of pods can prevent CA from removing a node?](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-types-of-pods-can-prevent-ca-from-removing-a-node) in the cluster autoscaler FAQ.\n- [Official Kubernetes Cluster Autoscaler documentation](https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler#cluster-autoscaler)\n\nOperating criteria\n------------------\n\nThe cluster autoscaler makes the following assumptions when resizing a node pool:\n\n- All replicated Pod objects can be restarted on some other node, possibly causing a brief disruption. If your workload doesn't tolerate disruption, configure the workload to run on a node pool with autoscaling disabled. For more information, see [Controlling scheduling with node taints](/kubernetes-engine/docs/how-to/node-taints).\n- The cluster autoscaler can override any manual node management operations that you perform.\n- All nodes in a single node pool have the same set of labels.\n- The cluster autoscaler selects a node group that has the least idle CPU or unused memory after scaling up. This behavior affects which node pools are scaled up if you have different sizes of nodes (for example, high CPU or high memory nodes) in the same cluster.\n\nMinimum and maximum node pool size\n----------------------------------\n\nYou can specify the minimum and maximum size for each node pool in your cluster\nwith the `min-nodes` and `max-nodes` flags. To disable auto scaling, set\n`min-nodes` and `max-nodes` to the same number. The cluster autoscaler makes\nscaling decisions within these size boundaries.\n\nWhen you set the maximum size of your node pools, make sure that it is large\nenough to run all of your workloads. If the node pools in your cluster don't\nhave enough memory and CPU available to run all of your workloads, outages might\noccur.\n\nUse a `PodDisruptionBudget` to protect workloads\n------------------------------------------------\n\nYou can configure GKE on AWS to protect against workload disruption\nwith a `PodDisruptionBudget`. When you create a `PodDisruptionBudget`, you specify\nthe minimum number of Pod replicas that should be available, or the maximum\nnumber of Pod replicas that can be unavailable at any given time. For more\ninformation, see\n[Specifying a Disruption Budget for your Application](https://kubernetes.io/docs/tasks/run-application/configure-pdb/).\n\nScale up from zero nodes\n------------------------\n\nStarting with the following GKE on AWS versions, the cluster autoscaler\nsupports scaling up node pools from zero nodes:\n\n- Version 1.29 and later\n- Versions of 1.28 from 1.28.8-gke.800 and later\n- Versions of 1.27 from 1.27.12-gke.800 and later\n\nIf you're using an earlier version, you need to upgrade your cluster to one of\nthese versions to use this feature. To enable this feature for existing\nclusters, update your cluster to a supported version, and then perform a\nrolling update of your node pools by updating their Kubernetes version. For\nmore information about updating your node pools, see\n[Update a node pool](/kubernetes-engine/multi-cloud/docs/aws/how-to/update-node-pool).\n\nThe cluster autoscaler honors labels and taints you define on\nnode pools when making scaling decisions, even when no nodes are available for\nreference. GKE on AWS automatically sets the necessary label and taint\ntags on the node pool's underlying\n[AWS Auto Scaling group](https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html). For more information about these tags, see the\n[Auto-Discovery Setup](https://github.com/kubernetes/autoscaler/blob/df0ce2d99ab23b631b87a272eac7c2c552c198dc/cluster-autoscaler/cloudprovider/aws/README.md#auto-discovery-setup) section of the GitHub page describing cluster\nautoscaler configuration for AWS.\n\nBy setting these label and taint tags, GKE on AWS enables the cluster\nautoscaler to create accurate node templates. Node templates are virtual\nrepresentations of nodes that include the correct node configuration, labels,\nand taints, even when there are no physical nodes present in the node pool. As a\nresult of having these accurate node templates, the cluster autoscaler can make\ncorrect scale-up decisions.\n\nWhen configuring taints on your node pools, be aware that AWS Auto Scaling\ngroups have a limitation: if you apply multiple taints with the same key but\ndifferent value-effect combinations, only the last applied taint with the\nduplicated key is considered by the cluster autoscaler.\n\nMore information\n----------------\n\nTo learn more about the cluster autoscaler and how to prevent disruptions, see\nthe following resources:\n\n- [Kubernetes cluster autoscaler FAQ](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md)\n- [How does scale-down work?](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#how-does-scale-down-work)\n- [Does Cluster autoscaler work with `PodDisruptionBudget` in scale-down?](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#does-ca-work-with-poddisruptionbudget-in-scale-down)\n\nWhat's next\n-----------\n\n- [Create a node pool](/kubernetes-engine/multi-cloud/docs/aws/how-to/create-node-pool).\n- [Update a node pool](/kubernetes-engine/multi-cloud/docs/aws/how-to/update-node-pool)."]]