Support Keda Autoscaling

Keda autoscaling is exclusive with regular hpa scaling. If both are set to true, keda takes precedence.
This commit is contained in:
Brandon Pinske 2020-11-18 13:22:34 -07:00
parent 118b00a560
commit 129b7d119e
4 changed files with 73 additions and 1 deletions

View file

@ -1,4 +1,6 @@
{{- if and .Values.controller.autoscaling.enabled (or (eq .Values.controller.kind "Deployment") (eq .Values.controller.kind "Both")) -}}
{{- if not .Values.controller.keda.enabled }}
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
@ -34,3 +36,5 @@ spec:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,33 @@
{{- if .Values.controller.keda.enabled }}
# https://keda.sh/docs/
apiVersion: {{ .Values.controller.keda.apiVersion }}
kind: ScaledObject
metadata:
labels:
{{- include "ingress-nginx.labels" . | nindent 4 }}
app.kubernetes.io/component: controller
name: {{ include "ingress-nginx.controller.fullname" . }}
spec:
scaleTargetRef:
deploymentName: {{ include "ingress-nginx.controller.fullname" . }}
pollingInterval: {{ .Values.controller.keda.pollingInterval }}
cooldownPeriod: {{ .Values.controller.keda.cooldownPeriod }}
minReplicaCount: {{ .Values.controller.keda.minReplicas }}
maxReplicaCount: {{ .Values.controller.keda.maxReplicas }}
triggers:
{{- with .Values.controller.keda.triggers }}
{{ toYaml . | indent 2 }}
{{ end }}
advanced:
restoreToOriginalReplicaCount: {{ .Values.controller.keda.restoreToOriginalReplicaCount }}
{{- if .Values.controller.keda.behavior }}
horizontalPodAutoscalerConfig:
behavior:
{{ with .Values.controller.keda.behavior -}}
{{ toYaml . | indent 8 }}
{{ end }}
{{- end }}
{{- end }}