根据自定义CloudWatch Metric的多种条件,AWS EKS中的比例副本

发布于 2025-02-09 17:45:35 字数 1263 浏览 1 评论 0 原文

我是EKS的新手。我想根据我的SQS队列中没有消息自动自动。我已经阅读了Kubernetes中的HPA(),还通过此AWS博客( https://aws.amazon.com/blogs/compute/compute/scaling-kubernetes-deployments-with-with-with-mazon-azon-amazon-cloudwatch-cloudwatch-metrics/ )但是这对我不起作用,因为我的缩放策略看起来像这样:

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

Kubernetes中有任何可用的东西,还是可能是某种应用程序来实现这一目标?当我进行Google搜索时,我找不到任何可靠的东西。在某种程度上,必须在应用程序中创建可以进行自定义CloudWatch Metric进行轮询的方式,并因此通过消费Kubernetes API设置复制品计数。但是,此方法涉及该应用程序将使用的服务帐户的重大开发和自定义授权。我只是想在这里不重新发明轮子。有任何想法是否可以实现这一目标?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

女皇必胜 2025-02-16 17:45:35

我最终创建了一个自定义应用程序,该应用程序每60秒进行一次自定义CloudWatch Metric进行轮询,比较当前的副本计数,然后相应地设置副本计数。我使用了kubernetes python客户端()用于同一,并使用了一个服务帐户,用于使用EKS群集进行认证。该应用程序作为在同一EKS群集中的部署运行。稍后,我偶然发现 https://keda.sh/docs/ 2.13/sualers/aws-sqs/#触发指定,但它没有我需要的自定义选项。

I ended up creating a custom application that polls the custom Cloudwatch metric every 60 seconds, compares the current replica count and then sets replica count accordingly. I used the kubernetes python client (https://github.com/kubernetes-client/python/blob/master/kubernetes/README.md) for the same and used a service account for authenticating with EKS cluster. This application ran as a Deployment inside the same EKS cluster. Later on I stumbled upon https://keda.sh/docs/2.13/scalers/aws-sqs/#trigger-specification but it doesnt have custom options which I required.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文