Bird
Raised Fist0
Kubernetesdevops~20 mins

Vertical Pod Autoscaler concept in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Vertical Pod Autoscaler Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary function of the Vertical Pod Autoscaler (VPA) in Kubernetes?

Choose the best description of what the Vertical Pod Autoscaler does in a Kubernetes cluster.

AIt scales the number of pod replicas up or down based on incoming traffic.
BIt automatically adjusts the CPU and memory requests of pods based on usage patterns.
CIt manages persistent storage volumes for pods dynamically.
DIt schedules pods to nodes based on node labels and taints.
Attempts:
2 left
💡 Hint

Think about resource allocation inside a pod rather than the number of pods.

💻 Command Output
intermediate
2:00remaining
What is the output of this command related to VPA?

Given the command kubectl get vpa in a cluster with one VPA resource named my-app-vpa, what is the expected output?

Kubernetes
kubectl get vpa
A
NAME        READY
my-app-vpa  True
BNo resources found in default namespace.
C
NAME        RECOMMENDATION
my-app-vpa  cpu: 500m, memory: 256Mi
DError from server (NotFound): verticalpodautoscalers.autoscaling.k8s.io "my-app-vpa" not found
Attempts:
2 left
💡 Hint

The command lists VPA resources and their current recommendations.

❓ Configuration
advanced
3:00remaining
Which VPA configuration snippet correctly sets the update mode to 'Auto'?

Identify the correct YAML snippet that configures a Vertical Pod Autoscaler with update mode set to Auto.

A
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: example-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: example-deployment
  updatePolicy:
    update_mode: Auto
B
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: example-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: example-deployment
  updatePolicy:
    updateMode: Manual
C
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: example-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: example-deployment
  updatePolicy:
    mode: Auto
D
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: example-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: example-deployment
  updatePolicy:
    updateMode: Auto
Attempts:
2 left
💡 Hint

Check the exact field name and value for update mode in the VPA spec.

❓ Troubleshoot
advanced
3:00remaining
Why might a VPA not update pod resources even when usage is high?

Given a VPA configured with updateMode: Auto, pods still run with old resource requests despite high CPU and memory usage. What is a likely cause?

AThe VPA cannot update running pods; it only updates resource requests for new pods after restart.
BThe pods are managed by a Deployment with <code>replicaSet</code> and VPA does not support Deployments.
CThe VPA is in <code>Auto</code> mode but the pods have <code>resourceLimits</code> set too low.
DThe VPA is configured with <code>updateMode: Off</code> instead of <code>Auto</code>.
Attempts:
2 left
💡 Hint

Think about how resource changes affect running pods.

✅ Best Practice
expert
4:00remaining
What is the recommended approach to safely use VPA with Horizontal Pod Autoscaler (HPA)?

When using both Vertical Pod Autoscaler and Horizontal Pod Autoscaler together, which practice helps avoid conflicts and ensures stable scaling?

ASet VPA update mode to <code>Initial</code> so it only sets resources at pod start, while HPA manages pod count.
BConfigure VPA in <code>Off</code> mode and let HPA handle all scaling decisions.
CSet VPA update mode to <code>Auto</code> and HPA to scale based on CPU only.
DRun VPA and HPA with no coordination; Kubernetes will handle conflicts automatically.
Attempts:
2 left
💡 Hint

Consider how resource changes and pod count scaling interact.

Practice

(1/5)
1. What is the main purpose of the Vertical Pod Autoscaler in Kubernetes?
easy
A. Schedule pods to specific nodes manually
B. Scale the number of pod replicas up or down
C. Manage network policies between pods
D. Automatically adjust CPU and memory requests for pods based on usage

Solution

  1. Step 1: Understand VPA's role

    The Vertical Pod Autoscaler changes resource requests (CPU, memory) for pods automatically based on their usage.
  2. Step 2: Differentiate from other autoscalers

    Unlike Horizontal Pod Autoscaler, which changes pod count, VPA adjusts resource limits inside pods.
  3. Final Answer:

    Automatically adjust CPU and memory requests for pods based on usage -> Option D
  4. Quick Check:

    VPA adjusts resources, not pod count [OK]
Hint: VPA changes pod resources, not pod numbers [OK]
Common Mistakes:
  • Confusing VPA with Horizontal Pod Autoscaler
  • Thinking VPA manages pod replicas
  • Assuming VPA controls networking
