# Email / Mailu Mailu mail server deployed via the official Helm chart (`mailu 2.7.1`, appVersion `2024.06.51`). Managed by Helm, **not** `kubectl apply` — same model as the kube-prometheus-stack release in `Monitoring/`. ## Layout | File | Kind | How to apply | |---|---|---| | `mailu_namespace.yaml` | Namespace | `kubectl apply -f` | | `mailu_lbippool.yaml` | CiliumLoadBalancerIPPool (`10.4.0.0/24`) | `kubectl apply -f` | | `mailu.values.yaml` | Helm values | `helm upgrade ... -f` (do NOT `kubectl apply`) | Two non-Helm manifests (namespace + LBIP pool) are applied once with `kubectl apply -f`. Everything else is rendered by the Helm chart. ## Prerequisites — do these first (in order) ### 1. Apply the namespace + Cilium LB pool ```bash kubectl apply -f Email/mailu_namespace.yaml kubectl apply -f Email/mailu_lbippool.yaml ``` ### 2. Create the Mailu databases on the existing PostgreSQL Mailu reuses the existing `postgres-hetzner` instance in the `database` namespace (`Service postgres.database.svc.cluster.local:5432`, admin user `admin`). The chart does NOT create databases/users when `externalDatabase` is enabled, so do it manually before `helm install`. Get a shell on the postgres pod and create the `mailu` + `roundcube` databases and users. Replace `` and `` with strong generated values (you'll reuse them in the secret below). ```bash # Generate the two passwords once and keep them for the next step: MAILU_PW=$(pwgen 24 1); echo "mailu: $MAILU_PW" ROUNDCUBE_PW=$(pwgen 24 1); echo "roundcube: $ROUNDCUBE_PW" # Create databases + users on the existing postgres-hetzner: kubectl exec -n database deploy/postgres-hetzner -- psql -U admin -d postgres < ` - `MX mariushome.lt -> mail.mariushome.lt (prio 10)` - `TXT mariushome.lt "v=spf1 mx ~all"` - `TXT _dmarc.mariushome.lt "v=DMARC1; p=quarantine; rua=mailto:postmaster@mariushome.lt"` - DKIM: generated by the Mailu admin UI on first boot — add the `TXT` record Mailu shows you (typically `mail._domainkey.mariushome.lt`). - Optional: MTA-STS (`TXT _mta-sts.mariushome.lt` + a `/.well-known/mta-sts.txt` served over HTTPS — chart supports it via `front.overrides`). 3. **Cloudflare**: only the web UIs (`mail.mariushome.lt`, and the `/admin` + `/webmail` paths) are proxied through Cloudflare (orange cloud). The SMTP / IMAP / Submission / ManageSieve ports must **NOT** go through Cloudflare — they need a direct, DNS-only route (grey cloud) to the Hetzner-announced IP. Mail clients should be configured against `mail.mariushome.lt` directly. 4. **Hetzner Cloud firewall**: the current firewalls only allow inbound from the private network and home (`allow-all-internal`, `allow-all-home`, `Home-ip`). There are **no** public inbound rules for 25/465/587/143/993/ 4190, so Mailu is not reachable directly from the internet as-is. To expose it, add explicit inbound TCP rules for those ports (this reopens the public IPs for those ports) while keeping the private/home rules. See `Cluster_admin/firewall.md`. Mailu is not currently deployed (no pods in `mailu`), so this is preparatory. Outbound is allow-all now, but Hetzner may still block outbound 25 for new accounts — confirm before relying on direct delivery. ## Install / upgrade ```bash # One time: helm repo add mailu https://mailu.github.io/helm-charts helm repo update # Install: helm install mailu mailu/mailu -n mailu --version 2.7.1 -f Email/mailu.values.yaml # Upgrade after editing Email/mailu.values.yaml: helm repo update helm upgrade mailu mailu/mailu -n mailu --version 2.7.1 -f Email/mailu.values.yaml ``` The chart version `2.7.1` and `mailuVersion: "2024.06"` in the values are pinned deliberately — a mail server should move conservatively. To bump, edit both the `--version` here and (if needed) `mailuVersion` in the values, then test against a non-production domain first. ## Verification after install ```bash helm status mailu -n mailu kubectl get pods -n mailu # front, admin, imap, smtp, antispam, webmail, redis kubectl get svc -n mailu kubectl get ingress -n mailu kubectl get pvc -n mailu # mail storage (10Gi) only; DB lives on existing postgres-hetzner kubectl get ciliumloadbalancerippool mailu-pool # Confirm the pinned mail LB IP allocated to the front external Service: kubectl get svc -n mailu -l app.kubernetes.io/component=front \ -o jsonpath='{range .items[*]}{.metadata.name}{" "}{.status.loadBalancer.ingress}{"\n"}{end}' # Expect 10.4.0.122 in the ingress list. # Mail flow smoke test (from inside the cluster): kubectl exec -n mailu deploy/mailu-smtp -- swaks --to \ --from admin@mariushome.lt --server mail.mariushome.lt # DNS sanity (run from outside the cluster): dig MX mariushome.lt dig -x # must return mail.mariushome.lt (PTR) ``` ## Notes / gotchas - **`slow` is the default StorageClass** in this cluster (SMB). The mail PVC in `mailu.values.yaml` sets `storageClassName: hcloud-volumes` explicitly — do not remove it, or mail data lands on SMB. (The metadata DB now lives on the existing `postgres-hetzner`, whose PVC already uses `hcloud-volumes`.) - **Only one default StorageClass may exist.** If `kubectl get sc` ever shows two `(default)`, patch the unwanted one (see AGENTS.md). - Mailu reuses the existing `postgres-hetzner` instance (`database` namespace) via `externalDatabase`. The chart's bundled PostgreSQL subchart is disabled (`postgresql.enabled: false`). The `mailu` and `roundcube` databases/users must be created manually before `helm install` — see step 2 above. The custom-postgres image's pgvector extension is irrelevant to Mailu; it works fine against the existing server. - `L2AnnouncementPolicy` (`Cilium/L2AnnouncementPolicy.yaml`) already announces LoadBalancer IPs, so no new policy is needed for `10.4.0.122`. - The `front` chart subchart defaults to `hostPort: true` (assumes bare-metal nodes). This deployment disables `hostPort` and uses `externalService` instead, so the Cilium LBIPAM pool hands out the IP. Do not re-enable `hostPort` on a managed k8s cluster. - `ingress.realIpFrom` lists the Cloudflare CIDRs; if you ever switch the upstream proxy, update this list or `front` will rate-limit / ban the new proxy IPs (Mailu docs warn about this). - Roundcube's DB lives in the existing `postgres-hetzner` instance. The chart does NOT auto-create it for `externalDatabase` mode — step 2 above handles it manually. - `kubectl apply -f` does NOT apply to `mailu.values.yaml` — it is consumed only by `helm`. Applying it with kubectl does nothing useful and may confuse diff tooling. - Admin UI is at `https://mail.mariushome.lt/admin`, webmail at `https://mail.mariushome.lt/webmail` (default paths; configurable via `admin.uri` / webmail settings in the chart).