INFRA Signal 152
Kubernetes v1.37: Scale Workloads to Zero with HorizontalPodAutoscaler
Illustration only Photo by Chris Linnett on Unsplash
Kubernetes v1.37 adds Beta support for scaling workloads to zero replicas via HPA, enabled by default.
Engineers running queue consumers or batch processors can now let the HPA remove idle Pods that reserve expensive resources like CPUs or GPUs, cutting costs. The trade-off is cold-start latency when work arrives, so it suits workloads that can wait in a durable queue. HTTP workloads need a separate buffering layer because Kubernetes Services do not buffer requests while no Pods are ready.
Written by elseif from the cluster below · every claim links back to a sourceThe three things worth knowing
HPA can now scale workloads to zero replicas using object or external metrics, which remain available when no Pods run.
The feature is Beta and enabled by default in v1.37, removing the need for add-ons or an Alpha feature gate.
A ScaledToZero status condition distinguishes HPA-owned zero state from manually paused workloads.
THE READ
What the cluster adds up to.
Kubernetes v1.37 makes scale-to-zero autoscaling a Beta feature enabled by default. Previously, scaling a workload to zero required an add-on or external component, or enabling the Alpha feature gate. Now, a HorizontalPodAutoscaler can reduce a workload to zero replicas and bring it back when a suitable object or external metric changes. This is a core API change that removes a significant barrier to cost savings for idle workloads.
The key technical shift is the reliance on object or external metrics rather than CPU or memory. CPU and memory metrics come from running Pods, so at zero replicas there is no signal to scale back up. Object and external metrics, such as queue length, exist independently of the workers. The HPA can continue reading the queue length while no workers are running, allowing it to scale up when work arrives.
Adopting this feature costs cold-start time. The HPA must observe the metric, schedule a Pod, and start the application, which works well when work can wait in a durable queue. However, Kubernetes Services do not buffer requests while no Pods are ready, so HTTP and other request-driven workloads need a separate buffering layer. Additionally, manually setting a Deployment to zero pauses autoscaling; the HPA will not wake a workload it did not scale down itself.
The HPA distinguishes its own zero state from a paused workload using a ScaledToZero status condition. When the HPA scales a workload to zero, it records ScaledToZero=True, and later changes it to False when scaling back up. A workload at zero without that condition remains paused. The default downscale stabilization window of five minutes prevents a short drop in queue length from immediately removing all workers.
This feature stops working when the metric is unavailable. An HPA cannot scale from zero if its metric cannot be read, so the metrics pipeline must be verified first. It also only works with object or external metrics; CPU and memory metrics cannot drive scale-to-zero because they vanish with the Pods. For workloads that can tolerate cold starts and have an independent metric, this is a straightforward way to reduce resource costs.
Written by elseif from the cluster below · checked for specifics the sources never containedTHE CLUSTER