Skip to content

Commit

Permalink
feat: support mysql backend as keda trigger
Browse files Browse the repository at this point in the history
#36166

Signed-off-by: Romain Forlot <romain.forlot@dailymotion.com>
  • Loading branch information
claneys committed Dec 13, 2023
1 parent 8fbacb8 commit b71e8af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ If release name contains chart name it will be used as a full name.
name: {{ template "airflow_metadata_secret" . }}
key: connection
{{- end }}
{{- if and .Values.workers.keda.enabled .Values.pgbouncer.enabled (not .Values.workers.keda.usePgbouncer) }}
{{- if (or (and .Values.workers.keda.enabled (eq .Values.data.metadataConnection.protocol "mysql")) (and .Values.workers.keda.enabled .Values.pgbouncer.enabled (not .Values.workers.keda.usePgbouncer))) }}
- name: KEDA_DB_CONN
valueFrom:
secretKeyRef:
Expand Down
4 changes: 4 additions & 0 deletions chart/templates/secrets/metadata-connection-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ data:
{{- with .Values.data.metadataConnection }}
kedaConnection: {{ urlJoin (dict "scheme" .protocol "userinfo" (printf "%s:%s" (.user | urlquery) (.pass | urlquery) ) "host" (printf "%s:%s" $metadataHost $metadataPort) "path" (printf "/%s" $metadataDatabase) "query" $query) | b64enc | quote }}
{{- end }}
{{- else if and .Values.workers.keda.enabled (eq .Values.data.metadataConnection.protocol "mysql") }}
{{- with .Values.data.metadataConnection }}
kedaConnection: {{ urlJoin (dict "userinfo" (printf "%s:%s" (.user | urlquery) (.pass | urlquery) ) "host" (printf "tcp(%s:%s)" $metadataHost $metadataPort) "path" (printf "/%s" $metadataDatabase) "query" $query) | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
11 changes: 10 additions & 1 deletion chart/templates/workers/worker-kedaautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ spec:
advanced: {{- toYaml .Values.workers.keda.advanced | nindent 4 }}
{{- end }}
triggers:
- type: postgresql
{{- if eq .Values.data.metadataConnection.protocol "mysql" }}
- type: "mysql"
metadata:
queryValue: "1"
connectionStringFromEnv: KEDA_DB_CONN
query: {{ tpl .Values.workers.keda.query . | quote }}
{{- else }}
- type: "postgresql"
metadata:
targetQueryValue: "1"
{{- if and .Values.pgbouncer.enabled (not .Values.workers.keda.usePgbouncer) }}
Expand All @@ -56,4 +63,6 @@ spec:
connectionFromEnv: AIRFLOW_CONN_AIRFLOW_DB
{{- end }}
query: {{ tpl .Values.workers.keda.query . | quote }}
{{- end }}

{{- end }}

0 comments on commit b71e8af

Please sign in to comment.