-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
493 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v2 | ||
appVersion: v1.1.0 | ||
description: A Helm chart for deploying maildev SMTP server. | ||
name: maildev | ||
type: application | ||
version: 0.1.0 | ||
home: https://github.com/redhat-cop/helm-charts | ||
maintainers: | ||
- name: jtudelag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# SMTP relay service | ||
This helm-chart installs [Maildev](https://github.com/maildev/maildev). | ||
|
||
Its mainly usage is to provide with a SMTP relay service inside OpenShift, | ||
so other apps can rely on it to send mails externally. | ||
|
||
Inside the Namespace where it is deployed, an SMTP service is available: `smtp:25`. | ||
|
||
Maildev also provides a Web interface, it can be disabled/enabled at discretion. | ||
By default it exposed at a route. | ||
|
||
Also note that mails do not persist after reboot. Everytime Maildev starts, it starts from scratch, | ||
even if the `/tmp/maildev` folder, where Maildev stores mails, is persisted. | ||
|
||
And I haven't found any way to configure Maildev so it reload previous mails after a reboot.... | ||
|
||
# Sources code | ||
Maildev source code can be here: https://github.com/maildev/maildev | ||
|
||
# Known issue with Env Vars | ||
|
||
Github issue: https://github.com/maildev/maildev/issues/315 | ||
|
||
So, not every option can be configured using env vars, so, a few options are hardcoded in the deployment: | ||
`["--verbose", "--outgoing-secure", "--auto-relay"]` | ||
|
||
## Configuration | ||
|
||
Table with the most relevants parameters for MailDev. | ||
Not listing here the more general paramaters such as tolerations, nodeSelectors, etc. | ||
|
||
| Parameter | Description | Default | | ||
|------------------------------:|:--------------------------------------------------------------------------------------------------|:--------------------------------------------| | ||
| **outgoing_relay.host** | SMTP Relay host, `MAILDEV_OUTGOING_HOST`. | `` | | ||
| **outgoing_relay.port** | SMTP Relay port, `MAILDEV_OUTGOING_PORT`. | `` | | ||
| **outgoing_relay.user** | SMTP Relay user, `MAILDEV_OUTGOING_USER`. | `` | | ||
| **outgoing_relay.pass** | SMTP Relay password, `MAILDEV_OUTGOING_PASS`. | `` | | ||
| **outgoing_relay.secure** | Use SMTP SSL for outgoing emails, `MAILDEV_OUTGOING_SECURE`. | `true`. Hardcoded in the deployment due to a bug. | | ||
| **ports.smtp** | Port where the SMTP service is listenning. (Irrelevant for OCP/K8S), `MAILDEV_SMTP_PORT`. | `1025` | | ||
| **ports.web** | Port where the Web interface service is listenning. (Irrelevant for OCP/K8S), `MAILDEV_WEB_PORT`. | `1080` | | ||
| **web.disable** | Disable Web interface. `MAILDEV_DISABLE_WEB`. | `False` | | ||
| **web.user** | Web interface user, `MAILDEV_WEB_USER`. | `admin` | | ||
| **web.pass** | Web interface password, `MAILDEV_WEB_PASS`. | `` | | ||
| **https.enabled** | Switch from http to https protocol, `MAILDEV_HTTPS`. | `False` | | ||
| **https.key** | The file path to the ssl private key, `MAILDEV_HTTPS_KEY`. | | | ||
| **https.cert** | The file path to the ssl cert file, `MAILDEV_HTTPS_CERT`. | | | ||
| **incoming.user** | SMTP user for incoming emails, `MAILDEV_INCOMING_USER`. | | | ||
| **incoming.pass** | SMTP password for incoming emails, `MAILDEV_INCOMING_PASS`. | | | ||
|
||
# Test it | ||
|
||
rsh into the pod. | ||
```bash | ||
oc rsh $(oc get pod -l "app.kubernetes.io/instance=maildev" -o name) | ||
``` | ||
|
||
Create summy mail.txt file. | ||
```bash | ||
cat <<EOF >> mail.txt | ||
From: Test Maildev <[email protected]> | ||
To: Jorge Tudela <[email protected]> | ||
Subject: Test mail from maildev | ||
Date: Fri, 17 Nov 2020 11:26:16 | ||
Dear Joe, | ||
Welcome to this example email. What a lovely day. | ||
Cheers!! | ||
EOF | ||
``` | ||
|
||
Send the mail with curl: | ||
```bash | ||
curl smtp://smtp:25 --mail-from [email protected] --mail-rcpt [email protected] --upload-file ./mail.txt | ||
``` | ||
|
||
Check the logs and see if the mail has been delivered. | ||
```bash | ||
oc logs $(oc get pod -l "app.kubernetes.io/instance=maildev" -o name) | ||
Temporary directory created at /tmp/maildev | ||
Temporary directory created at /tmp/maildev/1 | ||
MailDev outgoing SMTP Server smtp.gmail.com:465 (user:[email protected], pass:####, secure:yes) | ||
Auto-Relay mode on | ||
MailDev webapp running at http://0.0.0.0:1080 | ||
MailDev SMTP Server running at 0.0.0.0:1025 | ||
Saving email: Test mail from maildev, id: 3ZhYnk5q | ||
MailDev outgoing SMTP Server smtp.gmail.com:465 (user:[email protected], pass:####, secure:yes) | ||
Mail Delivered: Test mail from maildev | ||
``` | ||
Alternatively you can check the webconsole. | ||
```bash | ||
oc get route web-maildev -o=jsonpath='{.spec.host}' | ||
``` | ||
Check your mail inbox ;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Sources code here: https://github.com/maildev/maildev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "maildev.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "maildev.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "maildev.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "maildev.labels" -}} | ||
helm.sh/chart: {{ include "maildev.chart" . }} | ||
{{ include "maildev.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "maildev.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "maildev.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "maildev.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "maildev.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v1 | ||
data: | ||
auto-relay-rules.json: "[\n\t{ \"allow\": \"*\" }\n]\n" | ||
kind: ConfigMap | ||
metadata: | ||
name: maildev-relay-rules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "maildev.fullname" . }} | ||
labels: | ||
{{- include "maildev.labels" . | nindent 4 }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
selector: | ||
matchLabels: | ||
{{- include "maildev.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
labels: | ||
{{- include "maildev.selectorLabels" . | nindent 8 }} | ||
spec: | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
serviceAccountName: {{ include "maildev.serviceAccountName" . }} | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 12 }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
command: ["/opt/app-root/src/bin/maildev"] | ||
args: ["--verbose", "--outgoing-secure", "--auto-relay"] | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
ports: | ||
- name: smtp-port | ||
containerPort: {{ .Values.ports.smtp }} | ||
protocol: TCP | ||
- name: web-port | ||
containerPort: {{ .Values.ports.web }} | ||
protocol: TCP | ||
env: | ||
- name: MAILDEV_DISABLE_WEB | ||
value: "{{ .Values.web.disable }}" | ||
{{- if or .Values.web.user .Values.web.pass}} | ||
- name: MAILDEV_WEB_USER | ||
value: "{{ .Values.web.user }}" | ||
- name: MAILDEV_WEB_PASS | ||
value: "{{ .Values.web.pass }}" | ||
{{- end }} | ||
- name: MAILDEV_SMTP_PORT | ||
value: "{{ .Values.ports.smtp }}" | ||
- name: MAILDEV_WEB_PORT | ||
value: "{{ .Values.ports.web }}" | ||
- name: MAILDEV_HTTPS | ||
value: "{{ .Values.https.enabled }}" | ||
{{- if .Values.https.key }} | ||
- name: MAILDEV_HTTPS_KEY | ||
value: "{{ .Values.https.key }}" | ||
{{- end }} | ||
{{- if .Values.https.cert }} | ||
- name: MAILDEV_HTTPS_CERT | ||
value: "{{ .Values.https.cert }}" | ||
{{- end }} | ||
- name: MAILDEV_OUTGOING_HOST | ||
value: "{{ .Values.outgoing_relay.host }}" | ||
- name: MAILDEV_OUTGOING_PORT | ||
value: "{{ .Values.outgoing_relay.port }}" | ||
- name: MAILDEV_OUTGOING_USER | ||
value: "{{ .Values.outgoing_relay.user }}" | ||
- name: MAILDEV_OUTGOING_PASS | ||
value: "{{ .Values.outgoing_relay.pass }}" | ||
- name: MAILDEV_OUTGOING_SECURE | ||
value: "{{ .Values.outgoing_relay.secure }}" | ||
{{- if .Values.incoming }} | ||
- name: MAILDEV_INCOMING_USER | ||
value: "{{ .Values.incoming.user }}" | ||
- name: MAILDEV_INCOMING_PASS | ||
value: "{{ .Values.incoming.pass }}" | ||
{{- end }} | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: {{ .Values.ports.web }} | ||
readinessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: {{ .Values.ports.web }} | ||
resources: | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
volumeMounts: | ||
- name: auto-relay-rules | ||
mountPath: /etc/maildev | ||
subpath: auto-relay-rules.json | ||
volumes: | ||
- name: auto-relay-rules | ||
configMap: | ||
name: maildev-relay-rules | ||
items: | ||
- key: auto-relay-rules.json | ||
path: auto-relay-rules.json | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{- if .Values.ports.smtp }} | ||
apiVersion: route.openshift.io/v1 | ||
kind: Route | ||
metadata: | ||
name: "smtp" | ||
labels: | ||
{{- include "maildev.labels" . | nindent 4 }} | ||
spec: | ||
port: | ||
targetPort: {{ .Values.ports.smtp }} | ||
to: | ||
kind: Service | ||
name: smtp | ||
weight: 100 | ||
tls: | ||
termination: passthrough | ||
wildcardPolicy: None | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if .Values.ports.web }} | ||
apiVersion: route.openshift.io/v1 | ||
kind: Route | ||
metadata: | ||
name: "web-{{ include "maildev.fullname" . }}" | ||
labels: | ||
{{- include "maildev.labels" . | nindent 4 }} | ||
spec: | ||
port: | ||
targetPort: {{ .Values.ports.web }} | ||
to: | ||
kind: Service | ||
name: web-{{ include "maildev.fullname" . }} | ||
weight: 100 | ||
wildcardPolicy: None | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.ports.smtp }} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: smtp | ||
labels: | ||
{{- include "maildev.labels" . | nindent 4 }} | ||
spec: | ||
type: {{ .Values.service.type }} | ||
ports: | ||
- name: smtp-{{ .Values.ports.smtp }}-tcp | ||
port: 25 | ||
protocol: TCP | ||
targetPort: {{ .Values.ports.smtp }} | ||
selector: | ||
{{- include "maildev.selectorLabels" . | nindent 4 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.ports.web }} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: "web-{{ include "maildev.fullname" . }}" | ||
labels: | ||
{{- include "maildev.labels" . | nindent 4 }} | ||
spec: | ||
type: {{ .Values.service.type }} | ||
ports: | ||
- name: web-{{ .Values.ports.smtp }}-tcp | ||
port: {{ .Values.ports.web }} | ||
protocol: TCP | ||
targetPort: {{ .Values.ports.web }} | ||
selector: | ||
{{- include "maildev.selectorLabels" . | nindent 4 }} | ||
{{- end }} |
Oops, something went wrong.