apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: tiflash-branch
  namespace: tiflash-autoscale
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: StatefulSet
    name: tiflash-branch
  minReplicas: 1
  maxReplicas: 10
  behavior:
    scaleDown:
      policies:
      - periodSeconds: 300 
        type: Pods
        value: 1
      - periodSeconds: 300 
        type: Percent
        value: 50
      selectPolicy: Max 
      stabilizationWindowSeconds: 1800
    scaleUp:
      policies:
      - periodSeconds: 60
        type: Pods
        value: 2
      - periodSeconds: 60
        type: Percent
        value: 10
      selectPolicy: Max 
      stabilizationWindowSeconds: 30
  maxReplicas: 20
  metrics:
  - containerResource:
      container: tiflash
      name: cpu 
      target:
        averageUtilization: 300 
        type: Utilization
    type: ContainerResource