HPA
- k8s
- 2024-08-04
- 198热度
- 0评论
HorizontalPodAutoscaler
先决条件
- 必须安装 metrics-server
- 必须定义 Request参数
v1
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: hpa_name
spec:
maxReplicas: 5
minReplicas: 2
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: myapp
targetCPUUtilizationPercentage: 60
v2
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: hpa_name
spec :
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: myapp
minReplicas: 3
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 80
resource:
name: memory
targetAverageValue: 800Mi