Course contentsShow
← Docker, Kubernetes & CI/CD
Lesson 414 of 8026. Kubernetes Traffic and ScalingFree lesson

Analyzing Resource Request Patterns with VPA Recommender

You will configure the Vertical Pod Autoscaler in recommendation mode to analyze historical resource usage patterns for your containerized applications.

In this lesson, you will learn how to use the Vertical Pod Autoscaler (VPA) in "Recommendation Mode" to determine the optimal CPU and memory requests for your containers based on real-world usage patterns.

Why Use Recommendation Mode?

When you define resource requests in your Kubernetes manifests, you are often guessing. If you set them too low, your application risks being throttled or evicted; set them too high, and you waste expensive cluster resources. The VPA Recommender is a controller that analyzes the historical performance of your pods and calculates an "ideal" resource footprint based on observed spikes and baselines.

By running the VPA in updateMode: "Off", the system provides these suggestions without automatically killing or restarting your pods. This allows you to observe, audit, and eventually adopt these values into your CI/CD pipelines.

Configuring the VPA

To start analyzing your workload, deploy a VPA object targeting your deployment. Here is a minimal configuration:

apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: my-app-vpa
spec:
  targetRef:
    apiVersion: "apps/v1"
    kind: Deployment
    name: my-app
  updatePolicy:
    updateMode: "Off" # Recommendation mode

Once applied, the VPA controller begins collecting metrics from the metrics-server. After a short period, you can inspect the recommendations by describing the VPA object:

kubectl describe vpa my-app-vpa

Under the Recommendation section, you will see calculated values for Target, Lower Bound, and Uncapped Target. These figures represent the VPA’s best estimate of what your containers should be requesting to run efficiently under current traffic conditions.

From Analysis to Action

Because this is in "Off" mode, these values are strictly informational. This is perfect for DevOps engineers who want to perform capacity planning without the risk of automatic pod restarts. You can periodically pull these recommendations and update your Helm charts or Kustomize manifests during your next deployment cycle, effectively bridging the gap between historical telemetry and cluster configuration.

Key Takeaway: Running the VPA in "Off" mode provides a data-driven blueprint for resource requests, allowing you to optimize cluster utilization by aligning container limits with actual historical usage.