最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

autoscaling - Kubernetes HPA won't scale up even when the used memory is more than the average memory limit specified -

programmeradmin2浏览0评论

I have following HPA configuration

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
spec:
  behavior:
    scaleUp:
      policies:
      - periodSeconds: 15
        type: Pods
        value: 4
      - periodSeconds: 15
        type: Percent
        value: 100
      selectPolicy: Max
      stabilizationWindowSeconds: 0
  metrics:
  - resource:
      name: memory
      target:
        averageUtilization: 70
        type: Utilization
    type: Resource
  minReplicas: 1
  maxReplicas: 10

When the deployment has a single pod, if I increase the pod memory to 71%, the HPA doesn't scale up the pod count. When I execute kubectl describe hpa, I can see following.

the desired count is within the acceptable range

But according to the following formula kubernetes uses to calculate the desired pod count, the desired pod count should be 2.

desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]

I waited few minutes to see there is some stabilization period is used (even though the stabilizationWindowSeconds specified is 0), but it didn't scale up the number of pods.

Then I tried reducing the averageUtilization gradually, and only when I set it to 64 it scaled up and new pod is created.

Why doesn't kubernetes scale up the pod count when the memory usage is below a certain value, even though the memory usage is higher than the specified average value?

I have following HPA configuration

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
spec:
  behavior:
    scaleUp:
      policies:
      - periodSeconds: 15
        type: Pods
        value: 4
      - periodSeconds: 15
        type: Percent
        value: 100
      selectPolicy: Max
      stabilizationWindowSeconds: 0
  metrics:
  - resource:
      name: memory
      target:
        averageUtilization: 70
        type: Utilization
    type: Resource
  minReplicas: 1
  maxReplicas: 10

When the deployment has a single pod, if I increase the pod memory to 71%, the HPA doesn't scale up the pod count. When I execute kubectl describe hpa, I can see following.

the desired count is within the acceptable range

But according to the following formula kubernetes uses to calculate the desired pod count, the desired pod count should be 2.

desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]

I waited few minutes to see there is some stabilization period is used (even though the stabilizationWindowSeconds specified is 0), but it didn't scale up the number of pods.

Then I tried reducing the averageUtilization gradually, and only when I set it to 64 it scaled up and new pod is created.

Why doesn't kubernetes scale up the pod count when the memory usage is below a certain value, even though the memory usage is higher than the specified average value?

Share Improve this question asked Nov 20, 2024 at 8:58 Lahiru ChandimaLahiru Chandima 24.1k25 gold badges114 silver badges199 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Your current desired pod count= 1*(71/70)=1.014

As per this kubernetes document:

The control plane skips any scaling action if the ratio is sufficiently close to 1.0 (within a globally-configurable tolerance, 0.1 by default).

So maybe that is the reason you are not getting new pod scaled up.

And you have also mentioned that reducing the averageUtilization to 64 is scaling a new pod. The desired count for it is 1.1, so that is the reason you are getting a new pod scaled up.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论