This repository contains the necessary files and instructions to deploy and configure KEDA (Kubernetes-based Event Driven Autoscaling) and Karpenter (Kubernetes Node Autoscaler) on an Amazon Elastic Kubernetes Service (EKS) cluster.
KEDA enables autoscaling of Kubernetes pods based on the number of events in event sources such as Azure Service Bus, RabbitMQ, Kafka, and more. Karpenter is a Kubernetes node autoscaler that scales the number of nodes in your cluster based on resource usage.
Before you begin, ensure that you have the following prerequisites:
kubectl
) installed.To install KEDA and Karpenter on your AWS EKS cluster, follow these steps:
Clone this repository to your local machine or download it as a ZIP file.
git clone https://github.com/aws-samples/amazon-eks-scaling-with-keda-and-karpenter.git
Navigate to the repository's directory.
cd amazon-eks-scaling-with-keda-and-karpenter
Update environmentVariables.sh file in /deployment
Variable Name | Description |
---|---|
AWS_REGION |
The AWS region. |
ACCOUNT_ID |
The AWS account ID. |
TEMPOUT |
Temporary output file. This used to temp. store CFN for karpenter |
DYNAMODB_TABLE |
The name of the DynamoDB table. |
CLUSTER_NAME |
The name of the EKS cluster. |
KARPENTER_VERSION |
The version of Karpenter. |
NAMESPACE |
The Kubernetes namespace for KEDA. |
SERVICE_ACCOUNT |
The Kubernetes service account for KEDA. |
IAM_KEDA_ROLE |
The IAM role for KEDA. |
IAM_KEDA_SQS_POLICY |
The IAM policy for KEDA to access SQS. |
IAM_KEDA_DYNAMO_POLICY |
The IAM policy for KEDA to access DynamoDB. |
SQS_QUEUE_NAME |
The name of the SQS queue. |
SQS_QUEUE_URL |
The URL of the SQS queue. |
SQS_TARGET_DEPLOYMENT |
The target deployment for KEDA to scale based on SQS messages. |
SQS_TARGET_NAMESPACE |
The target namespace for the deployment that KEDA scales based on SQS messages. |
To strat deployment run
sh ./deployment/_main.sh
You will be asked to verfiy the account in context
Select your deployment option
If you are experiencing error while deploying Karpenter, it can be due to Karpenter repository currently supports limited version and you may be havign old version in environmentVariables.sh. Please follow steps below:
Please check latest karpenter version from https://karpenter.sh -> Getting Started. environmentVariables should match with supported version
Check file createkarpenter.sh under deployment-->karpenter line 80 - 90 and compare with karpneter getting started helm https://karpenter.sh/
I have used iTerm2 on Mac with K9s
to connect with cluster and run scripts
Once Cluster, Karpenter & KEDA is deployed
Open two more terminal and connect to cluster using K9s (check Prerequisites)
In first terminal with K9s, navigate to keda-test
namespace pod
view
In seconds terminal with k9s, navigate to Nodes
Open three or more terminals, copy content from deployment/environmentVariables.sh
and run it on all three terminal
In the terminal run below command to test Karpenter status. If you see error first fix it before moving furthe
kubectl logs -f -n karpenter -l app.kubernetes.io/name=karpenter -c controller
7. Run `keda-mock-sqs-post.py` script on all four terminals
```shell
cd app/keda
python3 -m venv env
source env/bin/activate
pip install boto3
cd {your path}/amazon-eks-scaling-with-keda-and-karpenter
python3 ./app/keda/keda-mock-sqs-post.py
Pod sclaing using KEDA
Node scaling using Karpenter
Navigate to the repository's root directory.
cd amazon-eks-scaling-with-keda-and-karpenter
To strat cleanup
sh ./cleanup.sh
This will delelte all the AWS services and workloads created for the solution.
The repository contains the necessary configuration files for deploying KEDA and Karpenter. You can modify these files to suit your specific requirements. Here are some important files to note:
Feel free to modify these files according to your needs.
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file..