blob: ea834d6e0974120eb0a281abe1eac84492fbb113 [file] [log] [blame]
Giovanni Tirloni59219b62024-04-09 14:50:25 -03001{{- $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 }}
5apiVersion: autoscaling/v2
6{{- else }}
7apiVersion: autoscaling/v2beta1
8{{- end }}
9kind: HorizontalPodAutoscaler
10metadata:
11 name: {{ include "loki.backendFullname" . }}
12 labels:
13 {{- include "loki.backendLabels" . | nindent 4 }}
14spec:
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 }}