Kubernetes基于容器线程的HPA

huangapple go评论47阅读模式
英文:

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相关联的度量系统,这是可行的。

  1. 尝试使用监控工具如Prometheus来收集容器使用的线程数的度量数据。

  2. 创建一个自定义自动缩放脚本,使用监控工具的API来检查线程计数,如果达到10则触发缩放事件。

  3. 根据定义的度量标准,使用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.

  1. Try to gather metrics on the number of threads used by the container using a monitoring tool such as Prometheus.

  2. 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.

  3. Scale pods using K8S HPA based on a defined metric.

Refer to the doc User-defined metrics overview for more information.

huangapple
  • 本文由 发表于 2023年5月11日 14:45:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76224814.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定