Element Server Suite (ESS) Helm Charts

repository·main·Indexed 21 days ago

https://github.com/element-hq/ess-helm

Helm charts for deploying the Element Server Suite (ESS), a complete Matrix stack on Kubernetes. Includes components such as Synapse, Matrix Authentication Service (MAS), Element Web, Matrix RTC Backend, and Well Known Delegation. The repository also provides the ess-migration-tool for converting existing Synapse and MAS configurations into ESS Helm values, and matrix-tools for configuration rendering and utility tasks.

Tokens
32.2K
Snippets
83
Records
131
Agent score
70%

What's inside ess-helm

  1. Overview of Element Server Suite (ESS) Editions

    main

    Element Server Suite (ESS) is a Matrix stack deployment provided via Helm charts. It is available in three editions:

    • ESS Community: A free, AGPLv3-licensed distribution for non-commercial community use (up to 100 users). It includes the core components needed to run a Matrix deployment quickly.
    • ESS Pro: A commercial distribution for professional environments (100 to millions of users). It includes everything in Community plus enterprise features like Synapse Pro (for high availability and multi-tenancy), Secure Border Gateway (application-layer firewall), Advanced IAM (LDAP/SCIM), Content Scanner (malware scanning), and AuditBot/AdminBot.
    • ESS TI-M: A specialized version of ESS Pro designed to meet the requirements of TI-Messenger Pro and ePA as specified by the German National Digital Health Agency Gematik.
  2. Overview of the syn2mas migration process

    main

    The syn2mas feature in the Helm chart facilitates a controlled migration from Synapse's legacy authentication to the Matrix Authentication Service (MAS). This is a one-way process; once the system reaches the delegated_auth state, you cannot roll back to legacy_auth.

    The migration follows three distinct stages:

    1. Setup (Dry Run): MAS is deployed in read-only mode and initializes the database. The system remains in legacy_auth state, and users continue using legacy authentication. The syn2mas job runs in dry-run mode to verify readiness.
    2. Execution (Migration): The migration job runs, downscaling Synapse to 0 replicas during the process. The system transitions to syn2mas_migrated. Users now use delegated authentication. Rollback is no longer possible.
    3. Finalization (Disable syn2mas): The syn2mas feature is disabled, and the system transitions to the final delegated_auth state.
  3. Understand Installation State Persistence

    main

    The ESS Helm chart manages several stateful components that may persist even after a helm uninstall. Understanding their lifecycle is critical for preventing data loss or configuration errors.

    Postgres Persistence

    • Default Behavior: If postgres.enabled: true, the chart creates a PersistentVolumeClaim (PVC). This PVC is not deleted on helm uninstall to prevent data loss.
    • Configuration:
      • To enable deletion on uninstall: Set postgres.storage.resourcePolicy: delete.
      • To use an external DB: Set postgres.enabled: false and provide connection details.
      • To use an existing PVC: Set postgres.storage.existingClaim.

    Synapse Media Persistence

    • Default Behavior: The PVC for Synapse media is not deleted on helm uninstall.
    • Configuration:
      • To enable deletion on uninstall: Set synapse.media.storage.resourcePolicy: delete.
      • To use an existing PVC: Set synapse.media.storage.existingClaim.

    Generated Secrets

    • Purpose: When initSecrets.enabled: true, the chart uses Helm hooks to generate credentials (like Synapse signing keys) to support tools like ArgoCD.
    • Lifecycle: These Secrets (labeled app.kubernetes.io/managed-by=matrix-tools-init-secrets) are not removed on helm uninstall to prevent losing critical credentials.
    • Manual Control: You can disable this by setting initSecrets.enabled: false and providing your own secrets in the values.

    Deployment Markers

    • Purpose: When deploymentMarkers.enabled: true, the chart records the installation state in a ConfigMap to prevent invalid state transitions during upgrades/reinstalls.
    • Lifecycle: The ConfigMap (labeled app.kubernetes.io/managed-by=matrix-tools-deployment-markers) is not removed on helm uninstall.
    • Manual Control: You can disable this by setting deploymentMarkers.enabled: false.
  4. Use Synapse Check Config Hook for Validation

    main
    The Helm chart includes a check-config hook. This hook runs the synapse.config command to validate the Synapse configuration before any changes are applied to the deployment. This prevents invalid configurations from causing production outages by catching errors early in the deployment lifecycle.
  5. Architecture and components of ESS Community

    main

    ESS Community provides a pre-configured Matrix stack. The following components are included out-of-the-box, though they can be enabled, disabled, or customized on a per-component basis:

    • Synapse: The core Matrix server.
    • Matrix Authentication Service: Manages users and authentication.
    • Element Call's Matrix RTC Backend: Enables Element Call functionality in Element X and Element Web.
    • Element Web: The Matrix Web Client.
    • Element Admin: The Admin Console.
    • Hookshot: A Matrix bot for external service integration (GitHub, GitLab, JIRA, etc.).
    • PostgreSQL: An optional packaged database server (recommended to use a dedicated server for long-term production).
    • HAProxy: Handles routing to Synapse processes.
    • .well-known delegation: Required for federation and client discovery.
  6. Use Init Secrets Hook for Password Generation

    main

    The init-secrets hook allows the chart to generate random passwords using a Helm Hook. This removes the need to manually generate and provide passwords beforehand.

    Warning for Production: If you use this feature, you must save the generated secrets in a secure location outside of the cluster to ensure you can recover them if the deployment is lost or recreated.

  7. Understand the Element Server Suite (ESS) Architecture

    main

    Element Server Suite Community is a collection of components used to build a Matrix homeserver. The architecture consists of the following core components:

    • Element Web Client: The web chat interface, preconfigured to use your local homeserver.
    • Synapse Server: The core Matrix homeserver that handles all communication between users. It can be deployed as a multiple-workers deployment to offload processes and handle more users.
    • Redis Pub/Sub: Enables Synapse to broadcast events between different Synapse workers.
    • HAproxy: Acts as a load balancer that distributes Matrix API traffic across Synapse workers and the Matrix Authentication Service (MAS). It also serves /.well-known/matrix and /.well-known/element files.
    • PostgreSQL Database: The primary storage backend for user profiles, room state, messages, and metadata. While the Helm chart provides a PostgreSQL instance by default, production deployments should use an external database.
    • Matrix Authentication Service (MAS): Provides OIDC-based authentication and is enabled by default.
    • Matrix RTC Backend: Provides the backend infrastructure for Matrix VoIP video calls.
  8. Configure individual ESS components

    main

    You can customize individual components by creating a values file for each and injecting custom configuration.

    Important: Some configuration options are managed directly by the Helm chart (e.g., for validation or wiring dependencies). Attempting to override these via the additional mechanism will have no effect.

    To apply custom configurations, you must pass the new values files using the helm upgrade command.

  9. Enable monitoring via Prometheus or Victoria Metrics

    main
    The ESS Community Helm chart automatically provides ServiceMonitor resources. If your cluster has the Prometheus Operator or Victoria Metrics Operator installed, metrics exposed by ESS Community will be automatically scraped without additional configuration.
  10. Set up ESS with existing Wildcard certificates

    main

    If you have a wildcard certificate that covers your server name and all service subdomains:

    1. Import the certificate into the ess namespace:

      kubectl create secret tls ess-certificate -n ess --cert=path/to/cert/file --key=path/to/key/file
    2. Configure ESS by downloading the wildcard fragment to your config directory:

      curl -L https://raw.githubusercontent.com/element-hq/ess-helm/refs/heads/main/charts/matrix-stack/ci/fragments/quick-setup-wildcard-cert.yaml -o ~/ess-config-values/tls.yaml

      Note: Adjust the TLS Secret name in tls.yaml if it differs from ess-certificate.

    kubectl create secret tls ess-certificate -n ess --cert=path/to/cert/file --key=path/to/key/file
    
    curl -L https://raw.githubusercontent.com/element-hq/ess-helm/refs/heads/main/charts/matrix-stack/ci/fragments/quick-setup-wildcard-cert.yaml -o ~/ess-config-values/tls.yaml
  11. Quick setup workflow for ESS Community

    main

    The standard deployment process for ESS Community follows these 6 steps:

    1. Setting up DNS entries: Configure your domain to point to your installation.
    2. Setting up K3s: Prepare your Kubernetes environment (or use another distribution).
    3. Setting up TLS/certificates: Configure Let's Encrypt, individual certificates, or an existing reverse proxy.
    4. Installing the stack: Deploy the Helm charts.
    5. Creating an initial user: Set up your first administrative/user account.
    6. Verifying the setup: Confirm the stack is running correctly.
  12. Set up Let's Encrypt certificates with Cert-Manager

    main

    To automate certificate issuance using Let's Encrypt, use Cert-Manager in your Kubernetes cluster:

    1. Add the Jetstack Helm repository:

      helm repo add jetstack https://charts.jetstack.io --force-update
    2. Install Cert-Manager:

      helm install \
        cert-manager jetstack/cert-manager \
        --namespace cert-manager \
        --create-namespace \
        --version v1.17.0 \
        --set crds.enabled=true
    3. Create a ClusterIssuer to allow ESS to request certificates (using Traefik as the ingress class):

      kubectl apply -f - <<EOF
      apiVersion: cert-manager.io/v1
      kind: ClusterIssuer
      metadata:
        name: letsencrypt-prod
      spec:
        acme:
          server: https://acme-v02.api.letsencrypt.org/directory
          privateKeySecretRef:
            name: letsencrypt-prod-private-key
          solvers:
            - http01:
                ingress:
                  class: traefik
      EOF
    4. Configure ESS by downloading the Let's Encrypt fragment to your config directory:

      curl -L https://raw.githubusercontent.com/element-hq/ess-helm/main/charts/matrix-stack/ci/fragments/quick-setup-letsencrypt.yaml -o ~/ess-config-values/tls.yaml
    helm repo add jetstack https://charts.jetstack.io --force-update
    
    helm install \
      cert-manager jetstack/cert-manager \
      --namespace cert-manager \
      --create-namespace \
      --version v1.17.0 \
      --set crds.enabled=true
    
    kubectl apply -f - <<EOF
    apiVersion: cert-manager.io/v1
    kind: ClusterIssuer
    metadata:
      name: letsencrypt-prod
    spec:
      acme:
        server: https://acme-v02.api.letsencrypt.org/directory
        privateKeySecretRef:
          name: letsencrypt-prod-private-key
        solvers:
          - http01:
              ingress:
                class: traefik
    EOF
    
    curl -L https://raw.githubusercontent.com/element-hq/ess-helm/main/charts/matrix-stack/ci/fragments/quick-setup-letsencrypt.yaml -o ~/ess-config-values/tls.yaml