我正在尝试理解Kubernetes HorizontalPodAutoscaler是如何工作的。到目前为止,我使用了以下配置:
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: my-deployment
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-deployment
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 50这使用了targetCPUUtilizationPercentage参数,但是我想用一个度量来表示所使用的内存百分比,但是我找不到任何例子。有什么暗示吗?
我还发现,有这种类型的配置支持多种度量,但apiVersion是autoscaling/v2alpha1。这能在生产环境中使用吗?
kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2alpha1
metadata:
name: WebFrontend
spec:
scaleTargetRef:
kind: ReplicationController
name: WebFrontend
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 80
- type: Object
object:
target:
kind: Service
name: Frontend
metricName: hits-per-second
targetValue: 1k发布于 2022-04-27 17:02:24
下面是您所需的一个显式示例,其中包括内存度量
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: web-servers
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: web-servers
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 20
- type: Resource
resource:
name: memory
target:
type: AverageValue
averageValue: 30Mi需要注意的是,正如您所看到的,它使用了自动标号/v2beta2api版本,因此您需要遵循前面列出的所有这里指令。
关于使用autoscaling/v2alpha1,是的可能性,您可以使用它,因为它包括对内存和自定义度量的支持,就像这个URL指定的那样,但是请记住,alpha版本是为了测试而发布的,因为它们不是最终版本。
要了解更多自动标注/v2beta2YAML的示例,以及更深入地了解内存度量,您可以查看这个线程。
https://stackoverflow.com/questions/71990765
复制相似问题