Here's a step-by-step guide to deploy Dovecot using Kubernetes manifests:
apiVersion: v1
kind: Namespace
metadata:
name: dovecot
Apply the namespace:
kubectl apply -f namespace.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: dovecot-config
namespace: dovecot
data:
dovecot.conf: |
protocols = imap pop3
listen = *
mail_location = maildir:/var/mail/%d/%n
ssl = yes
ssl_cert = </etc/ssl/certs/dovecot.pem
ssl_key = </etc/ssl/private/dovecot.key
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dovecot-mail-pvc
namespace: dovecot
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
apiVersion: apps/v1
kind: Deployment
metadata:
name: dovecot
namespace: dovecot
spec:
replicas: 1
selector:
matchLabels:
app: dovecot
template:
metadata:
labels:
app: dovecot
spec:
containers:
- name: dovecot
image: dovecot/dovecot:latest
ports:
- containerPort: 143
name: imap
- containerPort: 993
name: imaps
volumeMounts:
- name: dovecot-config
mountPath: /etc/dovecot
- name: dovecot-mail
mountPath: /var/mail
volumes:
- name: dovecot-config
configMap:
name: dovecot-config
- name: dovecot-mail
persistentVolumeClaim:
claimName: dovecot-mail-pvc
apiVersion: v1
kind: Service
metadata:
name: dovecot
namespace: dovecot
spec:
type: LoadBalancer
ports:
- port: 143
targetPort: 31143
name: imap
- port: 993
targetPort: 31993
name: imaps
selector:
app: dovecot
Save each manifest in separate YAML files and apply them in order:
kubectl apply -f namespace.yaml
kubectl apply -f configmap.yaml
kubectl apply -f pvc.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl get all -n dovecot
kubectl get pods -n dovecot
kubectl describe deployment dovecot -n dovecot