#  Note that this is in beta
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: php-apache
  namespace: doit-lab-13
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: php-apache
  minReplicas: 1
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 50
  behavior:
    # Define when to scale down
    scaleDown:
      #  Scale down after 5 minutes
      stabilizationWindowSeconds: 300
      policies:
        #  Only scale down by 25% every 30s
        - type: Percent
          value: 25
          periodSeconds: 30
    # Define when to scale up
    scaleUp:
      # Scale up immediately
      stabilizationWindowSeconds: 0
      policies:
        # Scale by 100% every 60s
        - type: Percent
          value: 100
          periodSeconds: 60
        #  Scale up to 4 pods every 30 seconds if conditions are met.
        - type: Pods
          value: 4
          periodSeconds: 30
      selectPolicy: Max
