我試圖了解 Kubernetes Horizo??ntalPodAutoscaler 的作業原理。到目前為止,我使用了以下配置:
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
uj5u.com熱心網友回復:
這是您需要的清單示例,其中包括Memory Metrics:
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
需要注意的重要一點是,如您所見,它使用autoscaling/v2beta2 API 版本,因此您需要遵循此處列出的所有先前說明。
關于使用autoscaling/v2alpha1的可能性,是的,您可以使用它,因為它包括對記憶體擴展的支持以及此URL指定的自定義指標,但請記住,alpha 版本是為測驗而發布的,因為它們不是最終版本版本。
有關更多autoscaling/v2beta2 YAML 的示例和更深入地了解記憶體指標,您可以查看此執行緒。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/466448.html
