集群自动扩缩器会根据该节点池中的资源请求(而不是实际资源利用率)自动增大或减小节点池的大小。如果 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"]],["最后更新时间 (UTC):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)."]]