hpa.yaml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. {{- if .Values.autoscaling.enabled }}
  2. {{- $kubeCapabilityVersion := semver .Capabilities.KubeVersion.Version -}}
  3. {{- $isHigher1p25 := ge (semver "1.25" | $kubeCapabilityVersion.Compare) 0 -}}
  4. {{- if and ($.Capabilities.APIVersions.Has "autoscaling/v2") $isHigher1p25 -}}
  5. apiVersion: autoscaling/v2
  6. {{- else }}
  7. apiVersion: autoscaling/v2beta1
  8. {{- end }}
  9. kind: HorizontalPodAutoscaler
  10. metadata:
  11. name: {{ include "kafka-ui.fullname" . }}
  12. namespace: {{ .Release.Namespace }}
  13. labels:
  14. {{- include "kafka-ui.labels" . | nindent 4 }}
  15. spec:
  16. scaleTargetRef:
  17. apiVersion: apps/v1
  18. kind: Deployment
  19. name: {{ include "kafka-ui.fullname" . }}
  20. minReplicas: {{ .Values.autoscaling.minReplicas }}
  21. maxReplicas: {{ .Values.autoscaling.maxReplicas }}
  22. metrics:
  23. {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
  24. - type: Resource
  25. resource:
  26. name: cpu
  27. {{- if $isHigher1p25 }}
  28. target:
  29. type: Utilization
  30. averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
  31. {{- else }}
  32. targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
  33. {{- end }}
  34. {{- end }}
  35. {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
  36. - type: Resource
  37. resource:
  38. name: memory
  39. {{- if $isHigher1p25 }}
  40. target:
  41. type: Utilization
  42. averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
  43. {{- else }}
  44. targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
  45. {{- end }}
  46. {{- end }}
  47. {{- end }}