我正在部署使用节点构建的微服务应用程序。
问题
当我使用 Jmeter 加载时, pods 不会自动缩放。 CPU实用性变为 50m ,它不会调用HPA开始自动缩放。我希望它在达到CPU请求的80%(即10m)后立即开始复制。
# apiVersion: autoscaling/v1
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: client-hpa
namespace: default
spec:
minReplicas: 1
maxReplicas: 4
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 80
scaleTargetRef:
# apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
name: client-depl
apiVersion: apps/v1
kind: Deployment
metadata:
name: client-depl
spec:
replicas: 1
selector:
matchLabels:
app: client
template:
metadata:
labels:
app: client
spec:
containers:
- name: client
image: <docker-id>/<image-name>
resources:
requests:
memory: 350Mi
cpu: 10m ### I want it to autoscale when it reaches 8m ###
另外,kubectl get hpa
显示以下输出:$ kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
client-hpa Deployment/client-depl <unknown>/80% 1 4 1 8m32s
最佳答案
HPA基于以下公式
desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]
如您所见,方程式基于当前cpu利用率,而不是基于CPU请求。 (我希望它达到8m时自动缩放)。
也就是说,您可能感兴趣以下内容:
Vertical Pod Autoscaling