Skip to content

Commit b3899a4

Browse files
committed
helm: add support for keda based autoscaling for querier
Signed-off-by: drfaust92 <ilia.lazebnik@gmail.com>
1 parent a20d146 commit b3899a4

File tree

1 file changed

+43
-0
lines changed
  • production/helm/loki/templates/querier

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
2+
{{- if and .Values.querier.kedaAutoscaling.enabled .Values.querier.autoscaling.enabled}}
3+
{{- fail "Cannot enable both HPA and Keda based autoscaling at the same time."}}
4+
{{- end }}
5+
{{- if and $isDistributed .Values.querier.kedaAutoscaling.enabled }}
6+
apiVersion: keda.sh/v1alpha1
7+
kind: ScaledObject
8+
metadata:
9+
name: {{ include "loki.querierFullname" . }}
10+
namespace: {{ .Release.Namespace }}
11+
labels:
12+
{{- include "loki.querierLabels" . | nindent 4 }}
13+
spec:
14+
advanced:
15+
horizontalPodAutoscalerConfig:
16+
{{- with .Values.querier.kedaAutoscaling.behavior }}
17+
behavior:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
pollingInterval: {{ .Values.kedaAutoscaling.pollingInterval }}
21+
scaleTargetRef:
22+
apiVersion: apps/v1
23+
kind: Deployment
24+
name: {{ include "loki.querierFullname" . }}
25+
minReplicas: {{ .Values.querier.kedaAutoscaling.minReplicas }}
26+
maxReplicas: {{ .Values.querier.kedaAutoscaling.maxReplicas }}
27+
triggers:
28+
- metadata:
29+
{{- if .Values.kedaAutoscaling.authentication.enabled }}
30+
authModes: "{{ .Values.kedaAutoscaling.authentication.authModes }}"
31+
{{- end }}
32+
query: sum(max_over_time(loki_query_scheduler_inflight_requests{namespace="{{ .Release.Namespace }}", quantile="0.75"}[2m]))
33+
serverAddress: {{ .Values.kedaAutoscaling.prometheusAddress }}
34+
threshold: {{ .Values.querier.kedaAutoscaling.querySchedulerInflightRequestsThreshold | quote }}
35+
ignoreNullValues: "{{ .Values.kedaAutoscaling.ignoreNullValues }}"
36+
unsafeSsl: "{{ .Values.kedaAutoscaling.unsafeSsl }}"
37+
name: querier_autoscaling_metric
38+
type: prometheus
39+
{{- if .Values.kedaAutoscaling.authentication.enabled }}
40+
authenticationRef:
41+
name: "keda-triggger-auth"
42+
{{- end }}
43+
{{- end }}

0 commit comments

Comments
 (0)