Kubernetes Blog
Follow
Kubernetes v1.37: Scale Workloads to Zero with HorizontalPodAutoscaler
Kubernetes v1.37 now offers Beta API support for scaling workloads down to zero replicas by default. This enables HorizontalPodAutoscalers to reduce idle resources to zero and then scale back up when needed. Previously, this functionality required external add-ons or alpha feature gates. Scaling to zero is particularly beneficial for workloads like queue consumers, where resource savings can be significant, especially with expensive dedicated hardware.The primary trade-off is an increased cold-start time as the system needs to observe metrics, schedule a pod, and initiate the application. This approach is most effective when work can be temporarily held in a durable queue. Unlike CPU or memory metrics which cease to exist when pods are gone, object and external metrics persist independently. This allows the HorizontalPodAutoscaler to continue monitoring metrics such as queue length even when no worker pods are running.To scale from zero, an external metrics adapter like the Prometheus Adapter is necessary to expose metrics such as queue consumer lag to Kubernetes. The HorizontalPodAutoscaler is then configured with a minimum of zero replicas and targets an external metric to dictate scaling. A special ScaledToZero status condition distinguishes automatic scaling down from a manual pause, ensuring the HorizontalPodAutoscaler can resume control. This feature, previously in Alpha, has graduated to Beta in v1.37 and is enabled by default for improved resource efficiency.