Sleep Tight, Cluster Right: Stop Burning Cash at 3 AM
Source: Dev.to
The Problem: Always‑On Clusters
Most Kubernetes clusters run 24/7 even when users aren’t active. CPU‑based HPAs try to help but quickly break down, especially when a VPA is added. Without smarter scaling, HPAs and VPAs fight each other, leaving idle pods and wasted resources.
Event‑Driven Scaling with KEDA
KEDA lets us scale based on real events instead of guesses:
- Prometheus scalers – trigger scaling when relevant metrics indicate work.
- Cron scalers – define explicit windows (e.g., off‑hours) to scale workloads down.
During peak hours, metric triggers drive rapid scale‑out. During low‑traffic periods, cron triggers enforce predictable scale‑down. By combining both, a workload runs only when there is work to do. As soon as requests arrive, pods scale out quickly; a longer scale‑down period handles any remaining traffic before the cluster shrinks again.
Node‑Level Autoscaling with Karpenter
Even with perfect pod scaling, idle nodes still cost money. Karpenter complements KEDA by:
- Consolidating and terminating empty nodes as soon as workloads disappear.
- Provisioning larger, “beefy” nodes only when needed.
- Using cron triggers to warm nodes in the morning, ensuring zero‑toil readiness for developers.
If early‑bird traffic occurs at night, metric‑based scaling takes over after the cron window, keeping pods available when required.
Putting It All Together
-
Define KEDA triggers
- Prometheus scaler for request‑rate or latency metrics.
- Cron scaler for known off‑peak windows.
-
Configure VPA to adjust pod resources without conflicting with HPA (KEDA replaces HPA).
-
Enable Karpenter with appropriate provisioner settings (instance types, limits, consolidation policies).
-
Add a warm‑up cron trigger so nodes are ready before the first developer logs in.
Benefits
- Cost savings – no payment for idle compute or standby nodes.
- Predictable performance – workloads scale exactly when needed.
- Reduced operational toil – automatic node provisioning and termination.
- Efficient use of resources – pods and nodes are only present during active periods.
Stop paying for idle time. Let KEDA’s event‑based triggers and Karpenter’s node management make your infrastructure work for you.