hpa.yaml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. {{- if and .Values.replica.autoscaling.enabled .Values.sentinel.enabled }}
  2. apiVersion: {{ include "common.capabilities.hpa.apiVersion" ( dict "context" $ ) }}
  3. kind: HorizontalPodAutoscaler
  4. metadata:
  5. name: {{ printf "%s-node" (include "common.names.fullname" .) }}
  6. namespace: {{ .Release.Namespace | quote }}
  7. labels: {{- include "common.labels.standard" . | nindent 4 }}
  8. app.kubernetes.io/component: replica
  9. {{- if .Values.commonLabels }}
  10. {{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }}
  11. {{- end }}
  12. {{- if .Values.commonAnnotations }}
  13. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  14. {{- end }}
  15. spec:
  16. scaleTargetRef:
  17. apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
  18. kind: StatefulSet
  19. name: {{ printf "%s-node" (include "common.names.fullname" .) }}
  20. minReplicas: {{ .Values.replica.autoscaling.minReplicas }}
  21. maxReplicas: {{ .Values.replica.autoscaling.maxReplicas }}
  22. metrics:
  23. {{- if .Values.replica.autoscaling.targetMemory }}
  24. - type: Resource
  25. resource:
  26. name: memory
  27. {{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
  28. targetAverageUtilization: {{ .Values.replica.autoscaling.targetMemory }}
  29. {{- else }}
  30. target:
  31. type: Utilization
  32. averageUtilization: {{ .Values.replica.autoscaling.targetMemory }}
  33. {{- end }}
  34. {{- end }}
  35. {{- if .Values.replica.autoscaling.targetCPU }}
  36. - type: Resource
  37. resource:
  38. name: cpu
  39. {{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
  40. targetAverageUtilization: {{ .Values.replica.autoscaling.targetCPU }}
  41. {{- else }}
  42. target:
  43. type: Utilization
  44. averageUtilization: {{ .Values.replica.autoscaling.targetCPU }}
  45. {{- end }}
  46. {{- end }}
  47. {{- end }}