Skip to content
Stand with Ukraine flag

Helm · Minikube

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

  • TBMQ × 2
  • Integration Executor × 2

Dependencies you deploy

  • PostgreSQL (CrunchyData PGO)
  • Kafka (Strimzi)
  • Valkey

Load balancer ports

  • 80 HTTP · NGINX Ingress TBMQ UI and REST API
  • 1883 MQTT · LoadBalancer MQTT clients
  • 8084 MQTT over WebSockets · LoadBalancer MQTT clients that connect over WebSockets
  • 8883 MQTTS · LoadBalancer MQTT clients that connect over TLS, once you configure mutual TLS
  • 8085 MQTT over secure WebSockets · LoadBalancer MQTT clients that connect over secure WebSockets, once you set the WSS listener variables (LISTENER_WSS_*)

Install the following tools:

The cluster needs 4 CPUs and 8 GB of memory.

Terminal window
minikube start --cpus=4 --memory=8192

The chart exposes the web UI through an NGINX Ingress. Enable the Minikube ingress addon, then wait for its controller:

Terminal window
minikube addons enable ingress
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/component=controller \
-n ingress-nginx --timeout=180s
Terminal window
helm repo add tbmq-helm-chart https://helm.thingsboard.io/tbmq
helm repo update

Create a namespace for TBMQ and its dependencies:

Terminal window
kubectl create namespace tbmq

Every 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:

Terminal window
helm install pgo oci://registry.developers.crunchydata.com/crunchydata/pgo \
--version 6.0.1 -n tbmq
kubectl wait --for=condition=Ready pod -l postgres-operator.crunchydata.com/control-plane=pgo \
-n tbmq --timeout=180s

Create a PostgreSQL 17 cluster with the thingsboard_mqtt_broker database:

Terminal window
cat <<'EOF' | kubectl apply -n tbmq -f -
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: tbmq-db
spec:
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: 1Gi
EOF

Wait 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:

Terminal window
until kubectl get pod -n tbmq -l postgres-operator.crunchydata.com/data=postgres 2>/dev/null | grep -q tbmq-db; do sleep 3; done
kubectl wait --for=condition=Ready pod -l postgres-operator.crunchydata.com/data=postgres \
-n tbmq --timeout=300s

PGO 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:

Terminal window
helm repo add strimzi https://strimzi.io/charts/
helm repo update
helm install strimzi strimzi/strimzi-kafka-operator --version 0.50.0 -n tbmq
kubectl wait --for=condition=Ready pod -l name=strimzi-cluster-operator -n tbmq --timeout=180s

Create a three-node Kafka 4.0 cluster in KRaft mode:

Terminal window
cat <<'EOF' | kubectl apply -n tbmq -f -
apiVersion: kafka.strimzi.io/v1
kind: KafkaNodePool
metadata:
name: combined
labels:
strimzi.io/cluster: tbmq-kafka
spec:
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/v1
kind: Kafka
metadata:
name: tbmq-kafka
annotations:
strimzi.io/node-pools: enabled
strimzi.io/kraft: enabled
spec:
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: {}
EOF

Wait for the cluster; this takes a few minutes:

Terminal window
kubectl wait kafka/tbmq-kafka --for=condition=Ready -n tbmq --timeout=480s

Kafka is reachable at tbmq-kafka-kafka-bootstrap:9092.

Install a standalone Valkey without a password and wait for it:

Terminal window
helm repo add valkey https://valkey.io/valkey-helm/
helm repo update
helm install valkey valkey/valkey --version 0.9.3 -n tbmq
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=valkey -n tbmq --timeout=180s

Valkey is reachable at valkey:6379.

Export the chart’s default values to a values.yaml file:

Terminal window
helm show values tbmq-helm-chart/tbmq-cluster > values.yaml

The 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: false

redis.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:

Terminal window
helm install my-tbmq-cluster tbmq-helm-chart/tbmq-cluster -n tbmq \
-f values.yaml \
--set installation.installDbSchema=true

my-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-cluster
NAMESPACE: tbmq
STATUS: deployed
REVISION: 1
...

The broker pods start after the schema exists. Wait until they are ready:

Terminal window
kubectl rollout status statefulset/my-tbmq-cluster-tbmq-node -n tbmq --timeout=600s

Get the address of the HTTP load balancer:

Terminal window
kubectl get ingress my-tbmq-cluster-http-lb -n tbmq
NAME CLASS HOSTS ADDRESS PORTS AGE
my-tbmq-cluster-http-lb nginx * 192.168.49.2 80 2m

Open http://{ADDRESS} in your browser and sign in as System Administrator:

Username
sysadmin@thingsboard.org
Password
sysadmin

Change 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:

Terminal window
minikube tunnel

Get the external IP:

Terminal window
kubectl get svc my-tbmq-cluster-mqtt-lb -n tbmq
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-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 5m

MQTT 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:

Terminal window
mosquitto_sub -h {EXTERNAL-IP} -p 1883 -u tbmq_websockets_username -t 'tbmq/demo/#' -v -q 1

In another, publish:

Terminal window
mosquitto_pub -h {EXTERNAL-IP} -p 1883 -u tbmq_websockets_username -t 'tbmq/demo/hello' -m 'hello from minikube' -q 1

The 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:

Terminal window
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:

Terminal window
kubectl logs -f my-tbmq-cluster-tbmq-node-0 -n tbmq

If helm install fails with failed post-install, the schema install did not succeed. Read the install pod’s logs:

Terminal window
kubectl logs my-tbmq-cluster-install-pod -n tbmq

Broker 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.

  1. Update the chart repository.

    Terminal window
    helm repo update
  2. Compare versions.

    The APP VERSION column is the TBMQ version. Compare your release with the latest chart:

    Terminal window
    helm list -n tbmq
    helm search repo tbmq-helm-chart/tbmq-cluster
  3. Update values.yaml.

    Export the new defaults and compare them with your file:

    Terminal window
    helm show values tbmq-helm-chart/tbmq-cluster > values-new.yaml
    diff values.yaml values-new.yaml

    Carry 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.2
  4. Run the upgrade.

    Terminal window
    helm upgrade my-tbmq-cluster tbmq-helm-chart/tbmq-cluster -n tbmq \
    -f values.yaml \
    --set upgrade.upgradeDbSchema=true

    A 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:

    Terminal window
    kubectl rollout status statefulset/my-tbmq-cluster-tbmq-node -n tbmq --timeout=600s

If 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.

Terminal window
helm uninstall my-tbmq-cluster -n tbmq

This removes the TBMQ resources of the release. It keeps the broker’s data volumes; delete them with:

Terminal window
kubectl delete pvc -n tbmq -l app=my-tbmq-cluster-tbmq-node

PostgreSQL, 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:

Terminal window
kubectl delete postgrescluster tbmq-db -n tbmq
kubectl delete kafka tbmq-kafka -n tbmq
kubectl delete kafkanodepool combined -n tbmq
helm uninstall valkey strimzi pgo -n tbmq
kubectl delete namespace tbmq

Deleting the namespace first leaves it stuck in Terminating: the operators are removed before they can clean up their clusters.

Terminal window
minikube delete

Connect your first client

Set up client credentials, then publish and subscribe with an MQTT client. See Getting started.

Secure the broker

Choose the authentication provider that fits your clients. See Security overview.

Tune the configuration

Change broker settings through environment variables in tbmq.customEnv of your values.yaml. See How to change configuration.

Watch the broker

Track sessions, throughput, and resource usage as traffic grows. See Monitoring.