Three Levels of Scaling
| What scales | Tool | Direction |
|---|---|---|
| Number of pods | HPA (Horizontal Pod Autoscaler), KEDA | Out and in (more or fewer replicas) |
| Size of a pod | VPA (Vertical Pod Autoscaler) | Up and down (requests/limits) |
| Number of nodes | Cluster Autoscaler, Karpenter | Add or remove machines |
Horizontal Pod Autoscaler (HPA)
The HPA controller checks metrics about every 15 seconds and changes the replicas of a Deployment, StatefulSet or other scalable resource.
<unknown>. It also needs metrics-server.
| Metric type | Example | Source |
|---|---|---|
Resource | CPU, memory | metrics-server |
ContainerResource | CPU of one container (not sidecars) | metrics-server |
Pods | http_requests_per_second averaged per pod | Custom Metrics API (Prometheus Adapter) |
Object | Requests per second on an Ingress | Custom Metrics API |
External | Queue length in SQS or Kafka lag | External Metrics API (KEDA, adapters) |
replicas by hand and with GitOps: If your manifest has replicas: 3 and the HPA changes it to 10, every kubectl apply resets it. Remove replicas from the Deployment YAML when an HPA manages it.
Common HPA Problems
| Symptom | Cause |
|---|---|
TARGETS <unknown>/60% | metrics-server missing or pods have no CPU requests |
| Never scales up | Target too high, wrong metric, maxReplicas reached, pods not Ready |
| Flapping up and down | Too short stabilization, spiky load. Increase scaleDown window |
Scales up but pods are Pending | No node capacity. Need the Cluster Autoscaler |
| Scaling does not help | Bottleneck is a database or a lock, not the pod count |
Vertical Pod Autoscaler (VPA)
The VPA watches real usage and recommends or sets CPU and memory requests. It is installed as an add-on (not in core Kubernetes).
- Start with
updateMode: Offand use the recommendations to set requests in your manifests - In
Auto/Recreatemode the VPA evicts pods to apply new values (newer Kubernetes can resize in place when supported) - Do not use HPA and VPA on the same metric (CPU) for the same workload, they fight each other
KEDA: Event-Driven Autoscaling
KEDA scales workloads from events such as queue length, Kafka lag, cron schedules and database rows. It can scale to zero and back. Under the hood it creates and manages an HPA.
Cluster Autoscaler and Karpenter
More pods need more nodes. Node autoscalers watch for Pending pods that cannot be scheduled and add nodes, and remove nodes that are empty or under-used.
| Cluster Autoscaler | Karpenter | |
|---|---|---|
| Model | Scales node groups (ASG, VMSS, MIG) up and down | Creates individual nodes that fit pending pods, chooses instance types freely |
| Speed | Minutes | Faster, bin-packs and consolidates |
| Config | Min/max per node group | NodePool and NodeClass objects |
| Where | Many clouds and Cluster API | Started on AWS, spreading to other clouds |
- Requests must be right: autoscalers decide using requests, not real usage
- Use PodDisruptionBudgets so that scale-down does not break availability
- Pods with local storage, no controller, or the annotation
cluster-autoscaler.kubernetes.io/safe-to-evict: falseblock scale-down - Keep a little headroom (overprovisioning pods with low priority) for fast bursts
- Set limits on maximum nodes to protect your budget
Putting It Together
| Goal | Combination |
|---|---|
| Web app with varying traffic | HPA on CPU or requests per second + Cluster Autoscaler/Karpenter |
| Queue workers | KEDA on queue length, scale to zero |
| Right-size stable services | VPA in recommendation mode, then update requests |
| Batch jobs on cheap nodes | Node pools with taints, spot instances, Karpenter |
Practice Tasks
- Create a Deployment with CPU requests, add an HPA and generate load until it scales
- Add a
scaleDownstabilization window and watch the effect - Install VPA in
Offmode and read the recommendations - Explain what happens when the HPA wants 20 pods but only 12 fit on nodes
- Design autoscaling for a queue-driven image processing service
Conclusion
HPA adds and removes pods using metrics and CPU requests, VPA right-sizes requests, KEDA scales from events, and Cluster Autoscaler or Karpenter adds and removes nodes for Pending pods. Set correct requests, PDBs and limits so scaling is safe and affordable.

