mosquitto

by alekc

Helm chartv0.3.1App 2.0.23EPL-2.0Verified publisher

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

NameEmailUrl
alekc[email protected]

Source Code

Gotchas

  • mosquitto.allowAnonymous defaults to true. Mosquitto 2.x defaults every configured listener to allow_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 to false and configure mosquitto.users (via mosquitto_passwd) before exposing the broker beyond a trusted network.
  • mosquitto.users/mosquitto.acls are plain text in values.yaml. There's no secretKeyRef-style indirection in mosquitto's own config format. Use additionalManifests to provision a Secret and 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 in service.ports. There's no toggle to disable it independently; remove the mqttws key from service.ports (and adjust the ConfigMap via mosquitto.config if you need to) if you want a websockets-free broker.
  • networkPolicy.enabled only opens DNS egress. Mosquitto itself makes no outbound connections by default. If you configure an MQTT bridge (mosquitto.config with a connection/address block), add the bridge target via networkPolicy.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 set mosquitto.allowAnonymous: false if you'd already locked the broker down some other way.
  • The mqttws Service/container port now has a matching listener; if you were relying on it being silently unbound (unlikely), it now actually accepts websocket connections.

Values

KeyTypeDefaultDescription
additionalManifestsobject{}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.
affinityobject{}Affinity rules for pod scheduling.
annotations.deploymentobject{"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.
commonAnnotationsobject{}Annotations merged onto every resource this chart renders, in addition to each resource's own dedicated annotations field.
commonLabelsobject{}Labels merged onto every resource this chart renders. Never reaches selector/matchLabels, safe to change without forcing a Deployment recreate.
extraContainerslist[]Extra sidecar containers appended to the pod spec, templated with tpl so they can reference .Release.Namespace and friends.
fullnameOverridestring""Overrides the full resource name, instead of the default <release>-<chart> pattern.
image.pullPolicystring"IfNotPresent"Image pull policy.
image.repositorystring"eclipse-mosquitto"Image repository.
image.tagstring""Overrides the image tag whose default is the chart appVersion.
imagePullSecretslist[]Image pull secrets, for a private registry mirror.
initContainerslist[]Extra init containers appended to the pod spec, templated with tpl.
liveness.enabledbooltrueIf true, renders a TCP liveness probe against the mqtt port.
mosquitto.aclsstring""Contents of the ACL file, mosquitto's own acl_file syntax.
mosquitto.allowAnonymousbooltrueAllows 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.configstring""Additional raw mosquitto.conf lines, appended after the chart-generated block.
mosquitto.persistence.accessModeslist["ReadWriteOnce"]Access modes for the created PVC.
mosquitto.persistence.enabledboolfalseRenders 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.matchExpressionsobject{}Persistent Volume expression selector.
mosquitto.persistence.matchLabelsobject{}Persistent Volume label selector.
mosquitto.persistence.pathstring"/mosquitto/data/"The path the volume is mounted at.
mosquitto.persistence.sizestring"100Mi"Requested size for the created PVC.
mosquitto.persistence.subPathstring""Subdirectory of the volume to mount, useful for sharing one PV across multiple releases.
mosquitto.ssl.certificate.dnsNameslist[]DNS names for the certificate.
mosquitto.ssl.certificate.enabledboolfalseRenders a cert-manager Certificate for secretName. Leave false to bring your own secret instead.
mosquitto.ssl.certificate.issuerRef.groupstring"cert-manager.io"
mosquitto.ssl.certificate.issuerRef.kindstring"ClusterIssuer"
mosquitto.ssl.certificate.issuerRef.namestring"letsencrypt"
mosquitto.ssl.enabledboolfalseRenders an additional TLS listener on service.ports.mqttssl using a certificate from secretName.
mosquitto.ssl.portNamestring"mqttssl"The service.ports key the SSL listener binds to.
mosquitto.ssl.secretNamestring"mosquitto-ssl"Secret holding tls.crt/tls.key, either provided externally or generated by the certificate block below.
mosquitto.usersstring""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.
nameOverridestring""Overrides the chart name used to build resource names.
networkPolicy.annotationsobject{}Annotations to add to the NetworkPolicy
networkPolicy.enabledboolfalseRender 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.extraEgresslist[]Additional raw egress rules, appended as-is under spec.egress.
networkPolicy.extraIngresslist[]Additional raw ingress rules, appended as-is under spec.ingress.
nodeSelectorobject{}Node selector for pod scheduling.
podAnnotationsobject{}Annotations added to the pod template.
podSecurityContextobject{}Pod-level securityContext.
replicaCountint1Pod 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.
resourcesobject{}Container resource requests/limits.
securityContextobject{}Container-level securityContext.
service.annotationsobject{}Annotations to add to the Service
service.externalIp.enabledboolfalseRenders 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.ipslist[]External IPs for the extra Service.
service.portsobject{"mqtt":1883,"mqttssl":8883,"mqttws":9001}Service ports. mqttws is always configured with a matching protocol websockets listener in mosquitto.conf, see ConfigMap.
service.typestring"ClusterIP"Kubernetes Service type.
serviceAccount.annotationsobject{}Annotations to add to the service account
serviceAccount.createbooltrueSpecifies whether a service account should be created
serviceAccount.namestring""The name of the service account to use. If not set and create is true, a name is generated using the fullname template
tolerationslist[]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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmosquitto 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