具有 2 个或更多指标的 kubernetes HPA 的行为如何 - 特别是 no.of 副本计算?

How kubernetes HPA with 2 or more metrics behaves - especially the no.of replicas calculation?

我们已配置为使用 2 个 HPA 指标

  1. CPU 利用率
  2. 特定于应用的自定义指标

在测试时,我们观察到发生了缩放,但是 no.of 副本的计算不是很清楚。我找不到关于此的任何文档。

问题:

  1. 有人可以指出计算部分的文档或代码吗?
  2. 使用多个指标进行缩放是一种好的做法吗?

提前致谢!

来自https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#how-does-the-horizontal-pod-autoscaler-work

If multiple metrics are specified in a HorizontalPodAutoscaler, this calculation is done for each metric, and then the largest of the desired replica counts is chosen. If any of those metrics cannot be converted into a desired replica count (e.g. due to an error fetching the metrics from the metrics APIs), scaling is skipped.

Finally, just before HPA scales the target, the scale recommendation is recorded. The controller considers all recommendations within a configurable window choosing the highest recommendation from within that window. This value can be configured using the --horizontal-pod-autoscaler-downscale-stabilization-window flag, which defaults to 5 minutes. This means that scaledowns will occur gradually, smoothing out the impact of rapidly fluctuating metric values