简体   繁体   English

Kubernetes队列具有按工作项自动缩放的Pod

[英]Kubernetes Queue with Pod Per Work Item autoscaling

I want an application to pull an item off a queue, process the item on the queue and then destroy itself. 我希望应用程序将项目从队列中拉出,处理队列中的项目,然后销毁自身。 Pull -> Process -> Destroy. 拉->处理->销毁。

I've looked at using the job pattern Queue with Pod Per Work Item as that fits the usecase however it isn't appropriate when I need the job to autoscale aka 0/1 pods when queue is empty and scale to a point when items are added. 我已经看过使用适合每个用例的工作模式队列和豆荚的情况,因为它适合用例,但是当我需要工作在队列为空时自动缩放又称0/1豆荚并且当项目为零时将其缩放到一个点时,这是不合适的添加。 The only way I can see doing this is via a deployment but that removes the pattern of Queue with Pod per Work Item. 我看到的唯一方法是通过部署,但这消除了每个工作项带有Pod的队列模式。 There must be a fresh container per item. 每个物品必须有一个新鲜的容器。

Is there a way to have the job pattern Queue with Pod Per Work Item but with auto-scaling? 有没有办法让工作模式按每个工作项在Pod中排队但具有自动缩放功能?

I am a bit confused, so I'll just say this: if you don't mind a failed pod, and you wish that a failed pod will not be recreated by Kubernetes, you can do that in your code by catching all errors and exiting gracefully (not advised). 我有点困惑,所以我只想这样说:如果您不介意失败的Pod,并且希望Kubernetes不会重新创建失败的Pod,则可以在代码中捕获所有错误并正常退出(不建议)。 Please also note, that for deployments, the only accepted restartPolicy is always. 还请注意,对于部署,唯一接受的restartPolicy始终是。 So pods of a deployments who crash will always be restarted by Kubernetes, and will probably fails for the same reason, leading to a CrashLoopBackOff . 因此,崩溃的部署的Pod将始终由Kubernetes重新启动,并且可能由于相同的原因而失败,从而导致CrashLoopBackOff

If you want to scale a deployment depending on the length of a RabbitMQ queue's length, check KEDA . 如果要根据RabbitMQ队列的长度扩展部署,请检查KEDA It is an event-driven autoscaling platform. 这是一个事件驱动的自动缩放平台。 Make sure to also check their example with RabbitMQ 确保还使用RabbitMQ检查他们的示例

Another possibility is a job/deployment, that routinely checks the length of the queue in question and executes kubectl commands to scale your deployment. 另一种可能是作业/部署,它会定期检查相关队列的长度并执行kubectl命令来扩展您的部署。 Here is the cleanest one I could find, at least for my taste 是我能找到的最干净的食物,至少就我的口味而言

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM