下午好。我正在使用 HPA (HorizontalPodAutoscaler) 自动缩放 Pod 的副本,在这种情况下,我使用内存使用作为参考,我声明如下:
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: find-complementary-account-info-1
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: find-complementary-account-info-1
minReplicas: 2
maxReplicas: 5
metrics:
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 70
我想要的是在 pod 的内存使用百分比大于 70% 时自动扩展我的 pod,并且当这个百分比下降时,我的副本返回到声明的最小值,但是,在进行测试时,我将限制设置为 70,但没有,当内存使用低于此值时,副本继续在 4。
5 分钟过去了,这就是 HPA 显示的内容:
[dockermd@tmp108 APP-MM-ConsultaCuentaPagadoraPospago]$ kubectl get hpa -o wide
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
find-complementary-account-info-1 Deployment/find-complementary-account-info-1 65%/70% 2 5 4 2d4h
我对 HPA 有错误的概念,或者我以错误的方式声明了 HPA 的配置,或者当内存使用量低于指定值时如何减少副本数量
我的环境是本地的,并且配置了 metalb,我使用 LoadBalancer 来公开我的服务