KEDA Overview
TOC
Introduction
KEDA is a Kubernetes-based Event Driven Autoscaler. Home Page. With KEDA, you can drive the scaling of any container in Kubernetes based on the number of events needing to be processed.
KEDA is a single-purpose and lightweight component that can be added into any Kubernetes cluster. KEDA works alongside standard Kubernetes components like the Horizontal Pod Autoscaler and can extend functionality without overwriting or duplication. With KEDA, you can explicitly map the apps you want to use event-driven scale, with other apps continuing to function. This makes KEDA a flexible and safe option to run alongside any number of any other Kubernetes applications or frameworks.
See the official documentation for more details: Keda Documentation
Advantages
Core advantages of KEDA:
- Autoscaling Made Simple: Bring rich scaling to every workload in your Kubernetes cluster.
- Event-driven: Intelligently scale your event-driven application.
- Built-in Scalers: Catalog of 70+ built-in scalers for various cloud platforms, databases, messaging systems, telemetry systems, CI/CD, and more.
- Multiple Workload Types: Support for variety of workload types such as deployments, jobs & custom resources with /scale sub-resource.
- Reduce environmental impact: Build sustainable platforms by optimizing workload scheduling and scale-to-zero.
- Extensible: Bring-your-own or use community-maintained scalers.
- Vendor-Agnostic: Support for triggers across variety of cloud providers & products.
- Azure Functions Support: Run and scale your Azure Functions on Kubernetes in production workloads.
How KEDA works
KEDA monitors external event sources and adjusts your app’s resources based on the demand. Its main components work together to make this possible:
- KEDA Operator keeps track of event sources and changes the number of app instances up or down, depending on the demand.
- Metrics Server provides external metrics to Kubernetes’ HPA so it can make scaling decisions.
- Scalers connect to event sources like message queues or databases, pulling data on current usage or load.
- **Custom Resource Definitions (CRDs)**define how your apps should scale based on triggers like queue length or API request rates.
In simple terms, KEDA listens to what’s happening outside Kubernetes, fetches the data it needs, and scales your apps accordingly. It’s efficient and integrates well with Kubernetes to handle scaling dynamically.
KEDA Custom Resource Definitions (CRDs)
KEDA uses Custom Resource Definitions (CRDs) to manage scaling behavior:
- ScaledObject: Links your app (like a Deployment or StatefulSet) to an external event source, defining how scaling works.
- ScaledJob: Handles batch processing tasks by scaling Jobs based on external metrics.
- TriggerAuthentication: Provides secure ways to access event sources, supporting methods like environment variables or cloud-specific credentials.
These CRDs give you control over scaling while keeping your apps secure and responsive to demand.
ScaledObject Example:
The following example targets CPU utilization of entire pod. If the pod has multiple containers, it will be sum of all the containers in it.
kind: ScaledObject
metadata:
name: cpu-scaledobject
namespace: <your-namespace>
spec:
scaleTargetRef:
name: <your-deployment>
triggers:
- type: cpu
metricType: Utilization # Allowed types are 'Utilization' or 'AverageValue'
metadata:
value: "50"