The Complete Production SOP: How to Deploy and Run KEDA Event-Driven Autoscaling for Queues & Cron in Autonomous AI Agents
Production SOP to install and run KEDA Event-Driven Autoscaling in Codex, Claude Code, and Cursor. Includes ScaledObject manifests and scale-to-zero fixes.
Technical Overview & Architectural Context
Autonomous coding agents frequently generate brittle Kubernetes autoscaling manifests when working with asynchronous workloads. Typical agent failures include conflicting standard HorizontalPodAutoscaler (HPA) definitions with KEDA ScaledObjects, generating deprecated KEDA API versions (v1alpha1 vs keda.sh/v1alpha1), misconfiguring scale-to-zero cooldown timings, and improperly hardcoding sensitive queue connection strings directly in trigger metadata rather than utilizing decoupled TriggerAuthentication resources. The keda-event-driven-autoscaling skill establishes strict procedural rails that mandate deterministic resource generation. By formalizing parameters for minReplicaCount, maxReplicaCount, cooldownPeriod, and external scaler configurations (AWS SQS, RabbitMQ, Kafka, Cron), this skill ensures coding assistants like Codex, Claude Code, Cursor, and Windsurf generate auditable, production-grade K8s manifests that scale cleanly from 0 to thousands of pods without manual intervention.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Create the local skill manifest directory and inject verified procedural rules into agent runtime path.
Autonomous runtimes parse SKILL.md manifests located in `.agents/skills` or `.cursor/rules` to establish system instructions and trigger matching. This step ensures the runtime loads the exact KEDA trigger schemas and parameter constraints before generating infrastructure-as-code manifests.
mkdir -p ~/.agents/skills/keda-event-driven-autoscaling && curl -fsSL https://askills.dev/api/skills/keda-event-driven-autoscaling/raw -o ~/.agents/skills/keda-event-driven-autoscaling/SKILL.md---
name: "keda-event-driven-autoscaling"
description: "Scale Kubernetes workloads from 0 to thousands of pods based on external queue depths and event streams."
metadata:
author: "KEDA"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "create keda scaledobject"
- "scale k8s to zero rabbitmq keda"
- "scale on sqs queue keda"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---Keep the runtime permissions to fs_write: 'workspace' and shell_exec: false. This allows the AI agent to draft valid YAML manifests without risking unauthorized cluster modifications or outbound credential leaking.
Do not rename the filename from SKILL.md. Agent runtime parsers in Windsurf and Cursor expect exact casing to compile procedural context into memory.
KEDA Core Installation & CRD Verification
Ensure KEDA operator and Custom Resource Definitions (CRDs) are installed on the target cluster.
Before directing the agent to scaffold ScaledObjects, verify that the cluster understands `keda.sh/v1alpha1`. Autonomous agents should be guided to deploy via standard Helm repositories and verify CRD availability prior to resource injection.
helm repo add kedacore https://kedacore.github.io/charts && helm repo update && helm upgrade --install keda kedacore/keda --namespace keda --create-namespacekubectl get crd scaledobjects.keda.sh triggerauthentications.keda.sh scaledjobs.keda.shInstruct the agent to use `TriggerAuthentication` with `secretTargetRef` or AWS IAM Roles for Service Accounts (IRSA) rather than inline plaintext credentials.
Avoid installing multiple KEDA operator versions across different namespaces. KEDA CRDs are cluster-scoped and concurrent operator instances will cause resource-lock race conditions.
Intent Matching & Trigger Invocation
Invoke deterministic autoscaling generation using tested natural language trigger phrases.
Provide the agent with clear workload specifications matching the registered skill triggers: queue metrics, target deployment names, and scale boundaries.
claude-code "create keda scaledobject for worker-deployment consuming from sqs queue orders-processing"apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: orders-processor-scaler
namespace: default
spec:
scaleTargetRef:
name: worker-deployment
minReplicaCount: 0
maxReplicaCount: 50
cooldownPeriod: 300
pollingInterval: 15
triggers:
- type: aws-sqs-queue
authenticationRef:
name: keda-aws-credentials
metadata:
queueURL: https://sqs.us-east-1.amazonaws.com/123456789012/orders-processing
queueLength: "10"
awsRegion: us-east-1
identityOwner: operatorExplicitly state target queue length thresholds per pod (e.g., `queueLength: '10'`) to prevent rapid pod thrashing under variable queue ingestion rates.
Never define a native `HorizontalPodAutoscaler` targeting the same deployment as a `ScaledObject`. KEDA internally generates and manages an HPA; manual duplicates result in scale flapping.
Manifest Validation, Dry-Run & Quality Gates
Execute dry-run schema validations and linting before committing generated manifests to Git.
The skill enforces validation gates where the agent must verify YAML syntax against K8s schemas using `kubeconform` or server-side dry runs before declaring task completion.
kubectl apply -f k8s/orders-scaledobject.yaml --dry-run=serverkubeconform -strict -kubernetes-version 1.28.0 -schema-location default -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' k8s/Use Datree's public CRD catalog in your agent's CI validation step to validate KEDA custom resources offline without cluster credentials.
Failure to quote numerical string values in the KEDA trigger metadata (e.g. queueLength: "10") can cause unmarshaling errors in strict YAML parsers.
Real-World Scenario: Scale RabbitMQ Celery Workers to Zero During Off-Peak Hours
“create keda scaledobject to scale k8s to zero rabbitmq keda for celery-workers. Queue name is 'tasks', threshold is 5 messages per worker, max 30 replicas, authenticated via rabbitmq-secret.”
Runtime Troubleshooting & Failure Modes
Root Cause: A manual HorizontalPodAutoscaler targeting 'worker-deployment' already exists in the cluster or workspace manifests, colliding with KEDA's internal HPA controller.
kubectl delete hpa worker-deployment && kubectl apply -f k8s/orders-scaledobject.yamlRoot Cause: The ScaledObject references a TriggerAuthentication or Secret that resides in a different namespace or has not been deployed prior to ScaledObject reconciliation.
kubectl create secret generic rabbitmq-secret --from-literal=host='amqp://user:[email protected]:5672/vhost' -n defaultFrequently Asked Questions (KEDA Event-Driven Autoscaling for Queues & Cron SOP)
Q:Can I use KEDA Event-Driven Autoscaling for Queues & Cron across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification. Once mounted in `~/.agents/skills/keda-event-driven-autoscaling` or your workspace root, any compliant runtime (Codex, Claude Code, Cursor, Windsurf) automatically detects the triggers and enforces the procedural SOP.
Q:How does KEDA Event-Driven Autoscaling for Queues & Cron prevent context window overflow during long agent sessions?
By isolating the exact YAML requirements, trigger types, and CRD schemas into standard SOP rules, the agent does not require repetitive prompt engineering or vast API documentation dumps within conversation history, reducing token consumption by over 60%.
Q:Does this skill require escalated root or container permissions?
No. The skill is audited with a security score of 98/100. It requires only standard workspace file write permissions to scaffold manifests. Shell execution and network access are restricted by default, making it safe for sandboxed agent workflows.
Ready to equip your autonomous agent with KEDA Event-Driven Autoscaling for Queues & Cron?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.