KubernetesLXXXIII · Vertical Pod Autoscaling ConceptsVertical Pod Autoscaler
VPA recommender — the recommendation engine
What you'll learn
- Explain how the VPA Recommender computes the recommendations
- Identify the percentile-based approach
- Inspect the recommendations
- Tune the recommendation algorithm
Prerequisites
Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16
The VPA Recommender is the recommendation engine. It observes the pod’s resource usage and computes the recommended requests. The recommendation is at the 90th percentile of the usage distribution. This lesson walks the recommender, the percentile approach, and the inspection of the recommendations.
The recommendation algorithm
The VPA Recommender uses a percentile-based approach:
flowchart LR
A[Pod usage history] --> B[Compute percentiles]
B --> C[90th percentile]
C --> D[Recommended requests]
D --> E[Bound by minAllowed/maxAllowed]
E --> F[Final recommendation]
The recommender collects the pod’s usage history, computes the percentiles, and selects the 90th percentile as the recommendation.
The historical data
The recommender collects the pod’s usage from the metrics server:
Pod: nginx-1-abc
Sample 1: CPU 50m, memory 128Mi
Sample 2: CPU 60m, memory 130Mi
Sample 3: CPU 45m, memory 125Mi
...
Sample N: CPU 55m, memory 129Mi
The samples are collected every 15 seconds (default for the metrics server). The recommender aggregates the samples into a distribution.
The percentiles
The recommender computes the percentiles:
CPU usage distribution:
10th percentile: 40m
50th percentile (median): 55m
90th percentile: 80m
99th percentile: 120m
Memory usage distribution:
10th percentile: 100Mi
50th percentile: 128Mi
90th percentile: 160Mi
99th percentile: 200Mi
The 90th percentile is the recommendation.
The recommendation bounds
The recommendation is bounded by the VPA’s
minAllowed and maxAllowed:
resourcePolicy:
containerPolicies:
- containerName: "*"
minAllowed:
cpu: 100m
memory: 128Mi
maxAllowed:
cpu: 2
memory: 4Gi
The recommendation is the 90th percentile, bounded by the min/max:
90th percentile: 80m
minAllowed: 100m
maxAllowed: 2
Recommendation: max(100m, min(80m, 2)) = 100m
The recommendation output
kubectl describe vpa nginx-vpa
Name: nginx-vpa
Namespace: default
Labels: <none>
Annotations: <none>
API Version: autoscaling.k8s.io/v1
Kind: VerticalPodAutoscaler
Metadata:
...
Spec:
Target Ref:
API Version: apps/v1
Kind: Deployment
Name: nginx
Status:
Conditions:
Last Transition Time: 2026-08-16T10:00:00Z
Status: True
Type: RecommendationProvided
Recommendation:
Container Recommendations:
Container Name: nginx
Lower Bound:
Cpu: 50m
Memory: 100Mi
Target:
Cpu: 100m
Memory: 200Mi
Uncapped Target:
Cpu: 80m
Memory: 180Mi
Upper Bound:
Cpu: 200m
Memory: 300Mi
The output shows:
- Lower Bound: the minimum recommended request.
- Target: the recommended request (the 90th percentile).
- Uncapped Target: the raw 90th percentile, before bounds.
- Upper Bound: the maximum recommended request.
The recommendation modes
The recommender supports different modes:
- Auto: the recommender uses the 90th percentile.
- Initial: the recommender uses the initial requests.
- Off: the recommender does not compute recommendations.
The default mode is Auto.
The tuning
The recommender can be tuned with the
recommendation-margin-fraction:
spec:
resourcePolicy:
containerPolicies:
- containerName: "*"
recommendationMarginFraction:
cpu: 0.15
memory: 0.15
The margin adds 15% to the recommendation. The tuned
recommendation is 90th_percentile * 1.15.
The margin is useful when the workload has spikes that are not captured by the 15-second metrics interval.
The historical window
The recommender uses the past 8 days of data by default:
spec:
resourcePolicy:
containerPolicies:
- containerName: "*"
historicalDataWindow: 8d
The historical window is configurable. A longer window captures seasonal patterns; a shorter window focuses on recent behavior.
The inspect metrics
The VPA Recommender exposes metrics:
vpa_recommender_recommendation_age_seconds
vpa_recommender_models_total
vpa_recommender_pods_count
vpa_recommender_cpu_recommendation
vpa_recommender_memory_recommendation
The metrics are scraped by Prometheus. The metrics indicate the recommender’s health.
Cross-course references
- The HPA course (Part LXXXII) covers the horizontal alternative.
- The Prometheus course covers metric collection.
- The Observability course covers VPA monitoring.
Quiz
Knowledge check · 4 questions
Q1. What percentile does the VPA Recommender use for the recommendation?
Q2. The recommendation is bounded by minAllowed and maxAllowed.
Q3. Walk the inspection of the VPA recommendations.
Deployment nginx with VPA. The team is inspecting the recommendations to right-size the resources.
Q4. What is the recommendation-margin-fraction, and when is it useful?
Passing score: 75%. Answers are checked in this browser.
Production discipline
- Inspect the VPA recommendations regularly. Use
kubectl describe vpa. - Compare the Target to the current request. Identify the right-size opportunity.
- Set minAllowed and maxAllowed. Bound the recommendations.
- Tune the recommendation-margin-fraction. Catch the spikes.
- Tune the historical window. Capture seasonal patterns.
- Document the recommendations. The Target, the bounds, the rationale.
The VPA Recommender is the recommendation engine. Operating it well is inspecting the recommendations, setting the bounds, and tuning the algorithm.