有时,集群自动扩缩器无法完全缩减,缩减后还会有额外节点存在。当所需的系统 Pod 被安排到其他节点上时会发生这种情况,因为没有任何触发器适用于任何这些移动到其他节点的 Pod。请参阅我有一些利用率较低的节点,但它们没有被缩减。为什么?。
要解决此限制,您可以配置 Pod 中断预算。
如果您在缩减集群时遇到问题,请参阅 Pod 调度和中断。您可能需要为 kube-system Pod 添加 PodDisruptionBudget。如需详细了解如何为 kube-system Pod 手动添加 PodDisruptionBudget,请参阅 Kubernetes 集群自动扩缩器常见问题解答。
进行缩减时,集群自动扩缩器会遵循对 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"]],["最后更新时间 (UTC):2025-09-01。"],[],[],null,["This document describes autoscaling for a user cluster in\nGoogle Distributed Cloud.\n\nCluster autoscaling increases or decreases the number of nodes in a node pool\nbased on the demands of your workloads.\n\nBefore you begin\n\nRead about the [limitations](#limitations) of the cluster autoscaler.\n\nThe cluster autoscaler makes the following assumptions:\n\n- All replicated Pods can be restarted on some other node, which might cause a\n brief disruption. If your services cannot tolerate disruption, we do not\n recommend using the cluster autoscaler.\n\n- Users or administrators do not manually manage nodes. If autoscaling is\n enabled for a node pool, you cannot override the `replicas` field of the node\n pool.\n\n- All nodes in a single node pool have the same set of labels.\n\nHow cluster autoscaling works\n\nThe cluster autoscaler works on a node-pool basis. When you enable autoscaling\nfor a node pool, you specify a minimum and maximum number of nodes for the pool.\n\nThe cluster autoscaler increases or decreases the number of nodes in the pool\nautomatically, based on the resource requests (rather than actual resource\nutilization) of Pods running on the nodes. It periodically checks the status of\nPods and nodes, and takes action:\n\n- If Pods are unschedulable because there are not enough nodes in the pool,\n the cluster autoscaler adds nodes, up to the specified maximum.\n\n- If nodes are under-utilized, and all Pods could be scheduled with fewer\n nodes in the pool, the cluster autoscaler removes nodes, down to the specified\n minimum. If a node can't be drained gracefully, the node is forcibly\n terminated, and the attached Kubernetes-managed disk is safely detached.\n\nIf your Pods have requested too few resources (or haven't changed the defaults,\nwhich might be insufficient) and your nodes are experiencing shortages, the\ncluster autoscaler does not correct that situation. You can help ensure that\nthe cluster autoscaler works accurately by making explicit resource requests\nfor all of your workloads.\n\nFor an individual node pool, `minReplicas` must be ≥ 1. However, the sum\nof the untainted user cluster nodes at any given time must be at least 3. This\nmeans the sum of the `minReplicas` values for all autoscaled node pools, plus\nthe sum of the `replicas` values for all non-autoscaled node pools, must be at\nleast 3.\n\nThe cluster autoscaler considers the relative cost of the instance types in\nthe various node pools, and attempts to expand the node pool in a way that\ncauses the least waste possible.\n\nCreate a user cluster with autoscaling\n\nTo create a user cluster with autoscaling enabled for a node pool, fill in the\n[`autoscaling`](/kubernetes-engine/distributed-cloud/vmware/docs/how-to/user-cluster-configuration-file-latest#nodepool-autoscaling-section)\nsection for the node pool in the user cluster configuration file. For example:\n\n```\nnodePools:\n- name: pool‐1\n …\n replicas: 3\n ...\n autoscaling:\n minReplicas: 1\n maxReplicas: 5\n```\n\nThe preceding configuration creates a node pool with 3 replicas, and applies\nautoscaling with the minimum node pool size as 1 and the maximum node pool size\nas 5.\n\nThe `minReplicas` value must be ≥ 1. A node pool can't scale down to zero\nnodes.\n\nAdd a node pool with autoscaling\n\nTo add a node pool with autoscaling to an existing cluster:\n\n1. Edit the user cluster configuration file to add a new node pool, and include\n an `autoscaling` section for the pool. Set the values of `replicas`,\n `minReplicas`, and `maxReplicas` as desired. For example:\n\n nodePools:\n - name: my-new-node-pool\n ...\n replicas: 3\n ...\n autoscaling:\n minReplicas: 2\n maxReplicas: 6\n\n2. Update the cluster:\n\n gkectl update cluster --config \u003cvar translate=\"no\"\u003eUSER_CLUSTER_CONFIG\u003c/var\u003e \\\n --kubeconfig \u003cvar class=\"edit\" translate=\"no\"\u003eADMIN_CLUSTER_KUBECONFIG\u003c/var\u003e\n\nEnable autoscaling for an existing node pool\n\nTo enable autoscaling for a node pool in an existing cluster:\n\n1. Edit a specific `nodePool` in the user cluster configuration file, and\n include the `autoscaling` section. Set the values of `minReplicas` and\n `maxReplicas` as desired.\n\n nodePools:\n - name: my-existing-node-pool\n ...\n replicas: 3\n ...\n autoscaling:\n minReplicas: 1\n maxReplicas: 5\n\n2. Update the cluster:\n\n gkectl update cluster --config \u003cvar translate=\"no\"\u003eUSER_CLUSTER_CONFIG\u003c/var\u003e \\\n --kubeconfig \u003cvar translate=\"no\"\u003eADMIN_CLUSTER_KUBECONFIG\u003c/var\u003e\n\n| **Note:** You cannot modify the value of `replicas` for an existing node pool while enabling autoscaling.\n\nDisable autoscaling for an existing node pool\n\nTo disable autoscaling for a specific node pool:\n\n1. Edit the user cluster configuration file and remove the `autoscaling` section\n for that node pool.\n\n2. Run `gkectl update cluster`.\n\nCheck cluster autoscaler behavior\n\nYou can determine what the cluster autoscaler is doing in several ways.\n\nCheck cluster autoscaler logs\n\nFirst, find the name of the cluster autoscaler Pod:\n\n```\nkubectl --kubeconfig ADMIN_CLUSTER_KUBECONFIG get pods -n USER_CLUSTER_NAME | grep cluster-autoscaler\n```\n\nCheck logs on the cluster autoscaler Pod:\n\n```\nkubectl --kubeconfig ADMIN_CLUSTER_KUBECONFIG logs cluster-autoscaler-POD_NAME --container cluster-autoscaler -n USER_CLUSTER_NAME\n```\n\nReplace \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e with the name of the cluster autoscaler Pod.\n\nCheck the configuration map\n\nThe cluster autoscaler publishes the `kube-system/cluster-autoscaler-status`\nconfiguration map.\n\nTo see the configuration map:\n\n```\nkubectl --kubeconfig USER_CLUSTER_KUBECONFIG get configmap cluster-autoscaler-status -n kube-system -o yaml\n```\n\nCheck cluster autoscale events.\n\nYou can check\n[cluster autoscale events](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-events-are-emitted-by-ca):\n\n- On pods (particularly those that cannot be scheduled, or on underutilized nodes)\n- On nodes\n- On the `kube-system/cluster-autoscaler-status` config map.\n\nLimitations\n\nThe cluster autoscaler has the following limitations:\n\n- Custom scheduling with altered\n [filters](https://kubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework/#filter)\n is not supported.\n\n- Nodes do not scale up if Pods have a\n [`PriorityClass`](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass)\n value below `-10`. Learn more in\n [How does Cluster Autoscaler work with Pod Priority and Preemption?](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#how-does-cluster-autoscaler-work-with-pod-priority-and-preemption).\n\n- Auto-scaling for Windows node pools is not supported.\n\nTroubleshooting\n\n- Occasionally, the cluster autoscaler cannot scale down completely and an extra\n node exists after scaling down. This can occur when required system Pods are\n scheduled onto different nodes, because there is no trigger for any of those\n Pods to be moved to a different node. See\n [I have a couple of nodes with low utilization, but they are not scaled down. Why?](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#i-have-a-couple-of-nodes-with-low-utilization-but-they-are-not-scaled-down-why).\n To work around this limitation, you can configure a\n [Pod disruption budget](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/).\n\n- If you are having problems with downscaling your cluster, see\n [Pod scheduling and disruption](/kubernetes-engine/docs/concepts/cluster-autoscaler#scheduling-and-disruption).\n You might have to add a `PodDisruptionBudget` for the `kube-system` Pods. For\n more information about manually adding a `PodDisruptionBudget` for the\n `kube-system` Pods, see the\n [Kubernetes cluster autoscaler FAQ](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#how-to-set-pdbs-to-enable-ca-to-move-kube-system-pods).\n\n- When scaling down, cluster autoscaler respects scheduling and eviction rules\n set on Pods. These restrictions can prevent a node from being deleted by the\n autoscaler. A node's deletion could be prevented if it contains a Pod with any\n of these conditions:\n\n - The Pod's\n [affinity or anti-affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)\n rules prevent rescheduling.\n\n - The Pod has local storage.\n\n - The Pod is not managed by a\n [controller](https://kubernetes.io/docs/concepts/workloads/pods/#pods-and-controllers)\n such as a Deployment, StatefulSet, Job, or ReplicaSet.\n\n - The Pod is in kube-system namespace and does not have a\n [PodDisruptionBudget](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#how-disruption-budgets-work)\n\n- An application's PodDisruptionBudget might prevent autoscaling. If deleting\n nodes would cause the budget to be exceeded, the cluster does not scale down.\n\nMore information\n\nFor more information about cluster autoscaler and preventing disruptions, see\nthe following questions in the\n[Kubernetes cluster autoscaler FAQ](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md):\n\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- [What types of Pods can prevent Cluster autoscaler 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)"]]