hpa.yaml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. {{- range $name, $component := .Values.components }}
  2. {{- if $component.autoscaling.enabled }}
  3. ---
  4. apiVersion: autoscaling/v2
  5. kind: HorizontalPodAutoscaler
  6. metadata:
  7. name: {{ include "chart.componentFullname" (dict "root" $ "name" $name) }}
  8. labels:
  9. {{- include "chart.componentLabels" (dict "root" $ "name" $name) | nindent 4 }}
  10. spec:
  11. scaleTargetRef:
  12. apiVersion: apps/v1
  13. kind: Deployment
  14. name: {{ include "chart.componentFullname" (dict "root" $ "name" $name) }}
  15. minReplicas: {{ $component.autoscaling.minReplicas }}
  16. maxReplicas: {{ $component.autoscaling.maxReplicas }}
  17. metrics:
  18. {{- if $component.autoscaling.targetCPUUtilizationPercentage }}
  19. - type: Resource
  20. resource:
  21. name: cpu
  22. target:
  23. type: Utilization
  24. averageUtilization: {{ $component.autoscaling.targetCPUUtilizationPercentage }}
  25. {{- end }}
  26. {{- if $component.autoscaling.targetMemoryUtilizationPercentage }}
  27. - type: Resource
  28. resource:
  29. name: memory
  30. target:
  31. type: Utilization
  32. averageUtilization: {{ $component.autoscaling.targetMemoryUtilizationPercentage }}
  33. {{- end }}
  34. {{- end }}
  35. {{- end }}