/kubernetes-platform-skills:keda-event-driven-autoscaling-configurationfrom kubernetes-platform-skills
Configures KEDA ScaledObject and ScaledJob resources for event-driven pod autoscaling on Kafka lag, SQS/Azure queue depth, Prometheus queries, or cron schedules. Supports scaling to zero.
Ships in kubernetes-platform-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The built-in Kubernetes HorizontalPodAutoscaler (HPA) can only scale on
metrics it understands natively — CPU and memory, or a custom/external
metric wired through the metrics API, which most teams never bother to
build. KEDA closes that gap: it runs as a metrics adapter that exposes
external event-source state (Kafka consumer lag, an SQS queue's message
count, a Prometheus query result, a cron window) to the standard HPA
machinery, and it can additionally scale a workload to zero replicas
when there is no work at all — something the stock HPA cannot do on its
own. KEDA operates entirely at the pod level, deciding how many
replicas of a Deployment (or how many Jobs) should exist right now;
it says nothing about whether the cluster has enough node capacity to
run them, which is
Karpenter's
job. A cluster commonly runs both together: KEDA decides pod count from
event backlog, Karpenter provisions the nodes those pods land on. This
skill covers designing ScaledObject/ScaledJob and
TriggerAuthentication resources correctly; validating them (thresholds,
auth, cooldowns) before production is covered separately in
keda-configuration-validation.
Deployment up when a Kafka topic's consumer lag grows, and
back down (including to zero) once the backlog drains.Deployment poller
into a ScaledJob that spawns one Job per unit of work and scales
the number of concurrent Jobs with backlog.kedacore/keda Helm chart into a keda namespace), which installs
the keda-operator, keda-operator-metrics-apiserver, and the KEDA
CRDs (ScaledObject, ScaledJob, TriggerAuthentication,
ClusterTriggerAuthentication).Deployment/StatefulSet (for ScaledObject)
already exists and is otherwise healthy — KEDA scales an existing
workload, it does not create one.Secret, referenced via TriggerAuthentication —
never inlined directly into the ScaledObject spec.metrics-server is not required for KEDA
scalers themselves (KEDA runs its own metrics adapter), but is still
needed if the same ScaledObject also wants to blend in a CPU/memory
trigger alongside an external one.Start from the workload's existing scale target, and set an
explicit floor and ceiling — never leave minReplicaCount at its
implicit default without thinking about cold-start latency:
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: order-consumer-scaledobject
namespace: orders
spec:
scaleTargetRef:
name: order-consumer # existing Deployment
minReplicaCount: 1 # see warning below re: minReplicaCount: 0
maxReplicaCount: 20
cooldownPeriod: 300 # seconds at 0 activity before scaling toward min
pollingInterval: 30 # seconds between metric checks
triggers:
- type: kafka
metadata:
bootstrapServers: kafka-broker-1.orders.svc:9092,kafka-broker-2.orders.svc:9092
consumerGroup: order-consumer-group
topic: order-events
lagThreshold: "50"
activationLagThreshold: "5"
authenticationRef:
name: order-consumer-kafka-auth
Warning: minReplicaCount: 0 (scale-to-zero) means the first
event after an idle period has to wait for a pod to schedule, pull
its image, and become ready before it's processed — for a
latency-sensitive consumer this cold-start latency spike can violate
an SLO even though "average" latency looks fine. Only use
minReplicaCount: 0 for genuinely bursty, latency-tolerant, or
cost-dominant workloads; keep minReplicaCount: 1 (or higher) for
anything with a real online-latency requirement.
Create a TriggerAuthentication referencing a Secret, not literal
credentials in the trigger metadata:
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: order-consumer-kafka-auth
namespace: orders
spec:
secretTargetRef:
- parameter: sasl
name: kafka-scaler-credentials
key: sasl-mechanism
- parameter: username
name: kafka-scaler-credentials
key: username
- parameter: password
name: kafka-scaler-credentials
key: password
- parameter: tls
name: kafka-scaler-credentials
key: tls
On a cloud provider, prefer workload identity over static secrets
where the scaler supports it (podIdentity: { provider: aws-eks }
for an IAM role bound via IRSA, or the Azure/GCP equivalents) so no
long-lived credential material needs to be stored in the cluster at
all.
For a cloud queue depth trigger (SQS shown; Azure Service Bus and GCP Pub/Sub scalers follow the same shape with provider-specific metadata keys):
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: image-resize-worker-scaledobject
namespace: media
spec:
scaleTargetRef:
name: image-resize-worker
minReplicaCount: 0
maxReplicaCount: 50
cooldownPeriod: 120
triggers:
- type: aws-sqs-queue
metadata:
queueURL: https://sqs.<REGION>.amazonaws.com/<AWS_ACCOUNT_ID>/image-resize-jobs
queueLength: "10" # target messages-per-replica
awsRegion: "<REGION>"
identityOwner: operator # use the KEDA operator's IRSA role
queueLength is a target, not a hard cap: KEDA computes desired
replicas as ceil(currentQueueDepth / queueLength), bounded by
minReplicaCount/maxReplicaCount — tune it based on how long one
replica takes to process one message's worth of backlog, not an
arbitrary round number.
For a custom business metric, use the Prometheus scaler against an existing Prometheus/Thanos endpoint:
triggers:
- type: prometheus
metadata:
serverAddress: http://prometheus.monitoring.svc:9090
metricName: pending_orders_count
query: sum(pending_orders_total{queue="fulfillment"})
threshold: "100"
activationThreshold: "10"
threshold sets the per-replica target the same way queueLength
does for a queue scaler; activationThreshold (available on most
scalers) controls the point below which KEDA scales to
minReplicaCount (or zero) rather than merely capping growth — set
it deliberately rather than leaving it equal to threshold, which
would cause replicas to flap right at the boundary.
For a predictable schedule, use the cron trigger, typically
combined with another trigger so cron sets a floor rather than being
the only signal:
triggers:
- type: cron
metadata:
timezone: America/New_York
start: "0 6 * * 1-5" # 6am weekdays
end: "0 20 * * 1-5" # 8pm weekdays
desiredReplicas: "5"
- type: kafka
metadata:
bootstrapServers: kafka-broker-1.orders.svc:9092
consumerGroup: order-consumer-group
topic: order-events
lagThreshold: "50"
KEDA takes the maximum replica count implied by any active trigger, so the cron trigger here guarantees at least 5 replicas during business hours while the Kafka trigger can still scale higher if lag spikes.
For batch/queue-drain workloads, prefer ScaledJob over
ScaledObject so each unit of work gets its own Job/pod rather
than being multiplexed onto a long-running consumer process:
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
name: video-transcode-scaledjob
namespace: media
spec:
jobTargetRef:
parallelism: 1
completions: 1
backoffLimit: 2
template:
spec:
containers:
- name: transcoder
image: registry.example.com/video-transcoder:1.4.2
restartPolicy: Never
minReplicaCount: 0
maxReplicaCount: 30
pollingInterval: 15
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 3
scalingStrategy:
strategy: default
triggers:
- type: aws-sqs-queue
metadata:
queueURL: https://sqs.<REGION>.amazonaws.com/<AWS_ACCOUNT_ID>/transcode-jobs
queueLength: "1"
awsRegion: "<REGION>"
With ScaledJob, maxReplicaCount caps the number of concurrent
Jobs, not a Deployment's replica count — each scaled instance runs
to completion and exits, which fits idempotent, one-shot batch work
far better than an ever-running consumer pod that a ScaledObject
would restart in place.
minReplicaCount and maxReplicaCount explicitly —
an unbounded maxReplicaCount (or one left at KEDA's default) can
let a runaway backlog spike scale a workload out far enough to starve
cluster capacity or a downstream dependency (a database connection
pool, a rate-limited third-party API) that wasn't sized for that many
concurrent callers.minReplicaCount: 0 as a deliberate cost/latency trade-off, not
a default — document the expected cold-start time for the workload's
image/readiness probe and confirm it's acceptable for the consumer of
that workload before enabling scale-to-zero.activationLagThreshold/activationThreshold distinctly from the
main lagThreshold/threshold so a workload doesn't flap between 0
and 1 replicas right at the boundary of "any work at all."pollingInterval proportional to how quickly the event source's
metric actually changes — polling a slow-moving queue every 5 seconds
wastes API calls against the source (and can hit rate limits on a
cloud provider's queue API), while polling a fast-moving one only
every few minutes delays reaction to a real backlog spike.Secret referenced by
TriggerAuthentication (or use workload identity), and scope that
Secret's RBAC access to only the namespace(s) that need it — the same
least-privilege discipline applied to CI service accounts elsewhere in
this repo.Symptom: A workload scaled by KEDA with minReplicaCount: 0
produces a burst of request timeouts or a visible latency spike every
time it wakes up from idle.
Fix: This is the cold-start cost of scale-to-zero. Either set
minReplicaCount: 1 (accepting the idle-cost trade-off) for anything
with a real online-latency requirement, or pre-warm via a cron trigger
that guarantees a floor of replicas during expected traffic windows,
and separately reduce cold-start time itself (smaller image, faster
readiness probe).
Symptom: A ScaledObject targeting a Deployment that also has a
manually-configured HPA on the same target shows replica count
flapping unpredictably, or the HPA appears to be "fighting" KEDA.
Fix: KEDA creates and manages its own HPA object behind the
scenes for every ScaledObject — a second, independently-created HPA
on the same scaleTargetRef conflicts with it. Delete the manual HPA
and let KEDA's generated one be the only autoscaler for that target.
Symptom: A ScaledObject never scales past minReplicaCount
despite the event source clearly having a growing backlog (confirmed
by directly checking the Kafka consumer group or queue depth).
Fix: Check the keda-operator pod's logs for the specific
scaler's error — most commonly a TriggerAuthentication referencing
the wrong Secret key name, a network path the operator can't reach
(firewall/security-group blocking the metrics adapter from the
broker/queue endpoint), or a typo in bootstrapServers/queueURL.
KEDA fails a broken trigger silently from the workload's perspective —
it just never scales — so the operator's own logs, not the workload,
are where the actual error surfaces.
Symptom: A ScaledJob for a batch workload leaves large numbers
of completed/failed Job objects accumulating in the namespace,
slowing down kubectl operations and cluttering the namespace.
Fix: Set successfulJobsHistoryLimit and
failedJobsHistoryLimit to a small bounded number (a handful, not the
default of keeping everything) rather than leaving cleanup to manual
intervention.
Symptom: Scaling reacts correctly to backlog growth but takes
much longer than expected to scale back down once the backlog drains.
Fix: This is very likely cooldownPeriod doing exactly what it's
configured to do — KEDA intentionally waits cooldownPeriod seconds
of sustained zero/low activity before scaling toward minReplicaCount,
to avoid flapping on a momentarily-empty queue. Tune the value rather
than treating the delay as a bug; a very low cooldownPeriod trades
faster scale-down for more replica churn.
Scenario: order-consumer processes messages from the order-events
Kafka topic. Under normal load one replica keeps up; during flash-sale
traffic, lag can spike to thousands of messages and the team wants
automatic scale-out (bounded, to protect a downstream payment API) and
scale-back-in once the backlog clears, without ever going below one
running replica (an online consumer, not a pure batch job).
TriggerAuthentication referencing existing SASL credentials:
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: order-consumer-kafka-auth
namespace: orders
spec:
secretTargetRef:
- parameter: sasl
name: kafka-scaler-credentials
key: sasl-mechanism
- parameter: username
name: kafka-scaler-credentials
key: username
- parameter: password
name: kafka-scaler-credentials
key: password
ScaledObject:
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: order-consumer-scaledobject
namespace: orders
spec:
scaleTargetRef:
name: order-consumer
minReplicaCount: 1
maxReplicaCount: 15
cooldownPeriod: 300
pollingInterval: 20
triggers:
- type: kafka
metadata:
bootstrapServers: kafka-broker-1.orders.svc:9092,kafka-broker-2.orders.svc:9092
consumerGroup: order-consumer-group
topic: order-events
lagThreshold: "100"
activationLagThreshold: "10"
authenticationRef:
name: order-consumer-kafka-auth
maxReplicaCount: 15 was chosen deliberately after confirming the
downstream payment API's connection pool and rate limit can absorb 15
concurrent consumer instances without being overwhelmed — a value picked
without that check would just move the bottleneck (and the incident)
downstream instead of preventing it. During a flash sale, lag crosses
100 messages per partition, KEDA's generated HPA scales order-consumer
toward 15 replicas over a few polling intervals, and once lag drops back
under the activationLagThreshold for a full cooldownPeriod, it scales
back to the minReplicaCount floor of 1 rather than to zero, keeping the
consumer warm for the next order.
ScaledObject/TriggerAuthentication configuration (auth, thresholds, cooldowns) before it reaches production.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin kubernetes-platform-skills35 skills in this plugin
/cert-manager-tls-automationGuides installing and configuring cert-manager for automated TLS certificate issuance and renewal — Issuers vs. ClusterIssuers, ACME/ Let's Encrypt HTTP-01 and DNS-01 challenges, private-CA issuance, and integration with Ingress-nginx and Istio gateways. Use when a user asks to "automate TLS certificates on Kubernetes," "set up cert-manager with Let's Encrypt," "fix a stuck Certificate that won't become Ready," "use DNS-01 for a wildcard cert," "rotate mTLS certs automatically," or "issue certs from an internal CA."
/cni-networking-calico-flannelGuides choosing and installing a Kubernetes CNI plugin — Calico vs. Flannel — including NetworkPolicy enforcement capability differences, BGP vs. VXLAN/overlay data paths, and IP address management (IPAM) tradeoffs. Use when a user asks to "choose a CNI plugin for Kubernetes," "enable NetworkPolicy enforcement," "set up Calico with BGP peering," "install Flannel," "debug pod-to-pod connectivity across nodes," or "migrate from Flannel to Calico."
/complete-kubernetes-deployment-on-aks-from-scratchSequences a complete, end-to-end AKS deployment from a bare Azure subscription to a production-ready cluster serving a first workload — Azure landing zone prerequisites, AKS cluster and node pool provisioning, Azure CNI (with the Calico/Cilium alternative noted), ingress (Application Gateway Ingress Controller vs. ingress-nginx), cert-manager with Azure DNS, conformance validation, a Helm-deployed workload, and a node/cluster health baseline. This is an integration/orchestration skill that sequences several existing tool-specific skills in the correct order and flags the handoff points between them — it does not restate their internals. Use when a user asks to "deploy a Kubernetes cluster on AKS from scratch," "set up a new AKS environment end to end," "build a production AKS cluster from a fresh Azure subscription," or "give me the full sequence to go from nothing to a working AKS cluster."
Other plugins' skills for the same job