-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hpa memory #155
Comments
排查步骤
修复步骤
示例排查命令# 检查Metrics Server状态
kubectl get deployment metrics-server -n kube-system
kubectl get pods -n kube-system | grep metrics-server
# 检查Metrics API是否工作正常
kubectl top nodes
kubectl top pods -n <your-namespace>
# 查看HPA事件日志
kubectl describe hpa <hpa-name> -n <namespace>
# 编辑HPA配置
kubectl edit hpa <hpa-name> -n <namespace> 通过上述步骤,可以定位和解决 |
如果 排查步骤
修复步骤
示例排查命令# 查看HPA详细信息
kubectl describe hpa <hpa-name> -n <namespace>
# 查看pods的资源利用率
kubectl top pod -n <namespace> | grep <deployment-name>
# 检查Metrics Server状态
kubectl get deployment metrics-server -n kube-system
kubectl get pods -n kube-system | grep metrics-server
# 编辑HPA配置
kubectl edit hpa <hpa-name> -n <namespace> 通过上述步骤,可以定位和解决HPA无法正确缩减pods数量的问题,确保HPA能够根据资源利用率正确调整pods数量。 |
学习下面这个文章https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
在 Kubernetes 中,Horizontal Pod Autoscaling(HPA)通过自动调整工作负载的 Pod 副本数量来匹配需求。其计算公式为:
desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]
其中,ceil表示向上取整。
假设当前情况如下:
• currentReplicas为 2
• currentMetricValue = 90
• desiredMetricValue = 80
代入公式计算:
desiredReplicas = ceil[2 * (90 / 80)]
= ceil[2 * 1.125]
= ceil[2.25]
= 3
同时,根据文档中的说明,控制平面在比率足够接近 1.0(在全局可配置的容差范围内,默认容差为 0.1)时会跳过任何缩放操作。在此例中,计算比率:
ratio = currentMetricValue / desiredMetricValue
= 90 / 80
= 1.125
1.125 与 1.0 的差异是 0.125,超过了默认的 0.1 容差。因此,控制平面很可能会执行缩放操作,将副本数从 2 增加到 3。首先帮我验证这个说法是否正确。 另外帮我输出更多的例子。 也就是我可能需要举更多的例子。
你的说法是正确的。根据你提供的情况和计算,Horizontal Pod Autoscaling (HPA) 控制平面会根据当前指标值(currentMetricValue)和期望指标值(desiredMetricValue)之间的比率来决定是否需要调整副本数。在这个例子中,计算得到的比率是 1.125,这超过了默认的 0.1 容差,因此 HPA 会触发缩放操作,将副本数增加到 3。
下面是一些额外的例子,展示了不同的 currentMetricValue 和 desiredMetricValue 的情况下,desiredReplicas 的计算结果:
示例 1:
示例 2:
示例 3:
示例 4:
示例 5:
在这些示例中,我们可以看到不同的比率如何影响副本数的调整。如果比率接近 1.0,并且差异在容差范围内,HPA 可能不会执行缩放操作。如果比率显著高于或低于 1.0,HPA 将相应地增加或减少副本数。
The text was updated successfully, but these errors were encountered: