blob: 3541ec6965d68279b03c0060873d8a81b3c7d6c9 [file] [log] [blame]
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +00001{{- $autoscalingv2 := .Capabilities.APIVersions.Has "autoscaling/v2" -}}
2{{- if .Values.gateway.autoscaling.enabled }}
3{{- if $autoscalingv2 }}
4apiVersion: autoscaling/v2
5{{- else }}
6apiVersion: autoscaling/v2beta1
7{{- end }}
8kind: HorizontalPodAutoscaler
9metadata:
10 name: {{ include "loki.gatewayFullname" . }}
Giovanni Tirloni52306ad2024-04-12 15:35:05 -030011 namespace: {{ $.Release.Namespace }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000012 labels:
13 {{- include "loki.gatewayLabels" . | nindent 4 }}
14spec:
15 scaleTargetRef:
16 apiVersion: apps/v1
17 kind: Deployment
18 name: {{ include "loki.gatewayFullname" . }}
19 minReplicas: {{ .Values.gateway.autoscaling.minReplicas }}
20 maxReplicas: {{ .Values.gateway.autoscaling.maxReplicas }}
Giovanni Tirloni52306ad2024-04-12 15:35:05 -030021 {{- with .Values.gateway.autoscaling.behavior }}
22 behavior:
23 {{- toYaml . | nindent 4 }}
24 {{- end }}
Mohammed Naser8a2c8fb2023-02-19 17:23:55 +000025 metrics:
26 {{- with .Values.gateway.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.gateway.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 }}