Post

Mosquitto MQTT

Mosquitto MQTT

Mosquitto MQTT

Purpose

Eclipse Mosquitto is the MQTT broker used by Home Assistant and other IoT devices in the homelab. Runs as a single Deployment in the default namespace of the k3s cluster.

Deployment

ItemValue
Namespacedefault
Imageeclipse-mosquitto:2.1.2-alpine
Replicas1
Ports1883 (MQTT), 9001 (MQTT over WebSockets)
Resourcesrequests 20m/32Mi, limits 200m/128Mi
StoragePVC mosquitto-storage, 1Gi, storageClassName: local-path (persistence + logs)
Reloaderreloader.stakater.com/auto: "true"

Configuration

mosquitto.conf is supplied via a ConfigMap (mosquitto-config) and requires username/password authentication (allow_anonymous false, password_file /mosquitto/config/passwd). Persistence and file logging are both enabled.

The password file itself lives in a Secret (mosquitto-passwd), mounted read-only into an emptyDir by an init container (fix-passwd-perms) that copies it and sets ownership/permissions the main container’s non-root user needs — the Secret can’t be mounted directly with the right ownership, hence the extra copy step.

Networking

Service mosquitto is a LoadBalancer (MetalLB-assigned IP) exposing both 1883 and 9001 directly to the LAN — there is no Traefik ingress, since MQTT isn’t HTTP traffic.

This post is licensed under CC BY 4.0 by the author.