KEDA (Kubernetes Event-driven Autoscaling) WITH CRON
Berat Uyanık
·
1 minute read
The Midnight Madness: A DevOps Scenario
The clock strikes 20:55. You are on a Zoom call with your DevOps team, and the silence is deafening. At 21:00, exactly five minutes, the massive "Flash Sale" campaign begins. The marketing team has been pushing this for weeks, and push notifications are about to go out to millions of users.
Normally, your system is protected by the standard Kubernetes HPA (Horizontal Pod Autoscaler). The logic is simple and reactive: Traffic increases -> CPU usage spikes -> HPA detects the spike -> New Pods are requested.
But at 21:00:01, the scenario you fear unfolds: The traffic doesn't climb like a gentle ramp; it hits like a vertical wall.
In the critical 2-3 minutes it takes for HPA to wake up, request resources, and for new pods to pull images and reach "Ready" status, chaos ensues:
- Existing pods are crushed under the load, spiraling into CrashLoopBackOff.
- Users clicking "Add to Cart" are greeted with 503 Service Unavailable errors.
- Twitter starts flooding with complaints.
As you watch the monitoring dashboard, waiting helplessly for the new pods to spin up, you ask yourself: "We knew the exact time of the sale. Why did we wait for the traffic to hit us? Why weren't we there before the users?"
This is where the standard "Reactive" HPA fails. You need a "Proactive" solution. You need scaling based on the clock, not just the CPU.
Enter KEDA (Kubernetes Event-Driven Autoscaling) and the Cron Scaler. In this guide, we will teach your Kubernetes cluster to say, "Wake up at 20:55 and be ready for the storm."
What is KEDA?
KEDA (Kubernetes Event-driven Autoscaling) is an open-source project that provides event-driven autoscaling capabilities in your Kubernetes environment. KEDA extends Kubernetes' HPA (Horizontal Pod Autoscaler) system, allowing you to scale your applications based on metrics beyond CPU and memory.
Table of Contents
- Prerequisites
- Installation
- Installation with Helm
- Installation with YAML
- Scaling with Cron
- Creating a ScaledObject
- Troubleshooting
- Contributing
- License
Prerequisites
- Kubernetes cluster (v1.16+)
- kubectl CLI
- (Optional) Helm 3
- Cluster admin privileges
Installation
Installation with Helm
Installation with YAML
Verify the installation:
Expected output:
Scaling with Cron
Creating a ScaledObject
ScaledObject is the core component KEDA uses to scale Kubernetes deployments.
1. Create a sample deployment:
2. Define a ScaledObject:
Troubleshooting
To troubleshoot KEDA issues:
Contributing
To contribute to the KEDA project, you can submit a pull request via GitHub.
License
KEDA is distributed under the Apache 2.0 license.
https://www.cncf.io/projects
https://github.com/kedacore/keda/blob/main/LICENSE
https://github.com/kedacore/keda/releases