updated the deployment manifests. Tested with Kubernetes 1.17 and docker-mailserver v6.2.1

This commit is contained in:
Remo E 2020-02-02 19:28:51 +01:00
parent 30bbc15a8b
commit f9ec66904f
1 changed files with 162 additions and 70 deletions

View File

@ -3,32 +3,35 @@
There is nothing much in deploying mailserver to Kubernetes itself. The things are pretty same as in [`docker-compose.yml`][1], but with Kubernetes syntax. There is nothing much in deploying mailserver to Kubernetes itself. The things are pretty same as in [`docker-compose.yml`][1], but with Kubernetes syntax.
```yaml ```yaml
kind: Service
apiVersion: v1 apiVersion: v1
kind: Namespace
metadata: metadata:
name: mailserver name: mailserver
---
kind: ConfigMap
apiVersion: v1
metadata:
name: mailserver.env.config
namespace: mailserver
labels: labels:
app: mailserver app: mailserver
spec: data:
selector: OVERRIDE_HOSTNAME: example.com
app: mailserver ENABLE_FETCHMAIL: "0"
ports: FETCHMAIL_POLL: "120"
- name: smtp ENABLE_SPAMASSASSIN: "0"
port: 25 ENABLE_CLAMAV: "0"
targetPort: smtp ENABLE_FAIL2BAN: "0"
- name: smtp-auth ENABLE_POSTGREY: "0"
port: 587 ONE_DIR: "1"
targetPort: smtp-auth DMS_DEBUG: "0"
- name: imap-secure
port: 993
targetPort: imap-secure
--- ---
kind: ConfigMap kind: ConfigMap
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: mailserver.config name: mailserver.config
namespace: mailserver
labels: labels:
app: mailserver app: mailserver
data: data:
@ -38,6 +41,18 @@ data:
postfix-virtual.cf: | postfix-virtual.cf: |
alias1@example.com user1@dexample.com alias1@example.com user1@dexample.com
#dovecot.cf: |
# service stats {
# unix_listener stats-reader {
# group = docker
# mode = 0666
# }
# unix_listener stats-writer {
# group = docker
# mode = 0666
# }
# }
SigningTable: | SigningTable: |
*@example.com mail._domainkey.example.com *@example.com mail._domainkey.example.com
@ -48,12 +63,17 @@ data:
127.0.0.1 127.0.0.1
localhost localhost
--- #user-patches.sh: |
# #!/bin/bash
#fetchmail.cf: |
---
kind: Secret kind: Secret
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: mailserver.opendkim.keys name: mailserver.opendkim.keys
namespace: mailserver
labels: labels:
app: mailserver app: mailserver
type: Opaque type: Opaque
@ -61,46 +81,95 @@ data:
example.com-mail.key: 'base64-encoded-DKIM-key' example.com-mail.key: 'base64-encoded-DKIM-key'
--- ---
kind: Service
kind: Deployment apiVersion: v1
apiVersion: extensions/v1beta1
metadata: metadata:
name: mailserver name: mailserver
namespace: mailserver
labels: labels:
app: mailserver app: mailserver
spec: spec:
strategy: selector:
type: Recreate app: mailserver
ports:
- name: smtp
port: 25
targetPort: smtp
- name: smtp-secure
port: 465
targetPort: smtp-secure
- name: smtp-auth
port: 587
targetPort: smtp-auth
- name: imap
port: 143
targetPort: imap
- name: imap-secure
port: 993
targetPort: imap-secure
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mailserver
namespace: mailserver
spec:
replicas: 1
selector:
matchLabels:
app: mailserver
template: template:
metadata: metadata:
labels: labels:
app: mailserver app: mailserver
role: mail
tier: backend
spec: spec:
nodeSelector: #nodeSelector:
has/mail-server: 'true' # kubernetes.io/hostname: local.k8s
subdomain: mailserver #initContainers:
#- name: init-myservice
# image: busybox
# command: ["/bin/sh", "-c", "cp /tmp/user-patches.sh /tmp/files"]
# volumeMounts:
# - name: config
# subPath: user-patches.sh
# mountPath: /tmp/user-patches.sh
# readOnly: true
# - name: tmp-files
# mountPath: /tmp/files
containers: containers:
- name: mailserver
image: tvial/docker-mailserver:2.1
ports:
- name: smtp - name: smtp
containerPort: 25 image: tvial/docker-mailserver:release-v6.2.1
- name: smtp-auth imagePullPolicy: Always
containerPort: 587
- name: imap-secure
containerPort: 993
env:
- name: ONE_DIR
value: '1'
volumeMounts: volumeMounts:
- name: config - name: config
subPath: postfix-accounts.cf subPath: postfix-accounts.cf
mountPath: /tmp/docker-mailserver/postfix-accounts.cf mountPath: /tmp/docker-mailserver/postfix-accounts.cf
readOnly: true readOnly: true
#- name: config
# subPath: postfix-main.cf
# mountPath: /tmp/docker-mailserver/postfix-main.cf
# readOnly: true
- name: config - name: config
subPath: postfix-virtual.cf subPath: postfix-virtual.cf
mountPath: /tmp/docker-mailserver/postfix-virtual.cf mountPath: /tmp/docker-mailserver/postfix-virtual.cf
readOnly: true readOnly: true
- name: config
subPath: fetchmail.cf
mountPath: /tmp/docker-mailserver/fetchmail.cf
readOnly: true
- name: config
subPath: dovecot.cf
mountPath: /tmp/docker-mailserver/dovecot.cf
readOnly: true
#- name: config
# subPath: user1.example.com.dovecot.sieve
# mountPath: /tmp/docker-mailserver/user1@example.com.dovecot.sieve
# readOnly: true
#- name: tmp-files
# subPath: user-patches.sh
# mountPath: /tmp/docker-mailserver/user-patches.sh
- name: config - name: config
subPath: SigningTable subPath: SigningTable
mountPath: /tmp/docker-mailserver/opendkim/SigningTable mountPath: /tmp/docker-mailserver/opendkim/SigningTable
@ -118,8 +187,31 @@ spec:
readOnly: true readOnly: true
- name: data - name: data
mountPath: /var/mail mountPath: /var/mail
- name: state subPath: data
- name: data
mountPath: /var/mail-state mountPath: /var/mail-state
subPath: state
- name: data
mountPath: /var/log/mail
subPath: log
ports:
- name: smtp
containerPort: 25
protocol: TCP
- name: smtp-secure
containerPort: 465
protocol: TCP
- name: smtp-auth
containerPort: 587
- name: imap
containerPort: 143
protocol: TCP
- name: imap-secure
containerPort: 993
protocol: TCP
envFrom:
- configMapRef:
name: mailserver.env.config
volumes: volumes:
- name: config - name: config
configMap: configMap:
@ -128,11 +220,11 @@ spec:
secret: secret:
secretName: mailserver.opendkim.keys secretName: mailserver.opendkim.keys
- name: data - name: data
hostPath: persistentVolumeClaim:
path: /path/to/mailserver/data claimName: mail-storage
- name: state - name: tmp-files
hostPath: emptyDir: {}
path: /path/to/mailserver/state
``` ```
__Note:__ __Note:__