CICD-286 · KEDA autoscaling deployment
Encyclopedia · Advanced Kubernetes operations · All snippets
Previous · CICD-285 · Next · CICD-287
1. Where it fits
- Placement In the KEDA ScaledObject manifest for the worker namespace.
- Prerequisites kubectl, isolated cluster or namespace and installed CRDs when named.
- Platforms kubernetes, local-lab.
2. Copy the snippet
yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata: {name: worker}
spec:
scaleTargetRef: {name: worker}
minReplicaCount: 0
maxReplicaCount: 5
triggers:
- type: rabbitmq
metadata: {protocol: amqp, queueName: jobs, mode: QueueLength, value: "10"}
authenticationRef: {name: rabbitmq-auth}3. How it works
KEDA reads RabbitMQ queue length using the referenced authentication. The target value guides scaling within the declared replica bounds as the queue grows or drains.
Queue length drives replica count, subject to lower and upper bounds.
flowchart TD N1["RabbitMQ queue"] N2["KEDA metric"] N1 --> N2 N3["TriggerAuthentication"] N3 --> N2 N4["Generated HPA"] N2 --> N4 N5["Replica bounds"] N5 --> N4 N6["Worker replicas"] N4 --> N6
4. Verify the result
Install KEDA and a TriggerAuthentication with RabbitMQ connection credentials. Send a sample message and observe replicas scale within the configured cap.
Validation version-dependent (YAML parse). Status definitions.