本文介绍了将水平Pod自动缩放与资源请求和限制一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我们有以下部署:

apiVersion: apps/v1
kind: Deployment
metadata:
  ...
spec:
  replicas: 2
  template:
    spec:
      containers:
        - image: ...
          ...
          resources:
            requests:
              cpu: 100m
              memory: 50Mi
            limits:
              cpu: 500m
              memory: 300Mi

我们还创建了一个 Horizo​​ntalPodAutoscaler 对象,该对象根据CPU的平均利用率自动按比例增加/减少Pod的数量.我知道HPA会根据资源请求计算pod的数量,但是如果我希望容器能够在水平扩展之前请求更多资源怎么办?

And we also create a HorizontalPodAutoscaler object which automatically scales up/down the number of pods based on CPU average utilization. I know that the HPA will compute the number of pods based on the resource requests, but what if I want the containers to be able to request more resources before scaling horizontally?

我有两个问题:

1)定义HPA时,K8是否甚至使用资源限制?

1) Are resource limits even used by K8s when a HPA is defined?

2)我可以告诉HPA根据资源限制而不是请求进行扩展吗?还是作为实现这种控件的一种方法,我可以将 targetUtilization 的值设置为大于100%吗?

2) Can I tell the HPA to scale based on resource limits rather than requests? Or as a means of implementing such a control, can I set the targetUtilization value to be more than 100%?

推荐答案

否,HPA根本没有考虑限制.您可以将目标利用率指定为甚至高于100%的任何值.

No, HPA is not looking at limits at all. You can specify target utilization to any value even higher than 100%.

这篇关于将水平Pod自动缩放与资源请求和限制一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 03:44