From 7ea9f3e7f859466a4d780c5c3be6889c9ac3e509 Mon Sep 17 00:00:00 2001 From: DavidSpek Date: Wed, 19 Oct 2022 14:19:22 +0200 Subject: [PATCH 1/3] add smtp settings to helm chart Signed-off-by: DavidSpek --- helm/oncall/templates/_env.tpl | 17 +++++++++++++++++ helm/oncall/templates/celery/_deployment.tpl | 3 +++ helm/oncall/templates/engine/deployment.yaml | 3 +++ helm/oncall/templates/engine/job-migrate.yaml | 3 +++ helm/oncall/templates/secrets.yaml | 11 ++++++++++- helm/oncall/values.yaml | 7 +++++++ 6 files changed, 43 insertions(+), 1 deletion(-) diff --git a/helm/oncall/templates/_env.tpl b/helm/oncall/templates/_env.tpl index 0084e7ae..9c7fdfe9 100644 --- a/helm/oncall/templates/_env.tpl +++ b/helm/oncall/templates/_env.tpl @@ -229,3 +229,20 @@ name: {{ template "snippet.redis.password.secret.name" . }} key: redis-password {{- end }} + +{{- define "snippet.oncall.smtp.env" -}} +- name: EMAIL_HOST + value: {{ .Values.oncall.smtp.host | quote }} +- name: EMAIL_PORT + value: {{ .Values.oncall.smtp.port | default "587" | quote }} +- name: EMAIL_HOST_USER + value: {{ .Values.oncall.smtp.username | quote }} +- name: EMAIL_HOST_PASSWORD + value: {{ .Values.oncall.smtp.password | quote }} + valueFrom: + secretKeyRef: + name: {{ include "oncall.fullname" . }}-smtp + key: smtp-password +- name: EMAIL_USE_TLS + value: {{ .Values.oncall.smtp.tls | toString | title | quote }} +{{- end }} diff --git a/helm/oncall/templates/celery/_deployment.tpl b/helm/oncall/templates/celery/_deployment.tpl index 5378c834..4a97ea0c 100644 --- a/helm/oncall/templates/celery/_deployment.tpl +++ b/helm/oncall/templates/celery/_deployment.tpl @@ -41,6 +41,9 @@ spec: {{- include "snippet.oncall.env" . | nindent 12 }} {{- include "snippet.oncall.slack.env" . | nindent 12 }} {{- include "snippet.oncall.telegram.env" . | nindent 12 }} + {{- if .Values.oncall.smtp.enabled }} + {{- include "snippet.oncall.smtp.env" . | nindent 12 }} + {{- end }} {{- include "snippet.mysql.env" . | nindent 12 }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} diff --git a/helm/oncall/templates/engine/deployment.yaml b/helm/oncall/templates/engine/deployment.yaml index 216d3055..6563d335 100644 --- a/helm/oncall/templates/engine/deployment.yaml +++ b/helm/oncall/templates/engine/deployment.yaml @@ -47,6 +47,9 @@ spec: {{- include "snippet.oncall.env" . | nindent 12 }} {{- include "snippet.oncall.slack.env" . | nindent 12 }} {{- include "snippet.oncall.telegram.env" . | nindent 12 }} + {{- if .Values.oncall.smtp.enabled }} + {{- include "snippet.oncall.smtp.env" . | nindent 12 }} + {{- end }} {{- include "snippet.mysql.env" . | nindent 12 }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} diff --git a/helm/oncall/templates/engine/job-migrate.yaml b/helm/oncall/templates/engine/job-migrate.yaml index 5bfc3019..8dcc39fd 100644 --- a/helm/oncall/templates/engine/job-migrate.yaml +++ b/helm/oncall/templates/engine/job-migrate.yaml @@ -43,6 +43,9 @@ spec: python manage.py migrate env: {{- include "snippet.oncall.env" . | nindent 12 }} + {{- if .Values.oncall.smtp.enabled }} + {{- include "snippet.oncall.smtp.env" . | nindent 12 }} + {{- end }} {{- include "snippet.mysql.env" . | nindent 12 }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} diff --git a/helm/oncall/templates/secrets.yaml b/helm/oncall/templates/secrets.yaml index 88b4eaed..64d1e22c 100644 --- a/helm/oncall/templates/secrets.yaml +++ b/helm/oncall/templates/secrets.yaml @@ -40,4 +40,13 @@ type: Opaque data: redis-password: {{ required "externalRedis.password is required if not redis.enabled" .Values.externalRedis.password | b64enc | quote }} {{- end }} - +--- +{{ if .Values.oncall.smtp.enabled -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "oncall.fullname" . }}-smtp +type: Opaque +data: + smtp-password: {{ required "oncall.smtp.password is required if oncall.smtp.enabled" .Values.oncall.smtp.password | b64enc | quote }} +{{- end }} diff --git a/helm/oncall/values.yaml b/helm/oncall/values.yaml index 363f8619..974fc442 100644 --- a/helm/oncall/values.yaml +++ b/helm/oncall/values.yaml @@ -79,6 +79,13 @@ oncall: enabled: false token: ~ webhookUrl: ~ + smtp: + enabled: false + host: ~ + port: ~ + username: ~ + password: ~ + tls: ~ # Whether to run django database migrations automatically migrate: From e8b34a895b40f437be5581b8c19c9c37c9cd2ecc Mon Sep 17 00:00:00 2001 From: DavidSpek Date: Wed, 19 Oct 2022 14:40:44 +0200 Subject: [PATCH 2/3] fix missing env vars Signed-off-by: DavidSpek --- helm/oncall/templates/_env.tpl | 9 +++++++++ helm/oncall/templates/celery/_deployment.tpl | 2 -- helm/oncall/templates/engine/deployment.yaml | 2 -- helm/oncall/templates/engine/job-migrate.yaml | 2 -- helm/oncall/values.yaml | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/helm/oncall/templates/_env.tpl b/helm/oncall/templates/_env.tpl index 9c7fdfe9..7e4b8f48 100644 --- a/helm/oncall/templates/_env.tpl +++ b/helm/oncall/templates/_env.tpl @@ -231,6 +231,9 @@ {{- end }} {{- define "snippet.oncall.smtp.env" -}} +{{- if .Values.oncall.smtp.enabled -}} +- name: FEATURE_EMAIL_INTEGRATION_ENABLED + value: {{ .Values.oncall.smtp.enabled | toString | title | quote }} - name: EMAIL_HOST value: {{ .Values.oncall.smtp.host | quote }} - name: EMAIL_PORT @@ -245,4 +248,10 @@ key: smtp-password - name: EMAIL_USE_TLS value: {{ .Values.oncall.smtp.tls | toString | title | quote }} +- name: DEFAULT_FROM_EMAIL + value: {{ .Values.oncall.smtp.fromEmail | quote }} +{{- else -}} +- name: FEATURE_EMAIL_INTEGRATION_ENABLED + value: {{ .Values.oncall.smtp.enabled | toString | title | quote }} +{{- end -}} {{- end }} diff --git a/helm/oncall/templates/celery/_deployment.tpl b/helm/oncall/templates/celery/_deployment.tpl index 4a97ea0c..0892c0cb 100644 --- a/helm/oncall/templates/celery/_deployment.tpl +++ b/helm/oncall/templates/celery/_deployment.tpl @@ -41,9 +41,7 @@ spec: {{- include "snippet.oncall.env" . | nindent 12 }} {{- include "snippet.oncall.slack.env" . | nindent 12 }} {{- include "snippet.oncall.telegram.env" . | nindent 12 }} - {{- if .Values.oncall.smtp.enabled }} {{- include "snippet.oncall.smtp.env" . | nindent 12 }} - {{- end }} {{- include "snippet.mysql.env" . | nindent 12 }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} diff --git a/helm/oncall/templates/engine/deployment.yaml b/helm/oncall/templates/engine/deployment.yaml index 6563d335..5b1f7776 100644 --- a/helm/oncall/templates/engine/deployment.yaml +++ b/helm/oncall/templates/engine/deployment.yaml @@ -47,9 +47,7 @@ spec: {{- include "snippet.oncall.env" . | nindent 12 }} {{- include "snippet.oncall.slack.env" . | nindent 12 }} {{- include "snippet.oncall.telegram.env" . | nindent 12 }} - {{- if .Values.oncall.smtp.enabled }} {{- include "snippet.oncall.smtp.env" . | nindent 12 }} - {{- end }} {{- include "snippet.mysql.env" . | nindent 12 }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} diff --git a/helm/oncall/templates/engine/job-migrate.yaml b/helm/oncall/templates/engine/job-migrate.yaml index 8dcc39fd..8778f420 100644 --- a/helm/oncall/templates/engine/job-migrate.yaml +++ b/helm/oncall/templates/engine/job-migrate.yaml @@ -43,9 +43,7 @@ spec: python manage.py migrate env: {{- include "snippet.oncall.env" . | nindent 12 }} - {{- if .Values.oncall.smtp.enabled }} {{- include "snippet.oncall.smtp.env" . | nindent 12 }} - {{- end }} {{- include "snippet.mysql.env" . | nindent 12 }} {{- include "snippet.rabbitmq.env" . | nindent 12 }} {{- include "snippet.redis.env" . | nindent 12 }} diff --git a/helm/oncall/values.yaml b/helm/oncall/values.yaml index 974fc442..9dcae3ff 100644 --- a/helm/oncall/values.yaml +++ b/helm/oncall/values.yaml @@ -86,6 +86,7 @@ oncall: username: ~ password: ~ tls: ~ + fromEmail: ~ # Whether to run django database migrations automatically migrate: From 8eed99865a2c54b0f62abed9790cac7e078a7a3a Mon Sep 17 00:00:00 2001 From: David van der Spek Date: Wed, 19 Oct 2022 15:01:49 +0200 Subject: [PATCH 3/3] fix using secret for smtp --- helm/oncall/templates/_env.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/helm/oncall/templates/_env.tpl b/helm/oncall/templates/_env.tpl index 7e4b8f48..089719a7 100644 --- a/helm/oncall/templates/_env.tpl +++ b/helm/oncall/templates/_env.tpl @@ -241,7 +241,6 @@ - name: EMAIL_HOST_USER value: {{ .Values.oncall.smtp.username | quote }} - name: EMAIL_HOST_PASSWORD - value: {{ .Values.oncall.smtp.password | quote }} valueFrom: secretKeyRef: name: {{ include "oncall.fullname" . }}-smtp