Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 1 | {{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}} |
| 2 | {{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}} |
| 3 | {{- if and $isSimpleScalable (not .Values.read.legacyReadTarget ) ( .Values.backend.autoscaling.enabled ) }} |
| 4 | {{- if $autoscalingv2 }} |
| 5 | apiVersion: autoscaling/v2 |
| 6 | {{- else }} |
| 7 | apiVersion: autoscaling/v2beta1 |
| 8 | {{- end }} |
| 9 | kind: HorizontalPodAutoscaler |
| 10 | metadata: |
| 11 | name: {{ include "loki.backendFullname" . }} |
| 12 | labels: |
| 13 | {{- include "loki.backendLabels" . | nindent 4 }} |
| 14 | spec: |
| 15 | scaleTargetRef: |
| 16 | apiVersion: apps/v1 |
| 17 | kind: StatefulSet |
| 18 | name: {{ include "loki.backendFullname" . }} |
| 19 | minReplicas: {{ .Values.backend.autoscaling.minReplicas }} |
| 20 | maxReplicas: {{ .Values.backend.autoscaling.maxReplicas }} |
| 21 | {{- with .Values.backend.autoscaling.behavior }} |
| 22 | behavior: |
| 23 | {{- toYaml . | nindent 4 }} |
| 24 | {{- end }} |
| 25 | metrics: |
| 26 | {{- with .Values.backend.autoscaling.targetMemoryUtilizationPercentage }} |
| 27 | - type: Resource |
| 28 | resource: |
| 29 | name: memory |
| 30 | {{- if $autoscalingv2 }} |
| 31 | target: |
| 32 | type: Utilization |
| 33 | averageUtilization: {{ . }} |
| 34 | {{- else }} |
| 35 | targetAverageUtilization: {{ . }} |
| 36 | {{- end }} |
| 37 | {{- end }} |
| 38 | {{- with .Values.backend.autoscaling.targetCPUUtilizationPercentage }} |
| 39 | - type: Resource |
| 40 | resource: |
| 41 | name: cpu |
| 42 | {{- if $autoscalingv2 }} |
| 43 | target: |
| 44 | type: Utilization |
| 45 | averageUtilization: {{ . }} |
| 46 | {{- else }} |
| 47 | targetAverageUtilization: {{ . }} |
| 48 | {{- end }} |
| 49 | {{- end }} |
| 50 | {{- end }} |