Scale replicas in AWS EKS based on multiple conditions of a custom Cloudwatch metric

Viewed 47

I am fairly new to EKS. I want to autoscale on the basis of no of messages in my SQS queue. I have read about HPA in kubernetes (https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) and also went through this aws blog (https://aws.amazon.com/blogs/compute/scaling-kubernetes-deployments-with-amazon-cloudwatch-metrics/) but this doesn't work for me because my scaling policy looks like this :

if 0 < sqs_message_count < 15:
        set replicas: 1
if 15 <= sqs_message_count < 32:
        set replicas: 2
if 32 <= sqs_message_count < 53:
        set replicas: 4
if 53 <= sqs_message_count < 105:
        set replicas: 7
if 105 <= sqs_message_count < 178:
        set replicas: 11
if 178 <= sqs_message_count < 371:
        set replicas: 14
if sqs_message_count => 371:
        set replicas: 16

Is there anything available natively in Kubernetes or may be some sort of an application to achieve this? I am unable to find anything solid when I did a google search. There is another way where in an application will have to be created which can poll the custom cloudwatch metric and accordingly set the replica count by consuming the kubernetes API. But this method involves significant development and custom IAM authorization for the service account which this application will use. I am just trying not to reinvent the wheel here. Any idea if an application/tool that can achieve this ?

0 Answers
Related