Kubernetes HPA无法正确扩展

sirbozc5  于 2023-10-17  发布在  Kubernetes
关注(0)|答案(2)|浏览(112)

我有app-1部署,并为此配置了HPAHPA似乎没有按预期工作,因为即使内存使用量(108%)超过目标,HPA也不会添加更多副本。

$ kubectl get hpa                               
NAME              REFERENCE                    TARGETS             MINPODS   MAXPODS   REPLICAS   AGE
app-1          Deployment/app-1                109%/100%, 5%/70%   2         4         3           3d

$ kubectl describe hpa app-1
...
Metrics:                                                  ( current / target )
  resource memory on pods  (as a percentage of request):  109% (5827813376) / 100%
  resource cpu on pods  (as a percentage of request):     18% (361m) / 70%
Min replicas:                                             2
Max replicas:                                             4
Behavior:
  Scale Up:
    Stabilization Window: 400 seconds
    Select Policy: Max
    Policies:
      - Type: Pods  Value: 1  Period: 60 seconds
  Scale Down:
    Stabilization Window: 400 seconds
    Select Policy: Min
    Policies:
      - Type: Pods  Value: 1  Period: 60 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 memory resource utilization (percentage of request)
  ScalingLimited  False   DesiredWithinRange  the desired count is within the acceptable range
Events:           <none>

有人能帮我解释一下到底怎么了吗?

yjghlzjz

yjghlzjz1#

根据提供的信息,它已经扩展到3个pod,现在正在等待扩展更多。时间可以在这里调整:

Scale Up:
    Stabilization Window: 400 seconds
    Select Policy: Max
    Policies:
      - Type: Pods  Value: 1  Period: 60 seconds
hfyxw5xn

hfyxw5xn2#

基于'kubectl describe hpa'输出,我们看到以下信息:
‘能成规模:True ReadyForNewScale建议的大小与当前大小匹配"“ScalingLimited:False DesiredWithinRange所需计数在可接受范围内
这意味着HPA认为它处于正确的规模,尽管内存利用率超过了目标。
考虑到您的400秒稳定窗口,您需要通过在更长的时间内监控HPA和相关指标来进行更深入的挖掘。这意味着HPA不会立即对指标做出React,而是在做出缩放决策之前通过此窗口观察它们。另外,检查群集和HPA事件是否存在任何问题迹象。最后,确保您的集群有足够的资源来调度新的Pod(如果它们被扩展)。附件是关于Kubernetes HPA的一个很好的阅读,可能对您的用例有帮助。[1]第一章
[1][https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/)

相关问题