2

我们正在使用v1.18ArgoCD

期望行为:当使用率低于 50% 时,每 5 分钟一次缩减 1 个 pod

HPA 使用默认规范完美地向上和向下扩展。

当我们将自定义行为添加到规范以实现Desired Behavior时,我们根本看不到 scaleDown 发生。

我猜我们的配置与算法冲突,这条消息可能是一个线索:

recent recommendations were higher than current one, applying the highest recent recommendation

编辑:我们让它与其他设置(例如每 10 分钟 5 个 pod)一起使用自定义配置行为。我还注意到,在一个策略中,可以分布在periodSeconds中,这意味着如果我的periodSeconds为 600 且值为5,我可以缩小 1 个 pod,然后在 120 秒后缩小 2 个 pod,然后在 120 秒后再次缩小 2 个 pod,所有这些都在这 600 秒内,而我之前读过,每个periodSeconds将有一个缩放事件,最多可达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
4

0 回答 0