ejabberd

by martialblog

Helm chartv0.3.1Apache-2.0

A Helm chart for installing the ejabberd messaging server on Kubernetes

About this chart

ejabberd Helm chart

A Helm chart for deploying the ejabberd messaging server based on the official container image.

ejabberd XMPP Server is a Rock Solid, Massively Scalable, Infinitely Extensible Realtime Platform

TL;DR

# generate self-signed ceritifcate
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes -subj '/CN=localhost'
# inject into cluster
kubectl create secret tls ejabberd-cert --cert=cert.pem --key=key.pem
# add Helm repository
helm repo add martialblog https://martialblog.github.io/helm-charts
# install Helm chart
helm install ejabberd martialblog/ejabberd
# check the logs
kubectl logs deploy/ejabberd

Checklist

  • [x] Deployment and Services
  • [x] Security: minimal privileges for ejabberd (separate ServiceAccount and restricted SecurityContext)
  • [x] Persistence: PVC (optional)
  • [x] Certificates: cert-manager integration (optional)
  • [x] Configuration: specify custom overrides for ejabberd.yml
  • [ ] Clustering: scale the deployment to multiple replicas
  • [x] Reload at runtime: apply configuration changes and certificate updates without restarting the server
  • [ ] Unit tests for Helm chart

Values

To explore all configuration parameters, please visit the values.yaml file. It is well commented and explains all the options.

FAQ

How to change the ejabberd configuration?

https://github.com/processone/ejabberd/blob/master/ejabberd.yml.example

How to use an external database?

By default, ejabberd uses its built-in Mnesia database for storing messages, users accounts etc., which is an in-process local database (the same principal as SQLite). The size of this database is limited however and it is general not recommended for production setups.

An external database can be configured with the following parameters:


config:
  default_db: "sql"
  sql_type: "mysql"
  sql_server: "mariadb.namespace.svc.cluster.local"
  sql_port: 3306
  sql_database: "ejabberd"
  sql_username: "ejabberd"
  sql_password: "hunter2"

Several database types are supported, see https://docs.ejabberd.im/admin/configuration/database/.

How to use a certificate?

Most XMPP clients require a TLS encrypted connection, ideally with a certificate signed by trusted root CA. If you have the cert-manager stack installed in your Kubernetes cluster, you can create a certificate and signing request automatically like this:

config:
  hosts:
    - example.com
  certfiles:
    - /opt/ejabberd/cert/tls.crt
    - /opt/ejabberd/cert/tls.key

certificate:
  create: true
  issuerRef:
    group: cert-manager.io
    kind: ClusterIssuer
    name: "letsencrypt-production"

Alternatively, with a custom certificate:

kubectl create secret tls my-ejabberd-certificate --cert=cert.pem --key=key.pem
config:
  hosts:
    - example.com
  certfiles:
    - /opt/ejabberd/cert/tls.crt
    - /opt/ejabberd/cert/tls.key

certificate:
  secretName: my-ejabberd-certificate

License

This Helm chart is licensed under the Apache 2.0 license - see LICENSE.

Deploy ejabberd with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has ejabberd 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartejabberd is pinned at v0.3.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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