mosquitto
by alekc
Eclipse Mosquitto is an open source message broker implementing MQTT versions 5, 3.1.1 and 3.1, for lightweight publish/subscribe messaging between IoT devices, sensors, and services.
About this chart
mosquitto
Eclipse Mosquitto is an open source message broker implementing MQTT versions 5, 3.1.1 and 3.1, for lightweight publish/subscribe messaging between IoT devices, sensors, and services.
Eclipse Mosquitto is a lightweight MQTT broker, commonly used as the message backbone for IoT devices and home automation (Home Assistant, Zigbee2MQTT, ESPHome). This chart runs it as a single Deployment with mqtt/mqtt-over-TLS/websockets listeners and optional persistence for retained messages and subscriptions.
Quick start
From the classic chart repository:
helm repo add alekc https://charts.alekc.dev
helm repo update
helm install my-mosquitto alekc/mosquitto
Or directly from the OCI registry, no helm repo add needed:
helm install my-mosquitto oci://charts.alekc.dev/mosquitto --version 0.3.0
Verifying the signature
curl -sO https://charts.alekc.dev/pubring.gpg
helm pull oci://charts.alekc.dev/mosquitto --version 0.3.0 --verify --keyring pubring.gpg
A minimal values file that locks the broker down with authentication (see Gotchas before relying on the anonymous-access default):
mosquitto:
allowAnonymous: false
# Generate with: mosquitto_passwd -c passwordfile someuser
users: |
someuser:$7$101$...
Maintainers
| Name | Url | |
|---|---|---|
| alekc | [email protected] |
Source Code
Gotchas
mosquitto.allowAnonymousdefaults totrue. Mosquitto 2.x defaults every configured listener toallow_anonymous false; without an explicit override, a fresh install of this chart would reject every client connection. The default here trades security for a working out-of-box quick start, appropriate for a trusted home-lab network. Set it tofalseand configuremosquitto.users(viamosquitto_passwd) before exposing the broker beyond a trusted network.mosquitto.users/mosquitto.aclsare plain text invalues.yaml. There's no secretKeyRef-style indirection in mosquitto's own config format. UseadditionalManifeststo provision aSecretand mount it alongside the ConfigMap if you'd rather not commit credentials to a values file.- The
mqttws(websockets) listener is always configured, matching the port that's always present inservice.ports. There's no toggle to disable it independently; remove themqttwskey fromservice.ports(and adjust the ConfigMap viamosquitto.configif you need to) if you want a websockets-free broker. networkPolicy.enabledonly opens DNS egress. Mosquitto itself makes no outbound connections by default. If you configure an MQTT bridge (mosquitto.configwith aconnection/addressblock), add the bridge target vianetworkPolicy.extraEgress.- Only one replica is supported. Persistence (retained messages, subscriptions) is a local file on one PVC; running more than one replica would give each pod its own, diverging state.
Upgrade notes
0.3.0
- Fixed a broker that rejected every connection by default (see Gotchas). If you were already
working around this by setting
mosquitto.config: "allow_anonymous true"directly, you can drop that override, it's now the default; explicitly setmosquitto.allowAnonymous: falseif you'd already locked the broker down some other way. - The
mqttwsService/container port now has a matching listener; if you were relying on it being silently unbound (unlikely), it now actually accepts websocket connections.
Values
| Key | Type | Default | Description |
|---|---|---|---|
| additionalManifests | object | {} | Additional raw Kubernetes manifests to render alongside the chart's own resources. Supports any valid Kubernetes object; values are templated with tpl, so a manifest can reference .Release.Namespace and friends. |
| affinity | object | {} | Affinity rules for pod scheduling. |
| annotations.deployment | object | {"reloader.stakater.com/auto":"true"} | Deployment's annotations. Ships with reloader.stakater.com/auto so an ExternalSecret/ConfigMap change (mosquitto.users, mosquitto.ssl secret) rolls the pod automatically; drop the key if you don't run Reloader. |
| commonAnnotations | object | {} | Annotations merged onto every resource this chart renders, in addition to each resource's own dedicated annotations field. |
| commonLabels | object | {} | Labels merged onto every resource this chart renders. Never reaches selector/matchLabels, safe to change without forcing a Deployment recreate. |
| extraContainers | list | [] | Extra sidecar containers appended to the pod spec, templated with tpl so they can reference .Release.Namespace and friends. |
| fullnameOverride | string | "" | Overrides the full resource name, instead of the default <release>-<chart> pattern. |
| image.pullPolicy | string | "IfNotPresent" | Image pull policy. |
| image.repository | string | "eclipse-mosquitto" | Image repository. |
| image.tag | string | "" | Overrides the image tag whose default is the chart appVersion. |
| imagePullSecrets | list | [] | Image pull secrets, for a private registry mirror. |
| initContainers | list | [] | Extra init containers appended to the pod spec, templated with tpl. |
| liveness.enabled | bool | true | If true, renders a TCP liveness probe against the mqtt port. |
| mosquitto.acls | string | "" | Contents of the ACL file, mosquitto's own acl_file syntax. |
| mosquitto.allowAnonymous | bool | true | Allows unauthenticated clients to connect. Mosquitto 2.x defaults every configured listener to allow_anonymous false; without this the broker rejects every connection unless users (below) is also set. Defaults to true so a fresh install works immediately. Set to false once you've configured users/acls, see Gotchas. |
| mosquitto.config | string | "" | Additional raw mosquitto.conf lines, appended after the chart-generated block. |
| mosquitto.persistence.accessModes | list | ["ReadWriteOnce"] | Access modes for the created PVC. |
| mosquitto.persistence.enabled | bool | false | Renders a PersistentVolumeClaim and enables mosquitto's own persistence true (retained messages, subscriptions survive a restart). When false, an emptyDir is used and persistence is disabled in mosquitto.conf too, matching the volume's actual lifetime. |
| mosquitto.persistence.matchExpressions | object | {} | Persistent Volume expression selector. |
| mosquitto.persistence.matchLabels | object | {} | Persistent Volume label selector. |
| mosquitto.persistence.path | string | "/mosquitto/data/" | The path the volume is mounted at. |
| mosquitto.persistence.size | string | "100Mi" | Requested size for the created PVC. |
| mosquitto.persistence.subPath | string | "" | Subdirectory of the volume to mount, useful for sharing one PV across multiple releases. |
| mosquitto.ssl.certificate.dnsNames | list | [] | DNS names for the certificate. |
| mosquitto.ssl.certificate.enabled | bool | false | Renders a cert-manager Certificate for secretName. Leave false to bring your own secret instead. |
| mosquitto.ssl.certificate.issuerRef.group | string | "cert-manager.io" | |
| mosquitto.ssl.certificate.issuerRef.kind | string | "ClusterIssuer" | |
| mosquitto.ssl.certificate.issuerRef.name | string | "letsencrypt" | |
| mosquitto.ssl.enabled | bool | false | Renders an additional TLS listener on service.ports.mqttssl using a certificate from secretName. |
| mosquitto.ssl.portName | string | "mqttssl" | The service.ports key the SSL listener binds to. |
| mosquitto.ssl.secretName | string | "mosquitto-ssl" | Secret holding tls.crt/tls.key, either provided externally or generated by the certificate block below. |
| mosquitto.users | string | "" | Contents of the password file (mosquitto_passwd format: one user:hashed-password line per user). Generate with mosquitto_passwd -c passwordfile username. CHANGE ME if you flip allowAnonymous to false. |
| nameOverride | string | "" | Overrides the chart name used to build resource names. |
| networkPolicy.annotations | object | {} | Annotations to add to the NetworkPolicy |
| networkPolicy.enabled | bool | false | Render a NetworkPolicy restricting ingress to the Service ports and egress to DNS only. mosquitto itself makes no outbound connections (MQTT bridging aside), so egress can be narrowed safely; see Gotchas if you configure a bridge. |
| networkPolicy.extraEgress | list | [] | Additional raw egress rules, appended as-is under spec.egress. |
| networkPolicy.extraIngress | list | [] | Additional raw ingress rules, appended as-is under spec.ingress. |
| nodeSelector | object | {} | Node selector for pod scheduling. |
| podAnnotations | object | {} | Annotations added to the pod template. |
| podSecurityContext | object | {} | Pod-level securityContext. |
| replicaCount | int | 1 | Pod replica count. Running more than one requires a shared persistence backend the stock config doesn't provide (each replica would keep its own retained-message/subscription state), so this is left at 1. |
| resources | object | {} | Container resource requests/limits. |
| securityContext | object | {} | Container-level securityContext. |
| service.annotations | object | {} | Annotations to add to the Service |
| service.externalIp.enabled | bool | false | Renders a second Service bound to specific external IPs (e.g. LAN), useful when devices need to reach the broker outside the cluster CNI. |
| service.externalIp.ips | list | [] | External IPs for the extra Service. |
| service.ports | object | {"mqtt":1883,"mqttssl":8883,"mqttws":9001} | Service ports. mqttws is always configured with a matching protocol websockets listener in mosquitto.conf, see ConfigMap. |
| service.type | string | "ClusterIP" | Kubernetes Service type. |
| serviceAccount.annotations | object | {} | Annotations to add to the service account |
| serviceAccount.create | bool | true | Specifies whether a service account should be created |
| serviceAccount.name | string | "" | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
| tolerations | list | [] | Tolerations for pod scheduling. |
Deploy mosquitto with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mosquitto 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 chartmosquitto is pinned at v0.3.1 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