๐Ÿ“– Read-only preview โ€” lessons, diagrams, and quizzes only. The hands-on labs, live grading, and progress tracking require running the real course locally against a Kubernetes cluster.Run it locally โ†’

Module 14 ยท Lesson 14.2

VPA & Cluster Autoscaling Concepts (Karpenter)

VPA: scaling size, not count

A VerticalPodAutoscaler (VPA) watches a workload's actual CPU/memory usage over time and recommends โ€” or, in its more aggressive modes, directly sets โ€” better resources.requests values. Where HPA changes how many pods you have, VPA changes how big each one is.

They don't combine cleanly on the same metric: if VPA is busy resizing a pod's CPU request while HPA is simultaneously trying to read that same request to decide whether to add more pods, the two can fight each other. In practice, teams either use VPA in recommendation-only mode alongside HPA, or pick one axis per metric.

This cluster doesn't have a VPA controller installed โ€” it's a separate controller plus its own CRDs, and installing a whole extra component for one lesson isn't worth it. The lab below has you write a correct VerticalPodAutoscaler object anyway; the object's shape is exactly what you'd ship for real, the only thing missing here is a controller to act on it.

Cluster autoscaling: a different axis entirely

HPA and VPA both assume there's room on existing nodes. Cluster autoscaling is what adds or removes nodes when there isn't.

  • Cluster Autoscaler (the original, widely-deployed-for-years approach): watches for Pending pods that can't be scheduled, picks a matching node group, scales it up by a node. It plans in terms of node groups you predefined โ€” it's bin-packing pods onto a shape you already decided on, and scaling back down means waiting for a node to become practically empty across all its pods.
  • Karpenter (AWS's newer, actively-developed approach โ€” the one you'll meet for real in Module 15): skips the node-group abstraction entirely. It looks directly at unschedulable pods' actual requirements and launches whatever instance type/size genuinely fits, bin-packing far more precisely. Scaling down is the same idea in reverse: consolidate pods onto fewer, better-fitting nodes and terminate the rest.

The traditional-infra analogy

HPA is a scaling policy on an Auto Scaling Group. Cluster autoscaling is the layer that resizes the ASG's capacity (or, with Karpenter, skips the ASG concept and launches exactly the instance shapes your pending workload needs) when the fleet itself is the bottleneck, not any one app's replica count.

The lab has you author both a VPA object and a Karpenter-shaped NodePool object by hand โ€” reading and writing the YAML correctly is most of what you'll actually do with these day to day, even with a live controller.

๐Ÿงช Lab: lab-29-vpa-and-cluster-autoscaling

Preview only

Goal

Write a correct VerticalPodAutoscaler and a correct Karpenter NodePool by hand. There's no VPA controller or Karpenter installed on this cluster (they're full extra components not worth adding for one lesson), so this lab grades the files themselves โ€” not something you apply โ€” exactly the skill you'll actually use day to day even with a live controller: knowing the correct shape without needing to look it up.

Tasks

  1. Open manifests/vpa.yaml. It uses an outdated API version (autoscaling.k8s.io/v1beta2). Fix it to the current stable version.
  2. Open manifests/nodepool.yaml. It's missing the nodeClassRef block Karpenter needs to know which EC2NodeClass (subnets, security groups, AMI, IAM role) to launch nodes with. Add one, pointing at an EC2NodeClass named default in the karpenter.k8s.aws group.
  3. Save both files.

Check

Run the check once both files are fixed โ€” it reads the files directly, no kubectl apply needed.

This lab runs against a real local Kubernetes cluster with an automated grader โ€” clone the repo and run make start to do it for real.

๐Ÿ“ Quiz

1. What's the core difference between HPA and VPA?

2. Why is combining HPA and VPA on the exact same metric (e.g. both reacting to CPU) risky?scenario

3. The classic Cluster Autoscaler scales nodes by:

4. How does Karpenter's approach to provisioning differ from the classic Cluster Autoscaler?scenario

5. This cluster has no VPA controller installed. What does that mean for this lesson's lab?

Progress isn't saved in this preview โ€” run the course locally to track completion and grade labs for real.