参考
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: nginxtest #应用名
namespace: default #集群空间
spec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment //需要伸缩的资源类型
name: nginxtest //需要伸缩的资源名称
maxReplicas: 5 //资源最大副本数
minReplicas: 1 //资源最小副本数
targetCPUUtilizationPercentage: 50 //触发伸缩的cpu使用率
apiVersion: "autoscaling/v2beta1"
kind: "HorizontalPodAutoscaler"
metadata:
name: "firststrick"
spec:
maxReplicas: 5
minReplicas: 1
scaleTargetRef:
apiVersion: "apps/v1beta1"
kind: "Deployment"
name: "firststrick"
metrics:
- resource:
targetAverageUtilization: 50
name: "memory"
type: "Resource"