2. Which of the following is the correct YAML snippet to create a Vertical Pod Autoscaler targeting a deployment named my-app?
easy
A. apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: name: my-app-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: my-app
B. apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: name: my-app-vpa spec: targetRef: apiVersion: apps/v1 kind: Deployment name: my-app
C. apiVersion: v1 kind: Pod metadata: name: my-app-pod spec: containers: - name: my-app image: my-app-image
D. apiVersion: autoscaling.k8s.io/v2 kind: VerticalPodAutoscaler metadata: name: my-app-vpa spec: target: apiVersion: apps/v1 kind: Deployment name: my-app

Solution

  1. Step 1: Check apiVersion and kind

    Correct VPA uses apiVersion: autoscaling.k8s.io/v1 and kind: VerticalPodAutoscaler.
  2. Step 2: Verify targetRef structure

    The targetRef field must specify the deployment with apiVersion, kind, and name correctly.
  3. Final Answer:

    YAML with apiVersion autoscaling.k8s.io/v1, kind VerticalPodAutoscaler, and targetRef for my-app deployment -> Option B
  4. Quick Check:

    VPA YAML uses targetRef, autoscaling.k8s.io/v1 [OK]
Hint: VPA uses targetRef, not scaleTargetRef [OK]
Common Mistakes:
  • Using HorizontalPodAutoscaler instead of VerticalPodAutoscaler
  • Wrong apiVersion like autoscaling/v1
  • Incorrect field name target instead of targetRef
3. Given this VPA configuration snippet, what will happen when the pod's CPU usage increases beyond the current request?
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: example-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: example-app
  updatePolicy:
    updateMode: "Auto"
medium
A. The VPA will automatically update the pod's CPU requests to match usage
B. The pod replicas will increase to handle the load
C. The pod will restart immediately to apply new resources
D. Nothing happens until manual intervention

Solution

  1. Step 1: Understand updateMode Auto

    When updateMode is Auto, VPA automatically adjusts resource requests without manual steps.
  2. Step 2: Effect on pod resources

    VPA changes CPU and memory requests to match observed usage, improving stability and efficiency.
  3. Final Answer:

    The VPA will automatically update the pod's CPU requests to match usage -> Option A
  4. Quick Check:

    updateMode Auto means automatic resource adjustment [OK]
Hint: Auto updateMode means VPA adjusts resources automatically [OK]
Common Mistakes:
  • Confusing VPA with Horizontal Pod Autoscaler scaling pods
  • Thinking pods restart immediately on resource change
  • Assuming manual approval is needed with Auto mode
4. You applied a Vertical Pod Autoscaler with updateMode: Auto, but pod resource requests did not change after high CPU usage. What is a likely cause?
medium
A. The Horizontal Pod Autoscaler is overriding VPA settings
B. The pod replicas are too few to trigger scaling
C. The VPA targetRef is incorrect or does not match the pods
D. The pod image version is outdated

Solution

  1. Step 1: Check VPA targetRef correctness

    If targetRef does not correctly point to the pods or deployment, VPA cannot adjust resources.
  2. Step 2: Understand VPA scope

    VPA only adjusts resources for pods matching targetRef; replicas count or pod image do not affect resource updates directly.
  3. Final Answer:

    The VPA targetRef is incorrect or does not match the pods -> Option C
  4. Quick Check:

    Incorrect targetRef means no resource updates [OK]
Hint: Verify targetRef matches pods exactly [OK]
Common Mistakes:
  • Blaming pod replicas count for resource update failure
  • Assuming HPA conflicts with VPA resource updates
  • Thinking pod image version affects VPA behavior
5. You want to use Vertical Pod Autoscaler but avoid pod restarts during resource updates. Which updateMode should you choose and why?
hard
A. "Initial" to set resources only at pod creation without restarts later
B. "Auto" to update resources and restart pods automatically
C. "Off" to disable updates and avoid restarts
D. "Manual" to require manual approval before updates

Solution

  1. Step 1: Understand updateMode options

    "Off" disables updates, "Auto" updates and restarts pods, "Initial" sets resources only at pod start, "Manual" requires manual approval.
  2. Step 2: Choose mode to avoid restarts

    "Initial" mode applies resource recommendations only when pods start, so no restarts happen later.
  3. Final Answer:

    "Initial" to set resources only at pod creation without restarts later -> Option A
  4. Quick Check:

    Initial mode avoids restarts by updating only at pod start [OK]
Hint: Use Initial mode to avoid pod restarts on resource changes [OK]
Common Mistakes:
  • Choosing Off disables VPA completely
  • Assuming Manual mode avoids restarts automatically
  • Confusing Auto mode with no restarts
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard