blob: e23c221032e9784d1c9d5ab40f23260fd8d2660e [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" . }}
11 labels:
12 {{- include "loki.gatewayLabels" . | nindent 4 }}
13spec:
14 scaleTargetRef:
15 apiVersion: apps/v1
16 kind: Deployment
17 name: {{ include "loki.gatewayFullname" . }}
18 minReplicas: {{ .Values.gateway.autoscaling.minReplicas }}
19 maxReplicas: {{ .Values.gateway.autoscaling.maxReplicas }}
20 metrics:
21 {{- with .Values.gateway.autoscaling.targetMemoryUtilizationPercentage }}
22 - type: Resource
23 resource:
24 name: memory
25 {{- if $autoscalingv2 }}
26 target:
27 type: Utilization
28 averageUtilization: {{ . }}
29 {{- else }}
30 targetAverageUtilization: {{ . }}
31 {{- end }}
32 {{- end }}
33 {{- with .Values.gateway.autoscaling.targetCPUUtilizationPercentage }}
34 - type: Resource
35 resource:
36 name: cpu
37 {{- if $autoscalingv2 }}
38 target:
39 type: Utilization
40 averageUtilization: {{ . }}
41 {{- else }}
42 targetAverageUtilization: {{ . }}
43 {{- end }}
44 {{- end }}
45{{- end }}