emqx

by SVTECH-NMAA

Helm chartv0.2.0App 6.0Verified publisher

A Helm chart to deploy EMQX through EMQX Operator

About this chart

EMQX Helm Chart

This chart renders an apps.emqx.io/v2 EMQX custom resource for EMQX Operator. It is intended for stacks that want to reuse EMQX instead of keeping the EMQX object inside an application chart such as Speedtest.

Prerequisites

Install the EMQX Operator before installing this chart. The official getting-started guide requires:

  • a running Kubernetes cluster
  • kubectl access to that cluster
  • Helm 3 or higher
  • cert-manager 1.1.6 or higher
  • EMQX Operator installed from the EMQX Helm repository

Reference: https://docs.emqx.com/en/emqx-operator/latest/getting-started/getting-started.html

Example operator install:

helm repo add jetstack https://charts.jetstack.io
helm repo add emqx https://repos.emqx.io/charts
helm repo update

helm upgrade --install cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --set crds.enabled=true

helm upgrade --install emqx-operator emqx/emqx-operator \
  --namespace emqx-operator-system \
  --create-namespace

kubectl wait --for=condition=Ready pods \
  -l "control-plane=controller-manager" \
  -n emqx-operator-system

Common Values

ValueDescriptionDefault
image.registryImage registryghcr.io
image.repositoryEMQX image repositorysvtechnmaa/emqx
image.tagEMQX image tag6
imagePullSecretsPull secrets passed to EMQX pods[{name: ghcr-pull-secret}]
config.modeEMQX Operator config modeMerge
config.dataRaw EMQX HOCON config. When empty, the chart renders websocket paths from global.emqx.mqtt.*""
global.emqx.mqtt.websocket.mqttPathWebSocket MQTT path/speedtest/ws-ep
global.emqx.mqtt.secureWebsocket.mqttPathSecure WebSocket MQTT path/speedtest/wss-ep
coreTemplate.replicaCountCore node replica count1
coreTemplate.persistence.enabledEnable core node PVC templatetrue
coreTemplate.persistence.storageClassPVC storage classlocal-path
coreTemplate.persistence.sizePVC size1Gi

Pod disruption budget

Set only one of coreTemplate.minAvailable or coreTemplate.maxUnavailable; leave the other as "". Kubernetes does not allow both in the same PDB. Use a non-negative integer (including 0) or a percentage such as "50%". Leaving both empty omits these fields from the EMQX resource.

coreTemplate:
  replicaCount: 3
  minAvailable: ""
  maxUnavailable: 1

This permits at most one unavailable Pod during voluntary eviction. Alternatively, use minAvailable: 2 and maxUnavailable: "" to require two healthy Pods. With one replica, minAvailable: 1 or maxUnavailable: 0 blocks eviction of the healthy Pod and can prevent node drain. PDBs do not prevent node failures.

Custom EMQX Config

When config.data is empty, the chart generates both WS and WSS listener paths from global.emqx.mqtt.*.mqttPath. Setting config.data replaces that generated listener block, even when config.mode is Merge; the chart does not append or overwrite listener paths in your custom HOCON.

The Ingress still uses global.emqx.mqtt.websocket.mqttPath and global.emqx.mqtt.secureWebsocket.mqttPath. Include matching paths for both listeners in custom config to avoid failed WebSocket connections. Since config.data supports Helm templates, reference those values directly:

config:
  mode: Merge
  data: |
    listeners.ws.default {
      websocket.mqtt_path = {{ .Values.global.emqx.mqtt.websocket.mqttPath | quote }}
    }
    listeners.wss.default {
      websocket.mqtt_path = {{ .Values.global.emqx.mqtt.secureWebsocket.mqttPath | quote }}
    }

Ingress

WS and WSS use separate Ingresses: WS forwards HTTP to port 8083, while WSS uses nginx.ingress.kubernetes.io/backend-protocol: HTTPS to port 8084. Both preserve the listener paths configured above. ingressClassName is the Helm release name; provide a matching IngressClass when installing standalone. global.enableHttps controls HTTPS redirects, not certificate provisioning: these Ingresses have no tls block. Configure the ingress controller's TLS certificate or the upstream TLS terminator in the deployment environment.

Prefix-only WS/WSS paths do not enable regex. The optional dashboard Ingress still uses a regex/rewrite; ingress-nginx can apply regex matching to other paths on that same host. See ingress-nginx annotations.

Install

helm upgrade --install emqx . --namespace speedtest --create-namespace

Check Status

kubectl get emqx -n speedtest
kubectl get pods,svc -n speedtest

The EMQX Operator should report the EMQX resource as Running after the cluster is ready.

MQTT credential ownership

By default, mqtt.enabled: true enables built-in password authentication and provisions mqtt.auth.username (default admin) during authenticator creation. This is an MQTT client user, not a dashboard administrator or an API key.

mqtt:
  auth:
    username: admin
    password: ""  # Generate once and reuse on cluster-backed upgrades.
    existingSecret: ""
    existingSecretPasswordKey: MQTT_BROKER_PASSWORD
  enabled: true

