为什么Kubernetes HPA没有缩小(内存)?
总结 在我们的Kubernetes集群中,我们引入了具有内存和cpu限制的HPA。现在我们不明白为什么我们有一个服务的两个副本 该服务使用57%/85%的内存,并有2个副本,而不是一个副本。我们认为,这是因为当你总结两个豆荚的内存时,它超过了85%,但如果只有一个豆荚的话,情况就不会如此了。那么这是否阻止了它的规模缩小?我们能在这里做什么 在部署服务时,我们还观察到内存使用的峰值。我们正在aks azure中使用spring引导服务,并认为它可能会在那里扩展,而不会下降。我们是否错过了什么,或者有人有什么建议 掌舵 hpa: 在部署中:为什么Kubernetes HPA没有缩小(内存)?,kubernetes,azure-aks,hpa,Kubernetes,Azure Aks,Hpa,总结 在我们的Kubernetes集群中,我们引入了具有内存和cpu限制的HPA。现在我们不明白为什么我们有一个服务的两个副本 该服务使用57%/85%的内存,并有2个副本,而不是一个副本。我们认为,这是因为当你总结两个豆荚的内存时,它超过了85%,但如果只有一个豆荚的话,情况就不会如此了。那么这是否阻止了它的规模缩小?我们能在这里做什么 在部署服务时,我们还观察到内存使用的峰值。我们正在aks azure中使用spring引导服务,并认为它可能会在那里扩展,而不会下降。我们是否错过了什么,或者
# Horizontal-Pod-Auto-Scaler
resources:
requests:
memory: {{ $requestedMemory }}
cpu: {{ $requesteCpu }}
limits:
memory: {{ $limitMemory }}
cpu: {{ $limitCpu }}
对于服务默认值:
hpa:
resources:
request:
memory: 500Mi
cpu: 300m
limits:
memory: 1000Mi
cpu: 999m
kubectl获得hpa-n开发
kubectl描述hpa-n开发
如果需要更多信息,请随时询问
非常感谢您抽出时间
干杯
罗宾是:
desiredReplicas=ceil[currentReplicas*currentMetricValue/desiredMetricValue]
对于您的问题,这一点的重要部分是ceil[…]函数包装器:它总是向上取整到下一个最近的副本。如果currentReplicas为2且desiredMetricValue为85%,则currentMetricValue必须为42.5%或更低才能触发缩放
在您的示例中,currentMetricValue为57%,因此
desiredReplicas = ceil[2 * (57 / 85)]
= ceil[2 * 0.671]
= ceil[1.341]
= 2
你是对的,如果当前副本数为1,HPA也不会觉得有必要扩大规模;实际利用率需要上升到85%以上才能触发它。是:
desiredReplicas=ceil[currentReplicas*currentMetricValue/desiredMetricValue]
对于您的问题,这一点的重要部分是ceil[…]函数包装器:它总是向上取整到下一个最近的副本。如果currentReplicas为2且desiredMetricValue为85%,则currentMetricValue必须为42.5%或更低才能触发缩放
在您的示例中,currentMetricValue为57%,因此
desiredReplicas = ceil[2 * (57 / 85)]
= ceil[2 * 0.671]
= ceil[1.341]
= 2
你是对的,如果当前副本数为1,HPA也不会觉得有必要扩大规模;实际利用率需要上升到85%以上才能触发
Name: xxx-registration-service-hpa
Namespace: dev
Labels: app.kubernetes.io/managed-by=Helm
Annotations: meta.helm.sh/release-name: vwg-registration-service
meta.helm.sh/release-namespace: dev
CreationTimestamp: Thu, 18 Jun 2020 22:50:27 +0200
Reference: Deployment/xxx-registration-service
Metrics: ( current / target )
resource memory on pods (as a percentage of request): 57% (303589376) / 85%
resource cpu on pods (as a percentage of request): 0% (1m) / 50%
Min replicas: 1
Max replicas: 10
Deployment pods: 2 current / 2 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>
desiredReplicas = ceil[2 * (57 / 85)]
= ceil[2 * 0.671]
= ceil[1.341]
= 2