Getting started
Kubernetes and k3s with Helm
Install RustPost on k3s or another Kubernetes cluster with the Helm chart: the setup wizard, certificates, client addresses, backups and upgrades.
On this page
The Helm chart runs RustPost on Kubernetes: one server pod, its configuration and message bodies on persistent volumes, a LoadBalancer Service for the mail ports and HTTPS, and PostgreSQL in the same release or your own. It was tested on k3s, a single-node cluster being the expected setup, and works on other distributions with a load balancer.
RustPost is in early development and the edge image follows the main branch. Do not move real mail to it yet.
Requirements
- A Kubernetes cluster and Helm 3. A single machine running k3s is enough. The image is published for amd64 and arm64.
- A public IPv4 address for the mail ports, with a reverse DNS (PTR) record naming your mail host, and outbound port 25 open (or a smarthost).
- A domain whose DNS you control.
- Optionally, a TLS certificate as a
kubernetes.io/tlsSecret, for example from cert-manager. Without one, the setup wizard makes a self-signed certificate to start with.
What the chart does
- One replica. Several active nodes are not supported yet. The Deployment uses the
Recreatestrategy, so an upgrade stops the old pod before starting the new one; mail is acknowledged only once stored, so nothing is lost. - Volumes:
/etc/rustpost(the configuration the wizard writes, and its keys) and/var/lib/rustpost(message bodies, unless you use S3). PostgreSQL has its own volume. - A LoadBalancer Service publishes 25, 465, 587, 143, 993, 4190 and 443 on the standard ports. The container listens on high ports and runs as an unprivileged user with a read-only root filesystem.
- Client addresses are kept. The Service uses
externalTrafficPolicy: Local, so the server sees each client's real address, which SPF, blocklists, rate limits and the logs need. This was checked on k3s's ServiceLB: withLocala test message showed the client's address, and withClusterit showed a node address and went to Junk. - Uninstalling keeps the mail. The configuration and data volumes, the database volume and the generated database password are kept by
helm uninstall, and installing again under the same release name picks them up.
1. Install k3s
Skip this step on an existing cluster. k3s bundles the Traefik ingress controller, which takes ports 80 and 443; disable it so RustPost can serve HTTPS on 443, or give RustPost an address of its own.
curl -sfL https://get.k3s.io | sh -s - --disable=traefik
sudo k3s kubectl get nodesk3s writes its kubeconfig to /etc/rancher/k3s/k3s.yaml. Open the mail ports in the firewall.
2. Install the chart
The chart is in the deploy/helm/rustpost directory of the server repository.
git clone https://github.com/Rust-Post/rustpost-server.git
helm install rustpost rustpost-server/deploy/helm/rustpost \
--namespace mail --create-namespace \
--set hostname=mail.example.org \
--set tls.secretName=mail-tlsLeave out tls.secretName if you have no certificate yet. Every setting is described in the chart's values.yaml; the most common ones are listed below.
kubectl -n mail get pods
kubectl -n mail get svc rustpost # EXTERNAL-IP is the mail ports' address3. Run the setup wizard
On the first start the pod opens the setup wizard instead of the mail ports. Read its one-time link and certificate fingerprint from the log, and reach it through a port-forward, so it never has to be opened to the internet:
kubectl -n mail logs deploy/rustpost | grep -A1 -E "setup wizard|fingerprint"
kubectl -n mail port-forward svc/rustpost 8443:443Open the link with https://localhost:8443 in place of its host and port, and compare the certificate's fingerprint with the log. The chart fills in what it knows:
- Database: the URL of the release's PostgreSQL, whose password is already in the pod's environment.
- Server: the
hostnamevalue. - TLS: with
tls.secretName, the Secret's files,/etc/rustpost/tls/tls.crtand/etc/rustpost/tls/tls.key. Without it, choose a self-signed certificate.
When the wizard finishes, the same pod starts the mail server. Sign in at https://mail.example.org/admin/ once DNS points there.
Without a browser
With setup.mode=cli, an init container configures the server from the chart's values on the first start, with the same checks as the wizard, and prints the DNS records in its log. The administrator's password comes from a Secret.
kubectl -n mail create secret generic rustpost-admin --from-literal=password='…'
helm install rustpost rustpost-server/deploy/helm/rustpost -n mail \
--set setup.mode=cli \
--set hostname=mail.example.org \
--set setup.domain=example.org \
--set setup.adminEmail=admin@example.org \
--set setup.adminPasswordSecret.name=rustpost-admin \
--set tls.secretName=mail-tls
kubectl -n mail logs deploy/rustpost -c setupOnce rustpost.toml exists, neither the wizard nor the init container runs again.
4. DNS records
Point the mail host's A (and AAAA) record at the Service's address, and ask your provider for the matching PTR record. Then publish the records the wizard showed, which the console's Domains page also lists and checks: see DNS records and SPF, DKIM and DMARC.
Certificates with cert-manager
Any kubernetes.io/tls Secret works. With cert-manager, a DNS-01 issuer needs no port 80. The certificate must name the mail host and, for client autoconfiguration and WKD, autoconfig., autodiscover. and openpgpkey. of each domain (which names):
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: mail-tls
namespace: mail
spec:
secretName: mail-tls
issuerRef:
kind: ClusterIssuer
name: letsencrypt-dns # an issuer you have set up
dnsNames:
- mail.example.org
- autoconfig.example.org
- autodiscover.example.org
- openpgpkey.example.orgThe server reads the certificate when it starts, so restart it after each renewal:
kubectl -n mail rollout restart deploy/rustpostOr let a controller such as Reloader do it, with this in your values file:
podAnnotations:
secret.reloader.stakater.com/reload: mail-tlsCommon values
| Value | Default | Meaning |
|---|---|---|
hostname | empty | The mail host name. Offered to the wizard; required with setup.mode=cli. |
setup.mode | wizard | wizard or cli (see above). |
tls.secretName | empty | A kubernetes.io/tls Secret, mounted at /etc/rustpost/tls. |
image.tag, image.digest | edge | The image. Set a digest to stay on one build. |
data.persistence.size | 20Gi | Volume for message bodies. |
postgresql.enabled | true | PostgreSQL 17 in the release. false uses externalDatabase.url and externalDatabase.passwordSecret. |
s3.enabled | false | S3-compatible storage; the keys come from s3.credentialsSecret. Then data.persistence.enabled can be false. |
service.type, service.loadBalancerIP | LoadBalancer | How the mail ports are published. |
service.ports.* | standard ports | Public port of each service; 0 leaves it out. |
resources, nodeSelector, tolerations, affinity | empty | The usual pod settings. |
Managing the server
The rustpost command runs inside the pod:
kubectl -n mail exec deploy/rustpost -- rustpost domain add example.net
kubectl -n mail exec deploy/rustpost -- rustpost dns example.net --checkDomains and users on the command line lists the commands. Pass a password through the environment, never as an argument.
Upgrading
The edge tag moves with the main branch, and the chart pulls it on every start:
helm upgrade rustpost rustpost-server/deploy/helm/rustpost -n mail --reuse-values
kubectl -n mail rollout restart deploy/rustpost # fetch the newest edge imageThe server applies database migrations when it starts. Back up first.
Backups
Dump the database first and copy the message bodies second, as with Docker Compose:
kubectl -n mail exec rustpost-postgresql-0 -- pg_dump -U rustpost -Fc rustpost > rustpost-$(date +%F).dump
kubectl -n mail exec deploy/rustpost -- tar czf - -C /var/lib/rustpost . > rustpost-blobs-$(date +%F).tar.gzKeep a copy of /etc/rustpost too (kubectl -n mail exec deploy/rustpost -- tar czf - -C /etc/rustpost .), and of the database password Secret.
Uninstalling
helm uninstall rustpost -n mailThis removes the pods and Services and keeps the volumes and the database password, so helm install with the same release name finds everything again.
Deleting the PersistentVolumeClaims (kubectl -n mail delete pvc --all) deletes every message, account and setting for good. Take a backup first.
Known limits
- One active replica; several nodes are planned.
- No PROXY protocol yet. A load balancer that replaces the client's address (an L4 proxy, or
externalTrafficPolicy: Cluster) hides it from SPF and the spam checks. - DANE for outgoing mail needs a resolver that passes DNSSEC records. If the log says DNSSEC validation is unavailable through the configured resolver, the cluster DNS (CoreDNS) is forwarding to a resolver that strips them; point it at a validating resolver (on k3s, the
--resolv-confoption). - The chart is installed from the repository for now; a published chart will come with the first releases.