hpa.yaml 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. {{- $name := .Chart.Name }}
  2. {{- range $index, $val := .Values.items }}
  3. {{- if and $val.autoscaling $val.autoscaling.enabled }}
  4. apiVersion: autoscaling/v2beta1
  5. kind: HorizontalPodAutoscaler
  6. metadata:
  7. name: {{ print $val.name | default (print $name "-autoscaller-" $index) }}
  8. labels:
  9. app: {{ $name }}
  10. tier: {{ $val.name | default (print $name "-autoscaller") }}
  11. spec:
  12. scaleTargetRef:
  13. apiVersion: apps/v1
  14. kind: Deployment
  15. name: {{ $val.name | default (print $name "-" $val.type "-" $index) }}
  16. minReplicas: {{ $val.autoscaling.minReplicas | default 1 }}
  17. maxReplicas: {{ $val.autoscaling.maxReplicas | default 10 }}
  18. metrics:
  19. {{- if $val.autoscaling.targetCPUUtilizationPercentage }}
  20. - type: Resource
  21. resource:
  22. name: cpu
  23. targetAverageUtilization: {{ $val.autoscaling.targetCPUUtilizationPercentage | default 50 }}
  24. {{- end }}
  25. {{- if $val.autoscaling.targetMemoryUtilizationPercentage }}
  26. - type: Resource
  27. resource:
  28. name: memory
  29. targetAverageUtilization: {{ $val.autoscaling.targetMemoryUtilizationPercentage | default 30}}
  30. {{- end }}
  31. {{ print "---" }}
  32. {{- end }}{{- end }}