Kubernetes HPA 错误地计算 CPU 的平均利用率
我正在设置基于 CPU 的 nginx 自动缩放。
nginx 部署的设置是:
resources:
limits:
cpu: "2"
memory: 1000Mi
requests:
cpu: 100m
memory: 100Mi
当我检查 kubectl top pod 时,
我看到我有 4 个 pod。每个 Pod 使用 2m。所以总共 8m。有人可以向我解释一下,当我检查 HPA 时,它显示 44%/50% 的利用率如何?这个数学绝对是错误的。
HPA 配置:
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: api-svc-nginx-ingress
namespace: api-svc
spec:
maxReplicas: 5
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx-ingress
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
如果我手动将部署缩减到 1 个 Pod,我会发现利用率下降到 8%/50%...不确定出了什么问题?公制服务器坏了吗?
I am setting up nginx autoscaling based on CPU.
Setup on the nginx deployment is:
resources:
limits:
cpu: "2"
memory: 1000Mi
requests:
cpu: 100m
memory: 100Mi
When I check kubectl top pod
I see I have 4 pods. Each pod is using 2m. So that is 8m total. Can someone explain to me how when I check the HPA it shows 44%/50% is utilized? That math is definitely wrong.
HPA config:
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: api-svc-nginx-ingress
namespace: api-svc
spec:
maxReplicas: 5
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx-ingress
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
If I manually scale down the deployment to 1 pod I see that the utilization drops to 8%/50%... Not sure whats wrong? Is metric server broken?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以事实证明我使用了一个不起作用的附加指标(这是一个自定义指标,没有来自指标服务器的来源) - 我认为这破坏了指标的更新。
我有另一个
显示在 HPA 目标输出上的内容。当我删除这个指标后,HPA 似乎工作得很好。
So it turns out I was using an additional metric that wasn't working (it was a custom metric that didn't have a source from metric server) - and I think that broke the metrics from updating.
I had another
that was showing up as on the HPA targets output. Once I removed that metric the HPA seemed to work fine.