Skip to content

Commit 2a1d418

Browse files
authored
doc: document setup and test-connection for mailu front (#392)
1 parent 754a752 commit 2a1d418

File tree

3 files changed

+131
-3
lines changed

3 files changed

+131
-3
lines changed

charts/mailu/SETUPS.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Mailu setups with the Helm Chart
2+
3+
WIP: This document shall describe and show how Mailu can be setup with the Helm Chart.
4+
5+
> [!IMPORTANT]
6+
> Routing all traffic, including Web traffic through the Mailu `front` service is done **on purpose** to deliver
7+
> an integrated service to the users of Mailu. You are free to run components separately, but such setups are not in scope
8+
> of the Mailu project or the Mailu Helm Chart and are not supported. Using `HTTPS` as backend for the ingress is also a
9+
> conscious decision and allows for an integrated experience while keeping the scope small for the volunteer dev team.
10+
11+
## Simple setup
12+
13+
This is a simple setup to make Mailu services available from the internet.
14+
Cert-manager is used to get a certificate for the Ingress. The same certificate is used by the `front` deployment for
15+
mail services.
16+
17+
How traffic is routed from a public IP address to individual K8s nodes is out of scope and must be taken care of individually.
18+
Typically K8s nodes have private IP addresses and a Service of type LoadBalancer is used to make services available on public IPs.
19+
20+
This setup is using a single instance where Mail services will be reachable either through HostPort or
21+
a Service of type NodePort or LoadBalancer.
22+
23+
```mermaid
24+
flowchart TD
25+
%% entities
26+
Internet(Internet)
27+
LoadBalancer(LoadBalancer)
28+
29+
Ingress("`**Ingress**
30+
service`")
31+
FrontService("`**NodePort/LoadBalancer**
32+
service`")
33+
Front("`**Mailu front**
34+
single pod`")
35+
Webmail("`**Mailu webmail**
36+
single pod`")
37+
MailServices("`**Mailu smtp/imap...**
38+
pods`")
39+
40+
41+
Internet -. NodePort .-> Node1
42+
Internet -. NodePort .-> Node2
43+
Internet -. "HostPort:\n25/.../995" .-> Front
44+
Internet -. LoadBalancer .-> LoadBalancer
45+
LoadBalancer -- 25/.../995 --> FrontService
46+
47+
subgraph Node1[k8s node 1]
48+
IngressController1 -- 80/443 --> Ingress
49+
end
50+
51+
subgraph Node2[k8s node 2]
52+
IngressController2 -- 80/443 --> Ingress
53+
54+
FrontService -- 25/.../995 --> Front
55+
Ingress -- HTTPS --> Front
56+
57+
Front --> MailServices
58+
Front --> Webmail
59+
end
60+
```
61+
62+
### Using HostPort (default)
63+
64+
- Enabled by default through `front.hostPort.enabled=true`
65+
- Ingress for Webmail (80, 443)
66+
- Host ports (25, 110, 143, 465, 587, 993, 995)
67+
- binding ports on the current node (host) directly to the front pod
68+
69+
### Using NodePort
70+
71+
Same as the above, but using a Service of type `NodePort` to bind ports on every node to the external service.
72+
73+
```yaml
74+
# values.yaml
75+
front:
76+
hostPort:
77+
enabled: false
78+
externalService:
79+
enabled: true
80+
type: NodePort
81+
nodePort:
82+
# optionally define specific ports
83+
imaps: 30995
84+
```
85+
86+
### Using LoadBalancer
87+
88+
Again the same as above, but using a Service of type `LoadBalancer` to assign a public IP on which to reach the external service:
89+
90+
```yaml
91+
# values.yaml
92+
front:
93+
hostPort:
94+
enabled: false
95+
externalService:
96+
enabled: true
97+
type: LoadBalancer
98+
```
99+
100+
## K8s nodes with public IPs
101+
102+
> [!WARNING]
103+
> Traffic between pods is unencrypted, use [istio](https://istio.io/) or similar to ensure traffic between pods of the k8s nodes is encrypted.
104+
105+
If your cluster nodes use public IPs, you can directly access the mail ports from the internet, for example using the
106+
default HostPort or a NodePort Service described above.

charts/mailu/ci/helm-lint-values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
hostnames:
2-
- example.com
2+
- mailu.cluster.local
33

4-
domain: example.com
4+
domain: mailu.cluster.local
55

66
initialAccount:
77
enabled: true
88
username: mailadmin
9-
domain: example.com
9+
domain: mailu.cluster.local
1010
password: chang3m3!
1111

1212
secretKey: chang3m3!
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: "{{ include "mailu.fullname" . }}-test-connection"
5+
labels: {{- include "common.labels.standard" . | nindent 4 }}
6+
annotations:
7+
"helm.sh/hook": test
8+
spec:
9+
containers:
10+
- name: wget
11+
image: busybox
12+
command: ['/bin/sh']
13+
args:
14+
- '-c'
15+
- |
16+
{{- range .Values.hostnames }}
17+
# HTTP redirects to HTTPS
18+
wget -S --header "Host: {{ . }}" 'http://{{ printf "%s-front" (include "mailu.fullname" $) }}.{{ include "common.names.namespace" $ }}.svc.cluster.local'
19+
# HTTPS redirects to SSO page
20+
wget -S --header "Host: {{ . }}" 'https://{{ printf "%s-front" (include "mailu.fullname" $) }}.{{ include "common.names.namespace" $ }}.svc.cluster.local'
21+
{{- end }}
22+
restartPolicy: Never

0 commit comments

Comments
 (0)