Skip to content

Commit 85f10fb

Browse files
committedMar 14, 2017
first pass. lacking documentation.
1 parent 35f91f5 commit 85f10fb

18 files changed

+136
-1
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+

‎README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# kubernetes-postfix-relay-host
2-
A SMTP relay host for transactional based emails from within a cluster.
2+
A SMTP relay host for transactional based emails.
3+
4+
Alpine/docker/postfix

‎image/.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.md

‎image/Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM alpine:3.4
2+
MAINTAINER Chris Dornsife <chris@applariat.com>
3+
4+
RUN apk add --no-cache postfix rsyslog supervisor \
5+
&& /usr/bin/newaliases \
6+
&& postconf 'mynetworks = 10.0.0.0/8,127.0.0.0/8,172.17.0.0/16' \
7+
&& postconf 'smtp_sasl_auth_enable = yes' \
8+
&& postconf 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd' \
9+
&& postconf 'smtp_sasl_security_options =' \
10+
&& postconf 'smtputf8_enable = no' \
11+
&& postconf 'always_add_missing_headers = yes'
12+
13+
COPY . /
14+
15+
EXPOSE 25
16+
17+
ENTRYPOINT [ "/tx-smtp.sh" ]
18+

‎image/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# kubernetes-postfix-relay-host Docker image
2+
A SMTP relay host for transactional based emails from within a cluster.

‎image/etc/rsyslog.conf

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# http://www.rsyslog.com/doc/
2+
3+
$ModLoad immark.so # provide --MARK-- message capability
4+
5+
$IncludeConfig /etc/rsyslog.d/*.conf
6+

‎image/etc/rsyslog.d/imux.conf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Input modules
2+
module(load="imuxsock")
3+
input(type="imuxsock" Socket="/var/run/rsyslog/dev/log" CreatePath="on")

‎image/etc/rsyslog.d/maillog.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mail.* -/var/log/maillog

‎image/etc/rsyslog.d/stdout.conf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$ModLoad omstdout.so # provide messages to stdout
2+
3+
*.* :omstdout: # send everything to stdout

‎image/etc/supervisor.d/postfix.ini

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[program:postfix]
2+
process_name = master
3+
directory = /etc/postfix
4+
command = /usr/sbin/postfix -c /etc/postfix start
5+
startsecs = 0
6+
autorestart = false

‎image/etc/supervisor.d/rsyslog.ini

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[program:rsyslog]
2+
command=/usr/sbin/rsyslogd -n
3+
numprocs=1
4+
autostart=true
5+
autorestart=true
6+
stdout_logfile=/dev/stdout
7+
stdout_logfile_maxbytes=0

‎image/tx-smtp.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
RELAY=${TX_SMTP_RELAY?Missing env var TX_SMTP_RELAY}
4+
USERNAME=${TX_SMTP_RELAY_USERNAME?Missing env var TX_SMTP_RELAY_USERNAME}
5+
PASSWORD=${TX_SMTP_RELAY_PASSWORD?Missing env var TX_SMTP_RELAY_PASSWORD}
6+
7+
8+
# create sasl_passwd.db
9+
echo "${RELAY} ${USERNAME}:${PASSWORD}" > /etc/postfix/sasl_passwd || exit 1
10+
postmap /etc/postfix/sasl_passwd || exit 1
11+
rm /etc/postfix/sasl_passwd || exit 1
12+
13+
# Override what you want here.
14+
postconf "relayhost = ${RELAY}" || exit 1
15+
postconf 'myhostname = tx-smtp.applariat.com' || exit 1
16+
17+
/usr/bin/supervisord -n

‎kubernetes/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tx-smtp-relay-password

‎kubernetes/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# kubernetes-postfix-relay-host
2+
A SMTP relay host for transactional based emails from within a cluster.

‎kubernetes/global-env-cm.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: global-env
6+
data:
7+
tx-smtp-relay-host: "[smtp.sendgrid.net]:587"
8+
tx-smtp-relay-username: your-sendgrid-user

‎kubernetes/global-env-secret.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
# Put your password in a file called tx-smtp-relay-password
4+
echo "---
5+
apiVersion: v1
6+
kind: Secret
7+
metadata:
8+
name: global-env
9+
data:
10+
tx-smtp-relay-password: `base64 tx-smtp-relay-password`
11+
" | kubectl create -f -

‎kubernetes/tx-smtp-deploy.yaml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
apiVersion: extensions/v1beta1
3+
kind: Deployment
4+
metadata:
5+
name: tx-smtp
6+
spec:
7+
replicas: 1
8+
template:
9+
metadata:
10+
labels:
11+
app: tx-smtp
12+
spec:
13+
containers:
14+
- name: tx-smtp
15+
image: applariat/tx-smtp
16+
env:
17+
- name: TX_SMTP_RELAY
18+
valueFrom:
19+
configMapKeyRef:
20+
name: global-env
21+
key: tx-smtp-relay-host
22+
- name: TX_SMTP_RELAY_USERNAME
23+
valueFrom:
24+
configMapKeyRef:
25+
name: global-env
26+
key: tx-smtp-relay-username
27+
- name: TX_SMTP_RELAY_PASSWORD
28+
valueFrom:
29+
secretKeyRef:
30+
name: global-env
31+
key: tx-smtp-relay-password
32+
ports:
33+
- containerPort: 25

‎kubernetes/tx-smtp-svc.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: tx-smtp
6+
spec:
7+
ports:
8+
- port: 25
9+
targetPort: 25
10+
protocol: TCP
11+
selector:
12+
app: tx-smtp

0 commit comments

Comments
 (0)
Please sign in to comment.