forked from grafana/helm-charts
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy path_keda.tpl
More file actions
55 lines (53 loc) · 1.96 KB
/
_keda.tpl
File metadata and controls
55 lines (53 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{{/*
KEDA ScaledObject helper
*/}}
{{/*
Validate that HPA and KEDA autoscaling are not both enabled for a component.
Params: .component (values object), .name (string for error message)
*/}}
{{- define "loki.validateAutoscaling" -}}
{{- if and (dig "kedaAutoscaling" "enabled" false .component) (dig "autoscaling" "enabled" false .component) }}
{{- fail (printf "Cannot enable both HPA and Keda based autoscaling for %s at the same time." .name) }}
{{- end }}
{{- end -}}
{{- define "loki.keda" }}
{{- if .component.kedaAutoscaling.enabled }}
{{- $target := .target }}
{{- $kind := .component.kind | default .kind | default "StatefulSet" }}
{{- $ctx := .ctx }}
{{- $component := .component }}
{{- $suffix := .suffix | default "" }}
{{- with $ctx }}
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ include "loki.resourceName" (dict "ctx" . "component" $target "suffix" $suffix) }}
namespace: {{ include "loki.namespace" . }}
labels:
{{- include "loki.labels" . | nindent 4 }}
app.kubernetes.io/component: {{ $target }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: {{ $kind }}
name: {{ include "loki.resourceName" (dict "ctx" . "component" $target "suffix" $suffix) }}
minReplicaCount: {{ $component.kedaAutoscaling.minReplicas }}
maxReplicaCount: {{ $component.kedaAutoscaling.maxReplicas }}
pollingInterval: {{ coalesce $component.kedaAutoscaling.pollingInterval .Values.defaults.kedaAutoscaling.pollingInterval }}
cooldownPeriod: {{ coalesce $component.kedaAutoscaling.cooldownPeriod .Values.defaults.kedaAutoscaling.cooldownPeriod }}
{{- with $component.kedaAutoscaling.fallback }}
fallback:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $component.kedaAutoscaling.behavior }}
advanced:
horizontalPodAutoscalerConfig:
behavior:
{{- toYaml . | nindent 8 }}
{{- end }}
triggers:
{{- tpl ($component.kedaAutoscaling.triggers | toYaml) . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}