Scale on events with KEDA

DevOps, Hands On20 minutesCosts moneySteps checked 14 November 2026By Cloud Hands On

In this task you'll scale a worker on queue length, down to zero.

KEDA (Kubernetes Event-driven Autoscaling) scales a deployment on an outside signal, such as messages waiting in a queue, instead of CPU. It can scale to zero pods when there's nothing to do, and back up when work arrives.

You write a ScaledObject (what to scale, between which limits, on which trigger) and, for credentials, a TriggerAuthentication that reads them from a Secret. On AKS, KEDA comes as an add-on Azure manages.

Example. SS Kaiser's order worker runs zero pods overnight and five at lunchtime, driven by how many orders are waiting in the queue.

Costs money. This task creates resources that are charged while they exist. Delete them as soon as you finish.

Before you start

You need: An AKS cluster. Time: 20 minutes.

Where to look

  1. Kubernetes services
  2. (cluster)
  3. Settings
  4. Application scaling

Steps

  1. Turn on the add-on: az aks update -g <group> -n <cluster> --enable-keda.
  2. Put the connection in a Secret and write a TriggerAuthentication that reads it.
  3. Write a ScaledObject: the deployment, minReplicaCount 0, maxReplicaCount, and an azure-queue trigger with queueName and queueLength (messages per pod).
  4. Put messages on the queue and watch kubectl get deploy -w.

Commands

# Connect kubectl to the cluster first
az aks get-credentials -g <group> -n <cluster>
az aks update -g <group> -n <cluster> --enable-keda
kubectl get scaledobject -A
kubectl describe scaledobject <name> -n <namespace>

Watch out for

Cost
The add-on is free; more pods may need more nodes.
Security
Keep connection strings in Secrets, or better, use workload identity; never inline in the ScaledObject.
Common mistakes
queueLength not in quotes, and adding an HPA as well: once KEDA is in charge, it owns the replica count.

Clean up

kubectl delete scaledobject <name> hands the replica count back to you.

Words to know

KEDA
Kubernetes Event-driven Autoscaling: scales pods on events such as queue length.
ScaledObject
KEDA's object that ties a deployment to a trigger and replica limits.
TriggerAuthentication
KEDA's object that supplies a trigger's credentials from a Secret or identity.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going