The default Secret for a release named emqx is emqx-mqtt. Speedtest consumes that same name/key via its own mqtt.auth.existingSecret and mqtt.auth.existingSecretPasswordKey. Do not generate another password in Speedtest. An existing Secret (string or {name, keyMapping}) takes precedence over password. Partial mappings fall back to existingSecretPasswordKey.

For externally managed credentials, both charts reference the same pre-created Secret:

# Umbrella values; create speedtest-mqtt-auth externally before installation.
emqx:
  mqtt:
    auth:
      username: admin
      existingSecret: speedtest-mqtt-auth
      existingSecretPasswordKey: mqtt-password
speedtest:
  mqtt:
    auth:
      username: admin
      existingSecret: speedtest-mqtt-auth
      existingSecretPasswordKey: mqtt-password

Only the Secret name/key enter the custom resource. A bootstrap initContainer reads the password via secretKeyRef and writes a JSON file (escaping quotes, backslashes and control characters) on a memory-backed emptyDir. Core and replicant Pods mount that file. Passwords are not embedded in HOCON or ConfigMaps. The bootstrap image is configurable.

Bootstrap runs when the authenticator is created; it does not rotate an existing user's password. For an already configured broker, migrate users deliberately via the EMQX API before switching consumers. On password rotation, update the broker user, Secret, and consumer Pods together. Offline rendering cannot preserve a random password; use the external Secret workflow for GitOps.

The chart builds an authentication chain from the built-in backend when mqtt.enabled is true, followed by mqtt.additionalAuthentication. Use the additional list for an HTTP backend that validates application users. Set mqtt.enabled: false and leave the additional list empty if config.data owns the complete authentication chain. Enabling it on an existing anonymous broker will require credentials from every client. Existing custom volumes/initContainers must not reuse the reserved name mqtt-bootstrap.

Disabling the built-in authenticator does not disable the broker. If both mqtt.enabled: false and mqtt.additionalAuthentication: [] are set, supply authentication in config.data unless anonymous access is intentional. Without an authentication chain, clients can connect anonymously. Topic authorization is a separate policy; authorization.no_match does not replace client authentication.

References:

API bootstrap keys

bootstrapAPIKeys accepts Secret references only. Plaintext key / secret values fail rendering:

bootstrapAPIKeys:
  - secretRef:
      key:
        secretName: emqx-api-auth
        secretKey: api-key
      secret:
        secretName: emqx-api-auth
        secretKey: api-secret

These credentials authorize the management API; they do not provision MQTT users. Use an Operator/CRD version supporting BootstrapAPIKey.secretRef and core/replicant initContainers/extra volumes. Bootstrap API keys have creation-time semantics in the Operator; updating values is not an automatic rotation mechanism.

For Speedtest browser users, append an HTTP authenticator pointing to http://django-service/api/auth/emqx/, using POST, JSON content type, and body fields username: "${username}", password: "${password}", and clientid: "${clientid}". The backend validates the user's MQTT token and tenant; the built-in database continues to authenticate service accounts from the Secret.

Additional authentication and upgrades

In an umbrella chart, put this block below emqx:. Standalone values:

mqtt:
  enabled: true
  additionalAuthentication:
    - mechanism: password_based
      backend: http
      enable: true
      method: post
      url: http://django-service/api/auth/emqx/
      headers:
        content-type: application/json
      body:
        username: "${username}"
        password: "${password}"
        clientid: "${clientid}"

The built-in service account is checked first, then the HTTP backend. Browser users authenticate with their application MQTT token; do not give them the service account password. Verify that the Django endpoint is reachable from EMQX.

For a supplied initial service password, set mqtt.auth.password and leave mqtt.auth.existingSecret: "". For auto-generation leave both empty. For an existing Secret, set its name/key and use the matching broker username. global.authenUsers.mqtt.password is a standalone override; the Speedtest stack maps global.authenApps.mqtt.password into mqtt.auth.password using tpl.

helm upgrade updates the EMQX custom resource. With config.mode: Merge, some configuration changes can be applied at runtime without replacing Pods. Check kubectl describe emqx <name> -n speedtest and the active authentication chain; Pod age alone does not prove that an upgrade failed. Updating a bootstrap Secret or restarting a Pod does not guarantee rotation of a user stored in EMQX's database.

Dashboard exposure

dashboard.ingress.enabled defaults to false; MQTT WS/WSS ingress remains available. Enable the dashboard ingress explicitly only after securing dashboard credentials and access. MQTT credentials and bootstrap API keys do not set the dashboard login password. To configure the account before exposing it, use a local port-forward to the dashboard Service or your existing administrative access.

dashboard:
  ingress:
    enabled: false

Upgrading from a version that always exposed the dashboard removes its managed Ingress unless this flag is set to true. The dashboard Service remains available inside the cluster. This flag does not rotate or reset dashboard credentials.

Deploy emqx with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has emqx 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 chartemqx is pinned at v0.2.0 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