stalwart
by andibraeu
Helm chart for the Stalwart mail and collaboration server
About this chart
Stalwart Helm Chart
Helm chart for Stalwart Mail Server, based on the official Kubernetes reference.
Installation
helm install stalwart ./charts/stalwart
Configuration
PostgreSQL DataStore with external Secrets
Typical GitOps setup with CloudNativePG and SealedSecrets:
image:
repository: stalwartlabs/stalwart
tag: "" # Uses Chart.yaml appVersion when empty
env:
secretRef: stalwart-env
dbPasswordSecret:
name: stalwart-db-credentials
key: password
config:
"@type": PostgreSql
host: stalwart-db-rw
port: 5432
database: stalwart
authUsername: stalwart
authSecret:
"@type": EnvironmentVariable
variableName: STALWART_DB_PASSWORD
persistence:
enabled: false
ingress:
enabled: true
className: traefik
hosts:
- host: stalwart.example.com
paths:
- path: /
pathType: Prefix
portName: mgmt
tls:
- secretName: wildcard-tls
hosts:
- stalwart.example.com
First install bootstrap
Enable recovery credentials in values for the first install, then disable after creating a permanent admin account:
recoveryAdmin:
enabled: true
username: admin
password: "choose-a-strong-password"
Alternatively, provide STALWART_RECOVERY_ADMIN via env.secretRef.
Persistence
Disable persistence when the DataStore is external (PostgreSQL, MySQL, etc.). Enable it for local RocksDB backends.
persistence:
enabled: true
accessMode: ReadWriteOnce
storageClass: local-path
size: 10Gi
Upgrading from 1.x to 2.0
Chart 2.0 moves from Stalwart v0.16 to Stalwart v1. Stalwart v1 uses a new database layout and cannot open a v0.16 data store, so an in-place upgrade is not possible. The data has to be copied into a new, empty data store with stalwart-migrate. The tool opens the v0.16 store read-only, so the old deployment remains a fallback.
-
Upgrade to chart
1.0.7(Stalwart v0.16.27) first; the migration tool requires exactly this version. -
Create a new, empty data store (for example a new PostgreSQL database) and a
config.jsonfor it. -
Run the migration tool (image
stalwartlabs/stalwart-migrate) in a pod that mounts the current<release>-configConfigMap at/etc/stalwart, the new configuration at/etc/stalwart-v1and a persistent state directory at/var/lib/stalwart-migrate:stalwart-migrate prepare(interactive, usekubectl exec -it)stalwart-migrate run(incremental, may run while v0.16 is serving)- scale the StatefulSet to 0, then
stalwart-migrate run --final stalwart-migrate report --severity error
-
Set
configto the new data store, upgrade to chart 2.x and start once with:extraEnv: STALWART_UPDATE_ROLE_PERMISSIONS: "true"Remove the variable after the first successful start.
Keep the v0.16 data store and the migration state directory until v1 has
proven itself; stalwart-migrate rollback needs the state directory.
Visible effects after the switch: OAuth tokens are not migrated (users sign in again), CalDAV/CardDAV/WebDAV clients re-download their data once, and the full-text index is rebuilt in the background.
See the official migration guide for all options.
Mail exposure
The Ingress only covers HTTP/HTTPS management traffic. SMTP, IMAP, POP3, and ManageSieve require L4 exposure via service.type: LoadBalancer or an external load balancer.
Testing
helm lint charts/stalwart
helm template stalwart charts/stalwart -f values.yaml
Deploy stalwart with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has stalwart on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartstalwart is pinned at v2.0.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply