HPA

HorizontalPodAutoscaler

先决条件

  1. 必须安装 metrics-server
  2. 必须定义 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