From eb8255f99f045830b23ea5f274127a8c37ccd7cf Mon Sep 17 00:00:00 2001 From: Rei Date: Fri, 9 Apr 2021 17:05:29 +0200 Subject: [PATCH] [mailhog] Add Outgoing SMTP config (#409) * Add outgoing-smtp secret and values * Docs * Bump chart version * Do not use default values for outgoingSMTP.fileContents Co-authored-by: Rainer 'rei' Schuth Co-authored-by: mircohaug --- charts/mailhog/Chart.yaml | 2 +- charts/mailhog/templates/_helpers.tpl | 11 +++++++++++ charts/mailhog/templates/deployment.yaml | 16 ++++++++++++++++ charts/mailhog/templates/smtp-secret.yaml | 12 ++++++++++++ charts/mailhog/values.yaml | 22 ++++++++++++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 charts/mailhog/templates/smtp-secret.yaml diff --git a/charts/mailhog/Chart.yaml b/charts/mailhog/Chart.yaml index 70f8cb27..9d0fd956 100644 --- a/charts/mailhog/Chart.yaml +++ b/charts/mailhog/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 description: An e-mail testing tool for developers name: mailhog appVersion: v1.0.1 -version: 4.0.0 +version: 4.1.0 type: application keywords: - mailhog diff --git a/charts/mailhog/templates/_helpers.tpl b/charts/mailhog/templates/_helpers.tpl index d811cd6e..64897b5c 100644 --- a/charts/mailhog/templates/_helpers.tpl +++ b/charts/mailhog/templates/_helpers.tpl @@ -70,3 +70,14 @@ Create the name for the auth secret. {{- template "mailhog.fullname" . -}}-auth {{- end -}} {{- end -}} + +{{/* +Create the name for the outgoing-smtp secret. +*/}} +{{- define "mailhog.outgoingSMTPSecret" -}} + {{- if .Values.outgoingSMTP.existingSecret -}} + {{- .Values.outgoingSMTP.existingSecret -}} + {{- else -}} + {{- template "mailhog.fullname" . -}}-outgoing-smtp + {{- end -}} +{{- end -}} diff --git a/charts/mailhog/templates/deployment.yaml b/charts/mailhog/templates/deployment.yaml index 1c907d5e..1e8f717c 100644 --- a/charts/mailhog/templates/deployment.yaml +++ b/charts/mailhog/templates/deployment.yaml @@ -44,6 +44,10 @@ spec: - name: MH_AUTH_FILE value: /authdir/{{ .Values.auth.fileName }} {{- end }} + {{- if .Values.outgoingSMTP.enabled }} + - name: MH_OUTGOING_SMTP + value: /config/{{ .Values.outgoingSMTP.fileName }} + {{- end }} {{- with .Values.extraEnv }} {{- toYaml . | nindent 12 }} {{- end }} @@ -68,6 +72,12 @@ spec: mountPath: /authdir readOnly: true {{- end }} + {{- if .Values.outgoingSMTP.enabled }} + volumeMounts: + - name: outsmtpdir + mountPath: /config + readOnly: true + {{- end }} {{- with .Values.containerSecurityContext }} securityContext: {{- toYaml . | nindent 12 }} @@ -92,3 +102,9 @@ spec: secret: secretName: {{ template "mailhog.authFileSecret" . }} {{- end }} + {{- if .Values.outgoingSMTP.enabled }} + volumes: + - name: outsmtpdir + secret: + secretName: {{ template "mailhog.outgoingSMTPSecret" . }} + {{- end }} diff --git a/charts/mailhog/templates/smtp-secret.yaml b/charts/mailhog/templates/smtp-secret.yaml new file mode 100644 index 00000000..b1178bbf --- /dev/null +++ b/charts/mailhog/templates/smtp-secret.yaml @@ -0,0 +1,12 @@ +{{- if and (.Values.outgoingSMTP.enabled) (not .Values.outgoingSMTP.existingSecret) -}} +apiVersion: v1 +kind: Secret +metadata: + labels: + {{- include "mailhog.labels" . | nindent 4 }} + name: {{ template "mailhog.outgoingSMTPSecret" . }} + namespace: {{ .Release.Namespace }} +type: Opaque +data: + {{ .Values.outgoingSMTP.fileName }}: {{ .Values.outgoingSMTP.fileContents | toJson | b64enc }} +{{- end -}} diff --git a/charts/mailhog/values.yaml b/charts/mailhog/values.yaml index 1eb868d7..d06b5912 100644 --- a/charts/mailhog/values.yaml +++ b/charts/mailhog/values.yaml @@ -68,6 +68,28 @@ auth: fileName: auth.txt fileContents: "" +# JSON file defining outgoing SMTP servers +outgoingSMTP: + enabled: false + existingSecret: "" + fileName: outgoing-smtp.json + fileContents: {} + # See https://github.com/mailhog/MailHog/blob/master/docs/CONFIG.md#outgoing-smtp-configuration + # Only name, host and port are required. + # + # server_name1: + # name: "server_name1" + # host: "mail.example.com" + # port: "25" # NOTE: go requires this port number to be a string... otherwise the container won't start + # email: "" + # username: "" + # password: "" + # mechanism: "PLAIN|CRAM-MD5" + # server_name2: + # name: "server_name2" + # host: "mail2.example.com" + # port: "587" # NOTE: go requires this port number to be a string... otherwise the container won't start + podAnnotations: {} podLabels: {}