借助 Pod 纵向自动扩缩,您可以分析和设置 Pod 所需的 CPU 和内存资源。您无需为 Pod 中的容器设置最新的 CPU 请求和限制以及内存请求和限制,而是可以配置 Pod 纵向自动扩缩,以便为可用于手动更新 Pod 的 CPU 和内存请求及限制提供建议值,也可以将 Pod 纵向自动扩缩配置为自动更新这些值。
在 Autopilot 集群中,Pod 纵向自动扩缩默认处于启用状态。
自动模式下的 Pod 纵向自动扩缩
由于 Kubernetes 的限制,修改正在运行的 Pod 的资源请求的唯一方法是重新创建 Pod。因此,如果您创建了一个 updateMode 为 Auto 的 VerticalPodAutoscaler 对象,则 VerticalPodAutoscaler 将在需要更改某个 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,["# Vertical Pod autoscaling\n\n[Autopilot](/kubernetes-engine/docs/concepts/autopilot-overview) [Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nThis page explains how you can analyze and optimize your resource allocation to improve your workload efficiency in Google Kubernetes Engine (GKE), using vertical Pod autoscaling. By analyzing your workload's resource usage over time, you can get optimization recommendations and automatically adjust CPU and memory requests, and limits for containers within the Pods.\n\nIn this page, you learn how vertical Pod autoscaling works, its benefits and limitations, best practices for using it, and access the [API references](#reference) for the `VerticalPodAutoscaler` custom resource and related types.\n\nThis page is for Operators and Developers who provision and configure cloud resources, deploy workloads, and manage application scaling. To learn\nmore about common roles, see\n[Common GKE user roles and tasks](/kubernetes-engine/enterprise/docs/concepts/roles-tasks).\n\nBefore reading this page, ensure that you are familiar with [resource requests and limits in Kubernetes](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/).\n\nFor rapid scaling needs in response to sudden resource usage, use the\n[Horizontal Pod Autoscaler](/kubernetes-engine/docs/concepts/horizontalpodautoscaler).\n\nTo learn best practices for autoscaling, see\n[Best practices for running cost-optimized Kubernetes applications on GKE](/architecture/best-practices-for-running-cost-effective-kubernetes-applications-on-gke#fine-tune_gke_autoscaling).\n\nHow vertical Pod autoscaling works\n----------------------------------\n\n*Vertical Pod autoscaling* lets you analyze and set CPU and memory resources\nrequired by Pods. Instead of having to set up-to-date\n[CPU requests and limits](https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/)\nand\n[memory requests and limits](https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/)\nfor the containers in your Pods, you can configure vertical Pod autoscaling to\nprovide recommended values for CPU and memory requests and limits that you can\nuse to manually update your Pods, or you can configure vertical Pod autoscaling\nto automatically update the values.\n\nVertical Pod autoscaling is enabled by default in Autopilot clusters.\n\n### Vertical Pod autoscaling in Auto mode\n\nDue to Kubernetes limitations, the only way to modify the resource requests of a\nrunning Pod is to recreate the Pod. If you create a `VerticalPodAutoscaler`\nobject with an `updateMode` of `Auto`, the `VerticalPodAutoscaler` evicts a Pod\nif it needs to change the Pod's resource requests.\n\nTo limit the amount of Pod restarts, use a\n[Pod disruption budget](https://kubernetes.io/docs/tasks/run-application/configure-pdb/).\nTo ensure that your cluster can handle the new sizes of your workloads, use\n[cluster autoscaler](/kubernetes-engine/docs/concepts/cluster-autoscaler) and\n[node auto-provisioning](/kubernetes-engine/docs/how-to/node-auto-provisioning).\n\nVertical Pod autoscaling notifies the cluster autoscaler ahead of the update,\nand provides the resources needed for the resized workload before recreating\nthe workload, to minimize the disruption time.\n\nBenefits\n--------\n\nVertical Pod autoscaling provides the following benefits:\n\n- Setting the right resource requests and limits for your workloads improves stability and cost efficiency. If your Pod resource sizes are smaller than your workloads require, your application can either be throttled or it can fail due to out-of-memory errors. If your resource sizes are too large, you have waste and, therefore, larger bills.\n- Cluster nodes are used efficiently because Pods use exactly what they need.\n- Pods are scheduled onto nodes that have the appropriate resources available.\n- You don't have to run time-consuming benchmarking tasks to determine the correct values for CPU and memory requests.\n- Reduced maintenance time because the autoscaler can adjust CPU and memory requests over time without any action on your part.\n\nGKE vertical Pod autoscaling provides the following benefits over\nthe\n[Kubernetes open source autoscaler](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler):\n\n- Takes maximum node size and resource quotas into account when determining the recommendation target.\n- Notifies the [cluster autoscaler](/kubernetes-engine/docs/concepts/cluster-autoscaler) to adjust cluster capacity.\n- Uses historical data, providing metrics collected before you enable the Vertical Pod Autoscaler.\n- Runs Vertical Pod Autoscaler Pods as [control plane](/kubernetes-engine/docs/concepts/cluster-architecture#control_plane) processes, instead of deployments on your [worker nodes](/kubernetes-engine/docs/concepts/cluster-architecture#nodes).\n\nLimitations\n-----------\n\n- To use vertical Pod autoscaling with [horizontal Pod autoscaling](/kubernetes-engine/docs/concepts/horizontalpodautoscaler), use [multidimensional Pod autoscaling](/kubernetes-engine/docs/how-to/multidimensional-pod-autoscaling). You can also use vertical Pod autoscaling with horizontal Pod autoscaling on [custom](/kubernetes-engine/docs/tutorials/custom-metrics-autoscaling) and [external](/kubernetes-engine/docs/tutorials/external-metrics-autoscaling) metrics.\n- Vertical Pod autoscaling is not ready for use with JVM-based workloads due to limited visibility into actual memory usage of the workload.\n- Vertical Pod autoscaling has a default setting of two minimum replicas for Deployments to replace Pods with revised resource values. In GKE version 1.22 and later, you can override this setting by specifying a value for `minReplicas` in the [PodUpdatePolicy](/kubernetes-engine/docs/concepts/verticalpodautoscaler#podupdatepolicy_v1_autoscalingk8sio) field.\n\n### Best practices\n\n- To avoid cluster update disruptions, we recommend that you keep the number of `VerticalPodAutoscaler` objects per cluster under 1,000.\n- Vertical Pod autoscaling works best with long-running homogenous workloads.\n\nAPI reference\n-------------\n\nThis is the `v1` API reference. We strongly recommend using this version of the\nAPI.\n\n### VerticalPodAutoscaler v1 autoscaling.k8s.io\n\n### VerticalPodAutoscalerSpec v1 autoscaling.k8s.io\n\n### VerticalPodAutoscalerList v1 autoscaling.k8s.io\n\n### PodUpdatePolicy v1 autoscaling.k8s.io\n\n### PodResourcePolicy v1 autoscaling.k8s.io\n\n### ContainerResourcePolicy v1 autoscaling.k8s.io\n\n### VerticalPodAutoscalerRecommenderSelector v1 autoscaling.k8s.io\n\n### VerticalPodAutoscalerStatus v1 autoscaling.k8s.io\n\n### RecommendedPodResources v1 autoscaling.k8s.io\n\n### RecommendedContainerResources v1 autoscaling.k8s.io\n\n### VerticalPodAutoscalerCondition v1 autoscaling.k8s.io\n\nWhat's next\n-----------\n\n- Learn how to [Scale container resource requests and limits](/kubernetes-engine/docs/how-to/vertical-pod-autoscaling).\n- Learn [best practices for running cost-optimized Kubernetes applications on GKE](/architecture/best-practices-for-running-cost-effective-kubernetes-applications-on-gke#vertical_pod_autoscaler).\n- Learn about [Cluster autoscaler](/kubernetes-engine/docs/concepts/cluster-autoscaler)."]]