Connect your first client
Set up client credentials, then publish and subscribe with an MQTT client. See Getting started.
This guide covers deploying a TBMQ cluster on Minikube with the official Helm chart. Minikube is the reference environment for self-managed Kubernetes clusters without a cloud load balancer, so you can use it to validate the whole setup on one machine.
The chart deploys only TBMQ: two broker nodes and two Integration Executors. PostgreSQL, Kafka, and a Redis-compatible
cache run separately. This guide deploys them with CrunchyData PGO, Strimzi, and Valkey, all in the tbmq namespace.
TBMQ Helm chart
Dependencies you deploy
Load balancer ports
LISTENER_WSS_*)
Install the following tools:
The cluster needs 4 CPUs and 8 GB of memory.
minikube start --cpus=4 --memory=8192The chart exposes the web UI through an NGINX Ingress. Enable the Minikube ingress addon, then wait for its controller:
minikube addons enable ingresskubectl wait --for=condition=Ready pod -l app.kubernetes.io/component=controller \ -n ingress-nginx --timeout=180shelm repo add tbmq-helm-chart https://helm.thingsboard.io/tbmqhelm repo updateCreate a namespace for TBMQ and its dependencies:
kubectl create namespace tbmqEvery command in this guide passes -n tbmq.
The chart doesn’t include PostgreSQL, Kafka, or a Redis-compatible cache. Any instances that TBMQ can reach work. This section deploys a small set on Minikube; for production, use operators or managed services sized for your load.
Install the CrunchyData PGO operator and wait for it:
helm install pgo oci://registry.developers.crunchydata.com/crunchydata/pgo \ --version 6.0.1 -n tbmqkubectl wait --for=condition=Ready pod -l postgres-operator.crunchydata.com/control-plane=pgo \ -n tbmq --timeout=180sCreate a PostgreSQL 17 cluster with the thingsboard_mqtt_broker database:
cat <<'EOF' | kubectl apply -n tbmq -f -apiVersion: postgres-operator.crunchydata.com/v1beta1kind: PostgresClustermetadata: name: tbmq-dbspec: postgresVersion: 17 instances: - name: instance1 replicas: 1 dataVolumeClaimSpec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 1Gi users: - name: postgres databases: - thingsboard_mqtt_broker backups: pgbackrest: repos: - name: repo1 volume: volumeClaimSpec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 1GiEOFWait for the database pod. PGO creates it a few seconds after the manifest is applied, so the first command waits for the pod to exist:
until kubectl get pod -n tbmq -l postgres-operator.crunchydata.com/data=postgres 2>/dev/null | grep -q tbmq-db; do sleep 3; donekubectl wait --for=condition=Ready pod -l postgres-operator.crunchydata.com/data=postgres \ -n tbmq --timeout=300sPGO serves the database at tbmq-db-primary:5432 and stores the generated password in the Secret
tbmq-db-pguser-postgres, key password.
Install the Strimzi operator and wait for it:
helm repo add strimzi https://strimzi.io/charts/helm repo updatehelm install strimzi strimzi/strimzi-kafka-operator --version 0.50.0 -n tbmqkubectl wait --for=condition=Ready pod -l name=strimzi-cluster-operator -n tbmq --timeout=180sCreate a three-node Kafka 4.0 cluster in KRaft mode:
cat <<'EOF' | kubectl apply -n tbmq -f -apiVersion: kafka.strimzi.io/v1kind: KafkaNodePoolmetadata: name: combined labels: strimzi.io/cluster: tbmq-kafkaspec: replicas: 3 roles: - controller - broker storage: type: jbod volumes: - id: 0 type: persistent-claim size: 1Gi deleteClaim: false resources: requests: memory: "1Gi" cpu: "250m" limits: memory: "1Gi" cpu: "500m"---apiVersion: kafka.strimzi.io/v1kind: Kafkametadata: name: tbmq-kafka annotations: strimzi.io/node-pools: enabled strimzi.io/kraft: enabledspec: kafka: version: 4.0.0 metadataVersion: "4.0" listeners: - name: plain port: 9092 type: internal tls: false config: auto.create.topics.enable: false default.replication.factor: 2 offsets.topic.replication.factor: 3 transaction.state.log.replication.factor: 3 transaction.state.log.min.isr: 2 entityOperator: topicOperator: {} userOperator: {}EOFWait for the cluster; this takes a few minutes:
kubectl wait kafka/tbmq-kafka --for=condition=Ready -n tbmq --timeout=480sKafka is reachable at tbmq-kafka-kafka-bootstrap:9092.
Install a standalone Valkey without a password and wait for it:
helm repo add valkey https://valkey.io/valkey-helm/helm repo updatehelm install valkey valkey/valkey --version 0.9.3 -n tbmqkubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=valkey -n tbmq --timeout=180sValkey is reachable at valkey:6379.
Export the chart’s default values to a values.yaml file:
helm show values tbmq-helm-chart/tbmq-cluster > values.yamlThe file pins the chart defaults, including the TBMQ image tags. Keep it: you edit and reuse it on every upgrade.
In values.yaml, find the postgresql, kafka, and redis sections and set these keys to point at the services from
the previous section:
postgresql: host: "tbmq-db-primary" port: 5432 database: "thingsboard_mqtt_broker" username: "postgres" existingSecret: "tbmq-db-pguser-postgres" existingSecretPasswordKey: "password"
kafka: bootstrapServers: "tbmq-kafka-kafka-bootstrap:9092"
redis: connectionType: "standalone" host: "valkey" port: 6379 usePassword: falseredis.connectionType defaults to cluster, so change it for a single Valkey node. For other setups, see the
connection settings
in the chart documentation.
The default nginx load balancer works on Minikube, so leave it unchanged:
loadbalancer: type: "nginx"It creates an Ingress for the web UI and a LoadBalancer Service for MQTT. The NGINX Ingress doesn’t terminate HTTPS,
and MQTTS (port 8883) is served only after you configure
mutual TLS
in the chart. Secure WebSockets (port 8085) also need the LISTENER_WSS_* variables set in tbmq.customEnv.
From the directory with your values.yaml, install the chart:
helm install my-tbmq-cluster tbmq-helm-chart/tbmq-cluster -n tbmq \ -f values.yaml \ --set installation.installDbSchema=truemy-tbmq-cluster is the Helm release name. It prefixes every resource the chart creates, and later helm commands
refer to it.
Helm runs a one-time install pod that creates the database schema and returns when the pod succeeds, usually within a minute or two:
NAME: my-tbmq-clusterNAMESPACE: tbmqSTATUS: deployedREVISION: 1...The broker pods start after the schema exists. Wait until they are ready:
kubectl rollout status statefulset/my-tbmq-cluster-tbmq-node -n tbmq --timeout=600sGet the address of the HTTP load balancer:
kubectl get ingress my-tbmq-cluster-http-lb -n tbmqNAME CLASS HOSTS ADDRESS PORTS AGEmy-tbmq-cluster-http-lb nginx * 192.168.49.2 80 2mOpen http://{ADDRESS} in your browser and sign in as System Administrator:
sysadmin@thingsboard.orgsysadminChange the password after the first sign-in.
The MQTT load balancer is the my-tbmq-cluster-mqtt-lb Service. Minikube assigns it an external IP only while
minikube tunnel runs. Start the tunnel in a separate terminal and keep it running; it may ask for your password:
minikube tunnelGet the external IP:
kubectl get svc my-tbmq-cluster-mqtt-lb -n tbmqNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEmy-tbmq-cluster-mqtt-lb LoadBalancer 10.102.244.25 10.102.244.25 1883:32568/TCP,8084:30826/TCP,8883:31746/TCP,8085:31579/TCP 5mMQTT clients connect to EXTERNAL-IP on port 1883, and MQTT over WebSockets on port 8084.
To check the broker end to end, publish and subscribe with the
Mosquitto clients. A new
installation has one MQTT credential, TBMQ WebSockets MQTT Credentials: username tbmq_websockets_username and no
password. In one terminal, subscribe:
mosquitto_sub -h {EXTERNAL-IP} -p 1883 -u tbmq_websockets_username -t 'tbmq/demo/#' -v -q 1In another, publish:
mosquitto_pub -h {EXTERNAL-IP} -p 1883 -u tbmq_websockets_username -t 'tbmq/demo/hello' -m 'hello from minikube' -q 1The subscriber prints tbmq/demo/hello hello from minikube. A client that connects without a username is refused as
not authorized, because MQTT Basic authentication is enabled by default. To create your own credentials, see
MQTT client credentials.
List the TBMQ pods:
kubectl get pods -n tbmq -l 'app in (my-tbmq-cluster-tbmq-node,my-tbmq-cluster-tbmq-ie,install-job)'View the logs of a broker node:
kubectl logs -f my-tbmq-cluster-tbmq-node-0 -n tbmqIf helm install fails with failed post-install, the schema install did not succeed. Read the install pod’s logs:
kubectl logs my-tbmq-cluster-install-pod -n tbmqBroker pods that stay in Init:0/1 are waiting for the schema. For the common causes and fixes, see
Troubleshooting the install
in the chart documentation.
Back up your PostgreSQL database before upgrading. Then review the upgrade instructions for the notes on every version between yours and the target.
Update the chart repository.
helm repo updateCompare versions.
The APP VERSION column is the TBMQ version. Compare your release with the latest chart:
helm list -n tbmqhelm search repo tbmq-helm-chart/tbmq-clusterUpdate values.yaml.
Export the new defaults and compare them with your file:
helm show values tbmq-helm-chart/tbmq-cluster > values-new.yamldiff values.yaml values-new.yamlCarry the changes you need into values.yaml. Always update the image tags, or the release keeps running the old
TBMQ version:
tbmq: image: tag: 2.4.2
tbmq-ie: image: tag: 2.4.2Run the upgrade.
helm upgrade my-tbmq-cluster tbmq-helm-chart/tbmq-cluster -n tbmq \ -f values.yaml \ --set upgrade.upgradeDbSchema=trueA pre-upgrade job migrates the database, then Kubernetes replaces the TBMQ pods one at a time, each after the previous one is ready. Wait for it to finish:
kubectl rollout status statefulset/my-tbmq-cluster-tbmq-node -n tbmq --timeout=600sIf the APP VERSION doesn’t change, there is nothing to migrate: run the same helm upgrade without
--set upgrade.upgradeDbSchema=true. With it, the migration fails with database already upgraded to current version
and the release is marked failed; running the upgrade again without the flag fixes it.
Chart 2.0.0 (TBMQ 2.3.0) removed the PostgreSQL, Kafka, and Redis subcharts that chart 1.x bundled. To upgrade a release from chart 1.x, follow Upgrading from chart version 1.x to 2.0.0 in the chart documentation.
helm uninstall my-tbmq-cluster -n tbmqThis removes the TBMQ resources of the release. It keeps the broker’s data volumes; delete them with:
kubectl delete pvc -n tbmq -l app=my-tbmq-cluster-tbmq-nodePostgreSQL, Kafka, and Valkey keep running.
To remove them too, delete the database and Kafka clusters while their operators still run, then the operators, Valkey, and the namespace:
kubectl delete postgrescluster tbmq-db -n tbmqkubectl delete kafka tbmq-kafka -n tbmqkubectl delete kafkanodepool combined -n tbmqhelm uninstall valkey strimzi pgo -n tbmqkubectl delete namespace tbmqDeleting the namespace first leaves it stuck in Terminating: the operators are removed before they can clean up their
clusters.
minikube deleteSet up client credentials, then publish and subscribe with an MQTT client. See Getting started.
Choose the authentication provider that fits your clients. See Security overview.
Change broker settings through environment variables in tbmq.customEnv of your values.yaml.
See How to change configuration.
Track sessions, throughput, and resource usage as traffic grows. See Monitoring.
Was this helpful?