Resolve OOMKilled Errors by Reading VPA Memory Recommendations
Scenario
A Deployment web-app is running in the production namespace with 2 replicas. The web-container consumes more memory than the configured limit, causing repeated OOMKilled events — the container is being terminated by the kernel because it tried to use more memory than its limit allows.
A Vertical Pod Autoscaler (VPA) named web-app-vpa is already configured for this Deployment with updateMode: Off. In this mode, the VPA continuously observes the container's actual resource usage and calculates a recommendation — but it never applies that recommendation automatically. It is your job to read the recommendation and apply it manually.
Task
- Check the VPA recommendation for the
web-container - Update the Deployment
web-appto set the memory request and memory limit to match the VPA's recommended target value - Ensure the Deployment rollout completes successfully and the replica count remains
2
Do not modify CPU values — requests.cpu and limits.cpu must remain 50m.
Wait a few minutes for the VPA to collect metrics before checking recommendations — if you check too early, the recommendation may not be populated yet.
Hint 1 — Confirm the OOMKilled Pods
Start by confirming the container is actually being OOMKilled. Check the Pod status and recent events:
kubectl get pods -n production
kubectl describe pod -n production -l app=web-app
Look for OOMKilled in the Last State section and a high Restart Count —
this confirms the container is exceeding its memory limit.
Documentation
Hint 2 — Read the VPA Recommendation
The VPA does not change anything automatically when updateMode: Off — it
only calculates recommendations. View them with:
kubectl describe vpa web-app-vpa -n production
Look for the Recommendation section near the bottom of the output. It will
show several values per container — Target, Lower Bound, Upper Bound,
and Uncapped Target. Use the Target memory value — this is the
recommended value to apply.
You can also extract just the target memory value directly:
kubectl get vpa web-app-vpa -n production \
-o jsonpath='{.status.recommendation.containerRecommendations[0].target.memory}'
Documentation
Hint 3 — Apply the Recommendation to the Deployment
Update only the memory request and memory limit — leave CPU untouched. You
can do this with kubectl set resources in one command, or by editing the
Deployment directly:
kubectl set resources deployment web-app -n production \
--containers=web-container \
--requests=memory=<target-value> \
--limits=memory=<target-value>
Or edit the Deployment manually:
kubectl edit deployment web-app -n production
After saving, watch the rollout complete and confirm the Pods are stable:
kubectl rollout status deployment web-app -n production
kubectl get pods -n production
Documentation