英文:
Kubernetes HPA based on container threads
问题
我想根据容器使用的线程数自动调整Pod的大小,所以:
如果容器的线程数> 10,则从1扩展到2。
这可能吗?
不幸的是,以CPU利用率作为指标不会起作用。
迄今为止还没有找到相关信息。
英文:
I want to autoscale a pod based on how many threads a container uses, so:
if container threads > 10 then scale from 1 -> 2.
Is this possible?
CPU utilization as metric is not going to work unfortunately.
Haven't found anything on this yet
答案1
得分: 1
Kubernetes并不单独跟踪这个作为统计数据,但如果你有另一个与HPA相关联的度量系统,这是可行的。
-
尝试使用监控工具如Prometheus来收集容器使用的线程数的度量数据。
-
创建一个自定义自动缩放脚本,使用监控工具的API来检查线程计数,如果达到10则触发缩放事件。
-
根据定义的度量标准,使用K8S HPA来扩展Pod。
有关更多信息,请参阅用户定义的度量概述文档。
英文:
As mentioned by David Maze, Kubernetes does not track this as a statistic on its own, however if you have another metric system that is linked to HPA, it should be doable.
-
Try to gather metrics on the number of threads used by the container using a monitoring tool such as Prometheus.
-
Create a custom auto scaling script that checks the thread count using the monitoring tool's API and triggers a scaling event if it reaches 10.
-
Scale pods using K8S HPA based on a defined metric.
Refer to the doc User-defined metrics overview for more information.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论