本文状态:草稿
配置例子
|
|
算法
desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]
currentMetricValue 为相关 pod 的 metric 平均数。
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.
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.
参数
--horizontal-pod-autoscaler-sync-period
flag (with a default value of 15 seconds) : control loop, with a period controlled by the controller manager--horizontal-pod-autoscaler-tolerance
: We’ll skip scaling if the ratio is sufficiently close to 1.0 (within a globally-configurable tolerance, defaults to 0.1--horizontal-pod-autoscaler-initial-readiness-delay
: Due to technical constraints, the HorizontalPodAutoscaler controller cannot exactly determine the first time a pod becomes ready when determining whether to set aside certain CPU metrics. Instead, it considers a Pod “not yet ready” if it’s unready and transitioned to unready within a short, configurable window of time since it started. This value is configured with the--horizontal-pod-autoscaler-initial-readiness-delay
flag, and its default is 30 seconds--horizontal-pod-autoscaler-cpu-initialization-period
: Once a pod has become ready, it considers any transition to ready to be the first if it occurred within a longer, configurable time since it started. This value is configured with the--horizontal-pod-autoscaler-cpu-initialization-period
flag, and its default is 5 minutes.--horizontal-pod-autoscaler-downscale-stabilization
: 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
flag, which defaults to 5 minutes. This means that scaledowns will occur gradually, smoothing out the impact of rapidly fluctuating metric values.
CRD
targetAverageValue
targetAverageUtilization
支持的指标
POD 指标
|
|
Container 指标
Kubernetes v1.20 的支持。
|
|
查询状态
|
|
参考
- https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#algorithm-details
- https://medium.com/expedia-group-tech/autoscaling-in-kubernetes-why-doesnt-the-horizontal-pod-autoscaler-work-for-me-5f0094694054
- https://github.com/kubernetes/community/blob/master/contributors/design-proposals/autoscaling/horizontal-pod-autoscaler.md