Kubernetes interview question · Most asked

How does autoscaling work in Kubernetes? Compare HPA, VPA, Cluster Autoscaler and Karpenter.

Summary

The Horizontal Pod Autoscaler changes the number of replicas based on metrics (CPU, memory, or custom and external metrics); the Vertical Pod Autoscaler recommends or sets CPU and memory requests; the Cluster Autoscaler and Karpenter add and remove nodes so pending pods can be scheduled and empty nodes are removed.

Longer Answer

  • HPA needs the metrics server (or a metrics adapter such as Prometheus Adapter or KEDA for queue length and other event sources). CPU-based HPA only works if CPU requests are set and CPU reflects load.
  • VPA and HPA should not both act on the same resource metric for the same workload.
  • Cluster Autoscaler scales predefined node groups; Karpenter provisions right-sized nodes directly from pending pods' requirements and consolidates under-used nodes, which is often faster and cheaper (mainly on AWS, also on other clouds through providers).

Scaling chains add latency: a traffic spike must be detected, pods created, nodes provisioned (minutes) and images pulled, so keep headroom or over-provision with low-priority placeholder pods.

Key Points

  • HPA: replicas; VPA: requests; CA/Karpenter: nodes.
  • HPA needs metrics and requests.
  • KEDA for event-driven scaling.
  • Node scaling takes minutes; keep headroom.

More most-asked Kubernetes questions

← All Kubernetes questions