我们使用的是 v1.18 和 ArgoCD。
期望行为:当使用率低于 50% 时,每 5 分钟一次缩小 1 个 pod
HPA 使用默认规范完美地放大和缩小。
当我们将自定义行为添加到规范以实现期望行为时,我们根本看不到 scaleDown 发生。
我猜我们的配置与算法冲突,这条消息可能是一个线索:
recent recommendations were higher than current one, applying the highest recent recommendation
编辑:我们使用自定义配置的行为和其他设置(例如每 10 分钟 5 个 pod)使其工作。我还注意到,在策略中 value 可以分布在 periodSeconds 中,这意味着如果我的 periodSeconds 是 600 并且 value< /strong> 是 5,我可以缩小 1 个 pod,然后在 120 秒后缩小 2 个 pod,然后在 120 秒后再次缩小 2 个 pod,所有这一切都在这 600 秒内,而我之前读到将恰好 ONE 每 periodSeconds 最多可扩展 value 数量的 pod。无论如何,我们仍在试图弄清楚如何每 5 分钟缩小 1 个 pod。我的理论是,如果我当前的 CPU 平均为 49%,有 10 个 pod,并且我一次只允许按比例缩小 1 个 pod,我们最终将使用 >50%(目标),因此“所需”的 pod 保持不变一样。
HPA DEF
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: stackoverflow
labels:
app: question
namespace: HPA
spec:
scaleTargetRef:
apiVersion: scaleTarget/v1alpha1
kind: Rollout
name: scaleTarget
minReplicas: 2
maxReplicas: 15
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Pods
value: 1
periodSeconds: 300
selectPolicy: Min
描述 HPA
Name: my-app
Namespace: default
Labels: app=my-app
app.kubernetes.io/instance=my-app
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"autoscaling/v2beta2","kind":"HorizontalPodAutoscaler","metadata":{"annotations":{},"labels":{"app":"my-app","app.kubernete...
CreationTimestamp: Wed, 20 Jan 2021 14:17:29 -0800
Reference: Rollout/my-app
Metrics: ( current / target )
resource cpu on pods (as a percentage of request): 10% (10m) / 50%
Min replicas: 2
Max replicas: 15
Rollout pods: 15 current / 15 desired
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True ScaleDownStabilized recent recommendations were higher than current one, applying the highest recent recommendation
ScalingActive True ValidMetricFound the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)
ScalingLimited True ScaleDownLimit the desired replica count is decreasing faster than the maximum scale rate
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulRescale 50m (x71 over 42h) horizontal-pod-autoscaler (combined from similar events): New size: 15; reason: cpu resource utilization (percentage of request) above target