Kubernetes operators can use the Vertical Pod Autoscaler (VPA) to set each pod’s CPU and memory requests from what it really uses, not from a guess. VPA is an add-on that watches every container and suggests the requests it should have, meaning the amount the scheduler reserves for it on a node. The safe way to start is updateMode: "Off". In that mode VPA still writes a full recommendation into its object, but it never restarts or changes a pod. You get honest numbers from an undisturbed workload, and you move to Initial or Auto only once you trust them.
One trap is worth knowing before you begin. Don’t let VPA and a Horizontal Pod Autoscaler (HPA, which adds or removes copies of a pod) both react to the same CPU or memory metric. VPA lowers the request, so the HPA sees higher usage per pod and adds replicas. Usage per pod then drops, VPA lowers the request again, and the workload never settles.
What you’ll accomplish
- Install the three VPA components and confirm the CRDs are registered.
- Get a
target,lowerBound,upperBoundanduncappedTargetrecommendation for a real Deployment without touching a single running pod. - Compare that recommendation against the requests you actually wrote, and reclaim the difference deliberately.
- Move to
InitialorAutowithresourcePolicybounds,controlledResources, and a PodDisruptionBudget so the updater cannot take out every replica at once. - Recognise the HPA collision and the workloads where VPA should stay in
Offpermanently.
Prerequisites
- A Kubernetes cluster on 1.28 or newer.
autoscaling.k8s.io/v1has been stable for a long time; pick a VPA release whose compatibility matrix lists your cluster version. - A working metrics-server. The recommender reads usage through the
metrics.k8s.ioAPI, so ifkubectl top podsfails, VPA produces nothing at all. Fix that first — the same requirement applies to the Horizontal Pod Autoscaler. cluster-admin, or at least permission to create CRDs, a mutating webhook configuration, ClusterRoles and Deployments inkube-system. The install script does all four.- An honest check of what your platform already provides. GKE ships VPA as a cluster feature you enable rather than install; on EKS, AKS and self-managed clusters you install from the
kubernetes/autoscalerrepository yourself. Adding the upstream install on top of a managed VPA gives you two recommenders fighting over the same objects, so check before you clone. - Realistic expectations about eviction. In-place pod resize is still maturing, and recent VPA releases add an
InPlaceOrRecreatemode behind a feature gate. On most clusters today,Automeans the updater evicts the pod and the replacement comes back with new requests — plan for a rollout, not a silent adjustment. - A workload with more than one replica. The updater refuses to evict pods belonging to a controller with fewer replicas than its
--min-replicasflag, default 2. A single-replica Deployment will hold a recommendation forever and never be acted on.
How it works
VPA is not one controller. It is three processes that share state only through the VerticalPodAutoscaler object, which is why the split explains most of the failure modes.
The recommender consumes usage samples for every pod matched by a VPA’s targetRef and maintains a decaying histogram per container — roughly eight days of history, weighted so recent behaviour counts more than last week’s. From it, four numbers land in status.recommendation.containerRecommendations: target (what the request should be), lowerBound (below which the pod is under-provisioned), upperBound (above which the request is wasteful), and uncappedTarget (the same maths with your resourcePolicy ignored). A safety margin sits on top of observed usage, set by --recommendation-margin-fraction, default 0.15.
The updater does the only destructive thing here: if a running pod’s requests fall outside [lowerBound, upperBound], it deletes the pod through the eviction API. Eviction respects PodDisruptionBudgets, so a PDB is your brake.
The admission controller is a mutating webhook on pod creation. When the replacement pod arrives, it rewrites spec.containers[].resources to match the current recommendation before the scheduler sees it. This is the component that actually changes requests — the updater only makes room for it.
spec.updatePolicy.updateMode decides how far around that loop you go:
Off— the recommender runs, the recommendation appears, nobody acts. The reporting mode, and where every rollout should begin.Initial— the admission controller applies the recommendation to pods as they are created, whatever created them. No evictions; existing pods keep their old requests until something else restarts them.Recreate— the updater actively evicts pods to apply new numbers.Autois currently an alias for this on most clusters, and upstream reserves the right to change whatAutomaps to as in-place resize matures. If you mean “evict”, sayRecreate.
spec.resourcePolicy.containerPolicies keeps you in control. minAllowed and maxAllowed clamp the target, controlledResources restricts VPA to cpu, memory or one of the two, and controlledValues: RequestsOnly leaves your limits alone. When a target is clamped, uncappedTarget still shows the raw number — that is how you tell “VPA wants more than I allow” from “VPA is happy”. A per-container mode: "Off" excludes a sidecar.
The recommender also writes a VerticalPodAutoscalerCheckpoint per container so the histogram survives a restart. Without it, every recommender rollout would reset your history and you would wait days again for a confident number.
Step-by-step
-
Confirm metrics-server is actually serving. VPA has no fallback for this.
kubectl top pods -n team-paymentsNAME CPU(cores) MEMORY(bytes) web-6d4f9c8b7d-2xk4p 214m 604Mi web-6d4f9c8b7d-9wq7n 198m 591Mi web-6d4f9c8b7d-hj52t 231m 618MiNumbers for every pod means you are good.
error: Metrics API not availablemeans stop and fix metrics-server. -
Clone the autoscaler repository and pick a release tag. Do not install from
master— the script builds manifests from the checked-out tree.git clone https://github.com/kubernetes/autoscaler.git cd autoscaler/vertical-pod-autoscaler git tag -l 'vertical-pod-autoscaler-*' | tail -4vertical-pod-autoscaler-1.1.2 vertical-pod-autoscaler-1.2.1 vertical-pod-autoscaler-1.3.1 vertical-pod-autoscaler-1.4.1Check the release notes for the cluster versions the tag supports.
-
Run the install script. It generates the webhook certificate, registers the CRDs, and creates the three Deployments in
kube-system.git checkout vertical-pod-autoscaler-1.4.1 ./hack/vpa-up.shcustomresourcedefinition.apiextensions.k8s.io/verticalpodautoscalers.autoscaling.k8s.io created customresourcedefinition.apiextensions.k8s.io/verticalpodautoscalercheckpoints.autoscaling.k8s.io created serviceaccount/vpa-recommender created deployment.apps/vpa-recommender created serviceaccount/vpa-updater created deployment.apps/vpa-updater created serviceaccount/vpa-admission-controller created deployment.apps/vpa-admission-controller created service/vpa-webhook created./hack/vpa-down.shfrom the same directory removes all of it — worth knowing before you start rather than after. -
Confirm the three components are Running and the CRDs exist. A half-finished install is the most common cause of “no recommendation ever appears”.
kubectl -n kube-system get deploy vpa-recommender vpa-updater vpa-admission-controller kubectl get crd | grep autoscaling.k8s.ioNAME READY UP-TO-DATE AVAILABLE AGE vpa-recommender 1/1 1 1 92s vpa-updater 1/1 1 1 92s vpa-admission-controller 1/1 1 1 91s verticalpodautoscalercheckpoints.autoscaling.k8s.io 2026-07-30T11:12:44Z verticalpodautoscalers.autoscaling.k8s.io 2026-07-30T11:12:44Z -
Create a VPA in
Offmode against a real Deployment. Measure before you move anything.apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: name: web-vpa namespace: team-payments spec: targetRef: apiVersion: apps/v1 kind: Deployment name: web updatePolicy: updateMode: "Off"kubectl apply -f web-vpa.yaml kubectl get vpa -n team-paymentsverticalpodautoscaler.autoscaling.k8s.io/web-vpa created NAME MODE CPU MEM PROVIDED AGE web-vpa Off 6sEmpty
CPUandMEMcolumns are expected at this age.PROVIDEDflips toTrueonce the recommender has enough samples, usually within a couple of minutes, but the number is only trustworthy after a full traffic cycle. -
Wait, then read the recommendation. Give it at least a day, ideally a week, so the histogram covers your real peaks.
kubectl describe vpa web-vpa -n team-paymentsName: web-vpa Namespace: team-payments API Version: autoscaling.k8s.io/v1 Kind: VerticalPodAutoscaler Spec: Target Ref: API Version: apps/v1 Kind: Deployment Name: web Update Policy: Update Mode: Off Status: Conditions: Last Transition Time: 2026-07-29T09:14:02Z Status: True Type: RecommendationProvided Recommendation: Container Recommendations: Container Name: web Lower Bound: Cpu: 262m Memory: 486Mi Target: Cpu: 418m Memory: 629Mi Uncapped Target: Cpu: 418m Memory: 629Mi Upper Bound: Cpu: 1265m Memory: 1483Mi Events: <none>RecommendationProvided: Truewith a populatedTargetis the success signal.kubectl get vpa web-vpa -n team-payments -o yamlgives the same block for scripting. -
Compare the recommendation against what you actually requested. This is the number that justifies the change:
kubectl get deploy web -n team-payments \ -o jsonpath='{.spec.template.spec.containers[0].resources}{"\n"}'{"limits":{"memory":"2Gi"},"requests":{"cpu":"1","memory":"1Gi"}}A request of
1CPU against a target of418mmeans roughly 580 millicores per replica are reserved and never used — times the replica count, that is capacity the scheduler cannot give to anything else. Memory is closer,1Giagainst629Mi, but still fenced off. Under namespace quotas, that reservation counts against the team’s ceiling too. -
Apply the recommendation by hand first. One reviewed rollout beats handing the keys to the updater.
kubectl set resources deploy web -n team-payments \ --requests=cpu=450m,memory=700Mi kubectl rollout status deploy/web -n team-paymentsdeployment.apps/web resource requirements updated Waiting for deployment "web" rollout to finish: 2 of 3 updated replicas are available... deployment.apps/web successfully rolled outRound up from
target, never down. A little headroom above the recommendation saves you a page. -
Add a PodDisruptionBudget before enabling any mode that evicts. The updater uses the eviction API, so the PDB is what stops it clearing the whole Deployment in one pass.
apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: web namespace: team-payments spec: minAvailable: 2 selector: matchLabels: app: webkubectl apply -f web-pdb.yaml kubectl get pdb web -n team-paymentspoddisruptionbudget.policy/web created NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE web 2 N/A 1 4sALLOWED DISRUPTIONS: 1is the signal. Zero is safe but also means VPA never acts. -
Switch to
InitialorRecreatewith bounds.Initialis gentler: new pods get right-sized, existing ones wait for a normal rollout.apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: name: web-vpa namespace: team-payments spec: targetRef: apiVersion: apps/v1 kind: Deployment name: web updatePolicy: updateMode: "Recreate" resourcePolicy: containerPolicies: - containerName: web controlledResources: ["cpu", "memory"] controlledValues: RequestsOnly minAllowed: cpu: 200m memory: 256Mi maxAllowed: cpu: "2" memory: 2Gi - containerName: istio-proxy mode: "Off"kubectl apply -f web-vpa.yaml kubectl get vpa web-vpa -n team-paymentsverticalpodautoscaler.autoscaling.k8s.io/web-vpa configured NAME MODE CPU MEM PROVIDED AGE web-vpa Recreate 418m 629Mi True 31hminAllowedprotects you from a quiet weekend producing a recommendation too small to start the service.maxAllowedstops one bad spike making the pod unschedulable.controlledValues: RequestsOnlyleaves your memory limit alone.
Validate it works
Four checks. Skipping the last is how eviction storms get found by users instead of by you.
The recommendation is present and non-empty. The PROVIDED column reads True and MODE shows what you intended:
kubectl get vpa -A
NAMESPACE NAME MODE CPU MEM PROVIDED AGE
team-payments web-vpa Recreate 418m 629Mi True 31h
Pods came back with the new requests. Read the running pods, not the Deployment — the admission webhook mutates the pod, and the template still says whatever you wrote:
kubectl get pods -n team-payments -l app=web \
-o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].resources.requests.cpu}{"\t"}{.spec.containers[0].resources.requests.memory}{"\n"}{end}'
web-7f8c5d9b64-4nmzp 418m 629Mi
web-7f8c5d9b64-8tqvd 418m 629Mi
web-7f8c5d9b64-lc6wr 418m 629Mi
It also annotates every pod it touched, which is the clearest proof the webhook fired:
kubectl get pod -n team-payments -l app=web \
-o jsonpath='{.items[0].metadata.annotations.vpaUpdates}{"\n"}'
Pod resources updated by web-vpa: container 0: cpu request, memory request
Node reservation pressure went down, so the scheduler can place more work:
kubectl describe node worker-3 | grep -A6 'Allocated resources'
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 2914m (72%) 6200m (155%)
memory 7482Mi (63%) 11Gi (94%)
If Requests did not move against your earlier reading, the recommendation never reached the pods that matter.
No eviction storm. The updater tags its own evictions:
kubectl get events -n team-payments --field-selector reason=EvictedByVPA \
--sort-by=.lastTimestamp
LAST SEEN TYPE REASON OBJECT MESSAGE
28m Normal EvictedByVPA pod/web-6d4f9c8b7d-2xk4p Pod was evicted by VPA Updater to apply resource recommendation.
26m Normal EvictedByVPA pod/web-6d4f9c8b7d-9wq7n Pod was evicted by VPA Updater to apply resource recommendation.
Evictions spaced minutes apart is the loop converging. Dozens per hour, forever, is the failure below.
Troubleshooting
-
No recommendation ever appears. Check the condition first:
kubectl get vpa web-vpa -n team-payments -o jsonpath='{.status.conditions}'.NoPodsMatchedmeans thetargetRefresolves to nothing — usually a name typo or the wrong namespace. No conditions at all points at the recommender:kubectl -n kube-system logs deploy/vpa-recommendershows metrics API errors when metrics-server is unreachable.LowConfidencemeans nothing is broken; the recommender has not seen enough history yet. -
The updater evicts pods constantly. Three causes, in order of likelihood: no PodDisruptionBudget, so nothing paces the updater. Or
minAllowedandmaxAllowedso tight that the clamped target sits outside the bounds the updater compares against, making every pod look permanently wrong. Or a genuinely bursty workload whose recommendation moves faster than pods can start. For the third,Offplus a periodic manual review is the better answer. -
VPA and HPA fight over the same resource. This one is structural, not a misconfiguration. If an HPA scales on CPU utilisation and a VPA in
Recreatemode controls the CPU request, they feed each other indefinitely.Two exits. Restrict VPA with
controlledResources: ["memory"]and let the HPA keep CPU — memory is what VPA is better at anyway, since you cannot scale a leak horizontally. Or move the HPA onto a custom or external metric such as requests per second, and let VPA own both compute resources. What you must not do is leave both controllers on CPU and hope the stabilisation windows absorb it. -
The recommendation is far above anything you have seen. Compare
uncappedTargetwithtarget. A single startup spike or a one-off batch job inside the pod inflates the histogram for days, because the decay half-life is measured in days, not minutes.maxAllowedcaps what gets applied whileuncappedTargetstill shows what VPA wanted. For a genuinely one-off event, deleting the container’sVerticalPodAutoscalerCheckpointresets the history — you then wait for it to rebuild. -
Pods stuck
Pendingafter the resize. The new request no longer fits any node:kubectl describe podsays0/6 nodes are available: 6 Insufficient memory. This is whatmaxAllowedprevents; set it below the largest request a single node can satisfy, allowing for what the kubelet and system daemons reserve. -
VPA ignores a workload entirely. The condition reads
ConfigUnsupported. VPA resolvestargetRefthrough the scale subresource, so Deployments, StatefulSets, DaemonSets and ReplicaSets work, but a custom controller CRD without a scale subresource is invisible to it. Point the VPA at the underlying Deployment the operator creates, not at the CR.
When this is the wrong approach
- Applications where memory is set by a runtime flag. A JVM with
-Xmx2g, a Node process with--max-old-space-size, a PHP-FPM pool with a fixed worker count: none shrink because VPA lowered the request. A limit lowered under the configured heap kills the process the moment it grows into it. UsecontrolledValues: RequestsOnly, or keep memory out ofcontrolledResourcesand size heap and limit together. - Workloads with strong daily or weekly cycles. The histogram deliberately smooths across days, so a service idle overnight and saturated at 09:00 gets a recommendation between the two — too small for the peak, too large for the trough. Scale those horizontally on a metric that tracks demand, and size the request for the peak.
- Single-replica stateful services.
--min-replicaskeeps the updater off them by default, and that default is correct: evicting the only replica of a database is a restart with data at stake. UseOff, read the recommendation, and change the requests during a maintenance window. - When a one-time exercise is all you need. If your requests were set once by copy-paste and never revisited, running VPA in
Offfor two weeks, applying the numbers and deleting the objects captures most of the value with none of the eviction risk. ContinuousRecreateearns its keep on workloads whose usage drifts, not on ones that were never measured.
Every flag lives in the vertical-pod-autoscaler directory of kubernetes/autoscaler, and the Kubernetes autoscaling concepts page covers how vertical and horizontal scaling are meant to divide the work.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.