apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  labels:
    app: ms-demo
  name: ms-demo-hpa
spec:
  maxReplicas: 10
  minReplicas: 2
  metrics:
    - resource:
        name: memory
        target:
          averageUtilization: 50
          type: Utilization
      type: Resource
    - resource:
        name: cpu
        target:
          averageUtilization: 50
          type: Utilization
      type: Resource
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: ms-demo
# Doc
#  kubectl autoscale deployment ms-demo-hpa --cpu-percent=50 --min=1 --max=10 // another way to create hpa
#  kubectl get hpa ms-demo-hpa --watch // monitor hpa
#  kubectl scale --replicas=2 deployment.apps/ms-demo //scale manually
##  To monitor utilization:
#  kube_horizontalpodautoscaler_status_current_replicas{horizontalpodautoscaler='ms-demo-hpa'}/
#  kube_horizontalpodautoscaler_spec_max_replicas{horizontalpodautoscaler='ms-demo-hpa'}*100
## To Monitor current replica
#  kube_horizontalpodautoscaler_status_current_replicas{horizontalpodautoscaler='ms-demo-hpa'}