Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 32/ 160
02. Workload Controllers & Scaling

Custom & External Metrics Scaling with KEDA (Event-Driven Autoscaling)

Scale on queues, lag, and external events with KEDA scalers.

AdvancedKEDA · External Metrics · Event-Driven3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

KEDA is a warehouse loading dock whose shutter opens when the truck queue appears and closes after the last parcel is handled. The simple Kubernetes rule is: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

Think of it like…

KEDA is a warehouse loading dock whose shutter opens when the truck queue appears and closes after the last parcel is handled.

Where you’ve seen it

During a release or scale event, the workload owner runs kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker. Expected evidence: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold. If the run instead shows this symptom, stop and restore the last known state: KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely.

Words you’ll hear

KEDA
For this lesson, KEDA is the controlling idea: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.
External Metrics
External Metrics is the checkpoint; run kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker and inspect the owner chain. KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely.
Event-Driven
Event-Driven is the outcome to preserve; the cost is explicit: Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation.
Verification evidence
The evidence command is kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker. It connects the declaration to this behavior: Scale on queues, lag, and external events with KEDA scalers.

Visual diagram

Loading interactive diagram

Theory & deep dive

How KEDA reaches the intended state

Scale on queues, lag, and external events with KEDA scalers. KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

The concrete checkpoint is kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker; compare the KEDA owner, External Metrics state, and Event-Driven outcome instead of treating YAML acceptance as proof.

Verify External Metrics, not only object creation

Run kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker after the change and correlate the result with Events and the owning object. KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

Key takeaway: KEDA is implemented only when this invariant remains observable: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

External Metrics: failure boundary and production cost

KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely. The prerequisite contract is concrete: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation. A safe design limits blast radius, records the last good configuration, and uses kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker as a deterministic rollback checkpoint.

Recover from External Metrics drift

Capture the current state with kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely.

Key takeaway: Accept the trade-off consciously: Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation.

How it works, step by step

Step 1 of 4
Workload author

1. Declare workload intent

Write the controller-owned Pod or scaling intent and preserve the owner chain: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

KEDA contract → owned state
Key numbers at this step
Goal
Scale on queues, lag, and external events with KEDA scalers.
Owner
KEDA

When to use it & trade-offs

What it is

Scale on queues, lag, and external events with KEDA scalers. KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

Why it matters: KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely. The invariant at risk is specific: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold. The quickest fact check before changing the design is kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker.

When to reach for it

  • Use KEDA to enforce this invariant: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.
  • Use External Metrics evidence from kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker in reviews and incident timelines. Scale on queues, lag, and external events with KEDA scalers.
  • Choose the progressive-delivery layer route only when this cost is justified by governance or scale: Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation.

When to avoid or be careful

  • Avoid assuming KEDA is complete after YAML submission; the required behavior is concrete: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.
  • Avoid treating the next symptom as random; check the owner and state with kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker first: KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely.
  • Avoid adopting a heavier platform wrapper before measuring its cost: Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation.

Native, manual, and managed paths for KEDA

Controller-managed workload
Best for: Scale on queues, lag, and external events with KEDA scalers. A concrete incident check is kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker.

Strengths: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

Watch out: Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation. Recovery must also recognize this signal: KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely.

Hand-managed Pods
Best for: Quickly testing the External Metrics assumption with kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker; the expected invariant is: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

Strengths: kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike KEDA, it does not make this symptom self-documenting: KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely.

Progressive-delivery layer
Best for: Teams that need Event-Driven integrated with guardrails; the evidence path is kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.

Watch out: The added platform ownership buys value at this cost: Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.
  • Trace KEDA to Event-Driven through External Metrics; the invariant is: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.
  • Recognize the symptom: KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely.
  • Justify the cost: Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation.
  • Verify with kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker instead of only inspecting YAML.

Benchmarks & rules of thumb

0 -
replicas are allowed while idle when the scaler permits activation from zero
2 -
KEDA-specific checks: trigger credentials and activation metric
1 -
HPA commonly receives the external or object metric

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the KEDA owner contract: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold.
  • Ignoring this telltale condition leads to unrelated changes: KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely.
  • Repeating kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker without an owner for remediation wastes retry cost. Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold?
  • Which owner object, logs, and Events would you inspect for this symptom-KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely-?
  • At what threshold would this cost become unacceptable: Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation?
Interview tip: Interview sequence: state the invariant, run kubectl get scaledobject,scaledjob,hpa; kubectl describe scaledobject queue-worker, name the failure, then justify the cost. Invariant: KEDA creates or configures HPA metrics from event sources and can activate a Deployment from zero when queue depth, lag, or an external metric crosses a threshold. Failure: KEDA can repeatedly scale up on the backlog but remain at zero if a scaler cannot authenticate, emits no current activation metric, or a message is not checkpointed safely. Cost: Scale-to-zero removes idle cost but adds cold start and makes the event source the control plane for workload activation.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Custom & External Metrics Scaling with KEDA (Event-Driven Autoscaling) with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Horizontal Pod Autoscaler (HPA) & Metrics Server
Next topic
Vertical Pod Autoscaler (VPA) & In-Place Pod Vertical Scaling