叢集自動調度資源會根據節點集區節點上執行的 Pod 資源要求 (而非實際資源用量),自動增加或減少節點集區的大小。系統會定期檢查 Pod 和節點的狀態,並採取下列行動:
如果節點集區的節點數量不足,導致 Pod 無法排程,叢集自動配置器會新增節點,直到節點集區達到大小上限為止。如果節點使用率過低,且即使節點集區中的節點數量較少,所有 Pod 仍可排程,叢集自動配置器就會移除節點,直到節點集區達到最小大小為止。如果節點在逾時時間 (10 分鐘) 後無法正常排除,則強制終止節點。寬限期無法設定。
如果 Pod 要求的資源過少 (例如預設值不足),叢集自動調度資源不會更正此情況。您可以為所有工作負載建立適當的資源要求,協助確保叢集自動配置器盡可能準確地運作。
作業條件
叢集自動配置器在調整節點集區大小時,做了下列假設:
所有備用的 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-07-22 (世界標準時間)。"],[],[],null,["# Scaling user clusters\n\nTo scale your workloads on GKE on AWS, you can configure your\nAWSNodePools to automatically scale out, or manually create and\ndelete AWSNodePools to scale up or down.\n\nCluster Autoscaler\n------------------\n\nGKE on AWS implements the Kubernetes [Cluster Autoscaler](https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler).\nWhen demand on your nodes is high, Cluster Autoscaler adds nodes to the node\npool. When demand is low, Cluster Autoscaler scales back down to a minimum size\nthat you designate. This can increase the availability of your workloads when\nyou need it while controlling costs.\n\n### Overview\n\nCluster Autoscaler automatically resizes the number of nodes in a given node\npool, based on the demands your workloads. You don't need to manually add or\nremove nodes or over-provision your node pools. Instead, you specify a minimum\nand maximum size for the node pool, and the cluster scales automatically.\n\nIf resources are deleted or moved when autoscaling your cluster, your workloads\nmight experience transient disruption. For example, if your workload consists of\na single replica, that replica's Pod might be rescheduled onto a different node\nif its current node is deleted. Before enabling Cluster Autoscaler in your\nAWSNodePool, design your workloads to 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 `coredns` and `konnectivity-agent` have specific autoscalers with permissions to scale their component up or down depending on need.\n\n### How Cluster Autoscaler Works\n\nCluster Autoscaler works on a per-node pool basis. When you create a node pool,\nyou specify a minimum and maximum size for the node pool in the\n[AWSNodePool](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/reference/node-pools)\nKubernetes resource.\n\nYou can disable Cluster Autoscaler by setting `spec.minNodeCount`\nto equal `spec.maxNodeCount` on your AWSNodePools.\n\nCluster Autoscaler increases or decreases the size of the node pool\nautomatically, based on the resource requests (rather than actual resource\nutilization) of Pods running on that node pool's nodes. It periodically checks\nthe status of Pods and nodes, and takes action:\n\nIf Pods are unschedulable because there are not enough nodes in the node pool,\nCluster Autoscaler adds nodes, up to the maximum size of the node pool. If nodes\nare under-utilized, and all Pods could be scheduled even with fewer nodes in the\nnode pool, Cluster Autoscaler removes nodes, down to the minimum size of the\nnode pool. If the node cannot be drained gracefully after a timeout period\n(10 minutes), the node is forcibly terminated. The grace period is not\nconfigurable.\n\nIf your Pods have requested too few resources (for example, if the defaults are\ninsufficient), Cluster Autoscaler does not correct the situation. You can help\nensure Cluster Autoscaler works as accurately as possible by creating adequate\nresource requests for all of your workloads.\n\n### Operating Criteria\n\nCluster Autoscaler makes the following assumptions when resizing a node pool:\n\n- All replicated Pods can be restarted on some other node, possibly causing a\n brief disruption. If your services do not tolerate disruption, we don't\n recommend using Cluster Autoscaler.\n\n- All nodes in a single node pool have the same set of labels.\n\n- If you have AWSNodePools with different instance types, Cluster\n Autoscaler considers the relative cost of launching new nodes, and attempts\n to expand the least expensive node pool.\n\n- Labels manually added after initial cluster or node pool creation are not\n tracked. Nodes created by Cluster Autoscaler are assigned labels specified\n with --node-labels at the time of node pool creation.\n\nResize a Node Pool\n------------------\n\nAn [AWSNodePool](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/reference/node-pools) includes\n`minNodeCount` and `maxNodeCount` fields. These fields declare a minimum and\nmaximum number of worker nodes in the pool. You may edit these values before or\nafter the AWSNodePool is created.\n\n### Before you begin\n\nProvision a cluster using the instructions in\n[Creating a user cluster](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/creating-user-cluster). Have the\nYAML file (for example, `cluster-0.yaml`) that creates the cluster available.\n\n### Enabling automatic node pool scaling\n\n1. From your `anthos-aws` directory, use\n `anthos-gke` to switch context to your management service.\n\n ```sh\n cd anthos-aws\n anthos-gke aws management get-credentials\n ```\n | **Note:** `anthos-gke` uses the credentials you specified when you ran `aws configure`.\n\n \u003cbr /\u003e\n\n2. To enable the Cluster Autoscaler, you edit the manifest for your\n AWSNodePool. Edit the `cluster-0.yaml` file and find the\n AWSNodePool section. Change the values for `spec.minNodeCount` and\n `spec.maxNodeCount`.\n\n The example below keeps the minimum size of this node pool at `3` nodes, but\n enables the Cluster Autoscaler to increase its size to `10` nodes. \n\n apiVersion: multicloud.cluster.gke.io/v1\n kind: AWSNodePool\n metadata:\n name: cluster-0-pool-0\n spec:\n clusterName: cluster-0\n version: 1.25.5-gke.2100\n minNodeCount: 3\n maxNodeCount: 10\n ...\n\n3. Next, apply the YAML to resize the node pool.\n\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl apply -f cluster-0.yaml\n\n4. The AWSNodePool resource will transition into a `Resizing` state.\n When the AWSNodePool completes scaling, it moves to the `Provisioned`\n state.\n\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl get AWSNodePools\n\n The output shows that the AWSNodePool is `Resizing`. Resize operations\n take several minutes to complete. \n\n NAME CLUSTER STATE AGE VERSION\n cluster-0-pool-0 cluster-0 Resizing 3h 1.25.5-gke.2100\n\nManually creating a new AWSNodePool\n-----------------------------------\n\nYou can also scale your cluster by creating new AWSNodePools.\nWhen you create a new AWSNodePool, you can also scale up or down\n[instance sizes](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/reference/instance-types).\n\n1. You can retrieve the configuration manifest of an existing AWSNodePool with\n `kubectl get`.\n\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl get awsnodepool cluster-0-pool-0 -o yaml \u003e new_nodepool.yaml\n\n2. Edit `new_nodepool.yaml` and remove the sections that are not present in the\n following example. Save the file.\n\n ```yaml\n apiVersion: multicloud.cluster.gke.io/v1\n kind: AWSNodePool\n metadata:\n name: NODE_POOL_NAME\n spec:\n clusterName: AWSCLUSTER_NAME\n version: CLUSTER_VERSION # latest version is 1.25.5-gke.2100\n region: AWS_REGION\n subnetID: AWS_SUBNET_ID\n minNodeCount: MINIMUM_NODE_COUNT\n maxNodeCount: MAXIMUM_NODE_COUNT\n maxPodsPerNode: MAXIMUM_PODS_PER_NODE_COUNT\n instanceType: AWS_NODE_TYPE\n keyName: KMS_KEY_PAIR_NAME\n iamInstanceProfile: NODE_IAM_PROFILE\n proxySecretName: PROXY_SECRET_NAME\n rootVolume:\n sizeGiB: ROOT_VOLUME_SIZE\n volumeType: VOLUME_TYPE # Optional\n iops: IOPS # Optional\n kmsKeyARN: NODE_VOLUME_KEY # Optional \n ```\n3. To create a new AWSNodePool, apply the manifest to your management\n cluster.\n\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl apply -f new_nodepool.yaml\n\nWhat's next\n-----------\n\nDeploy a service backed by [Ingress](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/ingress).\n\nTo see additional options, read the reference documentation on\n[AWSNodePool](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/reference/node-pools)."]]