kubernetes - 无论稳定窗口如何,Kubernetes HPA 都在摆动副本
问题描述
根据 K8s文档stabilizationWindowSeconds
,可以使用副本属性来避免抖动
当用于缩放的指标不断波动时,稳定窗口用于限制副本的摆动。自动缩放算法使用稳定窗口来考虑过去计算的期望状态以防止缩放。
当指标表明目标应该按比例缩小时,算法会查看先前计算的所需状态并使用指定间隔中的最大值。
根据我从文档中了解到的情况,使用以下 hpa 配置:
horizontalPodAutoscaler:
enabled: true
minReplicas: 2
maxReplicas: 14
targetCPUUtilizationPercentage: 70
behavior:
scaleDown:
stabilizationWindowSeconds: 1800
policies:
- type: Pods
value: 1
periodSeconds: 300
scaleUp:
stabilizationWindowSeconds: 60
policies:
- type: Pods
value: 2
periodSeconds: 60
如果在最后 1800 秒(30 分钟)内的任何时间 hpa 计算的目标 pod 数量等于 7 个 pod,则不应缩小我的部署(假设从 7 个 pod 到 6 个)。但我仍在观察部署中副本的抖动。
我在文档中误解了什么以及如何避免连续扩大/缩小 1 个 pod?
Kubernetes v1.20
HPA 说明:
CreationTimestamp: Thu, 14 Oct 2021 12:14:37 +0200
Reference: Deployment/my-deployment
Metrics: ( current / target )
resource cpu on pods (as a percentage of request): 64% (1621m) / 70%
Min replicas: 2
Max replicas: 14
Behavior:
Scale Up:
Stabilization Window: 60 seconds
Select Policy: Max
Policies:
- Type: Pods Value: 2 Period: 60 seconds
Scale Down:
Stabilization Window: 1800 seconds
Select Policy: Max
Policies:
- Type: Pods Value: 1 Period: 300 seconds
Deployment pods: 3 current / 3 desired
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True ReadyForNewScale recommended size matches current size
ScalingActive True ValidMetricFound the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)
ScalingLimited False DesiredWithinRange the desired count is within the acceptable range
Events: <none>
解决方案
推荐阅读
- reporting-services - 如何在 SSRS 中添加回车/换行
- c++ - 如何编译 CUDA C++ 项目
- wordpress - 向 Wordpress 插件的类函数添加过滤器
- c# - 带有两个 select 和 where 条件的 Linq 语句
- python - 用于通信 python - C++ 的 UNIX 套接字
- ios - pod FBSDKCoreKit 的 react-native-fbsdk 问题
- angular - Angular:从列表中链接两个不同的复选框
- graphql - Graphql 突变与 aws-appsync 上的父对象和子数组
- r - 如何使用“包含”和“ifelse”有条件地改变多个列?
- python - Discord.py - 获取随机 imgur 图像