Simple "Kubernetes Event Driven Autoscaling" KEDA demonstration for AWS EKS.
This repository:
- Deploys a simple SQS consumer (and shares SQS values w/prometheus).
- Deploys KEDA to cluster, to scale the consumer depending upon SQS message population.
- Assumes same AWS account, region, etc.
- Create a AWS SQS queue
- Create a IAM role
- example
- Be sure to add SQS permissions
- Create a namespace for your test
kubectl create ns guytest
- Create service account
- Be sure to update the annotation to reflect the IAM role.
kubectl apply -f service_account.yaml
- Create an IRSA account that grants access to SQS
- iam_role.json is an example
- be sure to add SQS access to role
- Deploy the SQS consumer to your cluster.
- "elder-peeler" is the name of the SQS consumer.
- There is a Dockerfile to help you get started.
- SQS queue name is defined within Dockerfile
- There is a deployment.yaml to help you get started
- Sanity test.
- There should be an elder-peeler pod active in your namespace.
- Write some messages to SQS (via the console or try producer.py
- Tail the pod log and it should be writing happy messages about message consumption.
- Optional prometheus step
- Apply pod-monitor.yaml and elder-peeler and prometheus will scrape elder-peeler
- exposes peeler_messages_available and peeler_messages_consumed
- Apply pod-monitor.yaml and elder-peeler and prometheus will scrape elder-peeler
- Create a IAM role
- example
- Be sure to add SQS permissions
- Install KEDA via helm
helm install keda kedacore/keda --namespace keda --create-namespace --version 2.13.2 -f values.yaml
- Note that values.yaml contains the ARN of keda role.
- It takes a minute for gRPC to get connected
- Apply ScaledObject
kubectl apply -f scaled.yaml
- Verify ScaledObject
kubectl describe scaledobject guyscaler -n guytest
- my results
- Test KEDA
- Write messages to your SQS queue.
- Before KEDA, there would have been only a single replica for all traffic but now the scaler should create many pods handle the increase in SQS traffic.
- After the SQS queue is emptied, the pods will all be removed by KEDA
- Cleanup
- Be sure to read cleanup instructions on KEDA website, it isn't enough to invoke
helm delete
- Be sure to read cleanup instructions on KEDA website, it isn't enough to invoke