Skip to content
Stand with Ukraine flag

Helm · Azure AKS

This guide covers deploying a TBMQ cluster on Azure Kubernetes Service (AKS) with the official Helm chart.

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 in the cluster with CrunchyData PGO, Strimzi, and Valkey; you can use Azure Database for PostgreSQL and Azure Managed Redis instead. Web traffic goes through an Azure Application Gateway, which the AKS ingress add-on configures, and MQTT traffic through an Azure Load Balancer.

AKS cluster · TBMQ Helm chart

  • TBMQ × 2
  • Integration Executor × 2

Dependencies

  • PostgreSQL (PGO or Azure Database for PostgreSQL)
  • Kafka (Strimzi)
  • Valkey (or Azure Managed Redis)

Load balancer ports

  • 80 HTTP · Application Gateway TBMQ UI and REST API
  • 443 HTTPS · Application Gateway TBMQ UI and REST API, once you enable HTTPS access
  • 1883 MQTT · Azure LB MQTT clients
  • 8084 MQTT over WebSockets · Azure LB MQTT clients that connect over WebSockets
  • 8883 MQTTS · Azure LB MQTT clients that connect over TLS, once you configure mutual TLS
  • 8085 MQTT over secure WebSockets · Azure LB MQTT clients that connect over secure WebSockets, once you configure mutual TLS

Install the following tools:

Your Azure account needs permission to create resource groups, virtual networks, and AKS clusters, and to assign roles on the virtual network, for example the Owner role on the subscription. To use the managed services, it also needs permission to create them.

Sign in and select the subscription to deploy into:

Terminal window
az login

Register the resource providers for AKS and its network. A provider registers once per subscription; the command returns at once for those that already are:

Terminal window
for ns in Microsoft.ContainerService Microsoft.Network; do
az provider register --namespace $ns --wait
done

The commands in this guide read these variables. Set them in the shell you run the guide from; if you open a new shell, set them again:

Terminal window
export AKS_RESOURCE_GROUP=TBMQResources
export AKS_LOCATION=eastus
export AKS_GATEWAY=tbmq-gateway
export TB_CLUSTER_NAME=tbmq-cluster
export TB_DATABASE_NAME=tbmq-db
export TB_REDIS_NAME=tbmq-cache
echo "Resource group: $AKS_RESOURCE_GROUP, region: $AKS_LOCATION"

Where:

  • AKS_RESOURCE_GROUP: the resource group that holds every resource of this guide.
  • AKS_LOCATION: the Azure region. List the regions with az account list-locations -o table.
  • AKS_GATEWAY: the name of the Application Gateway that the ingress add-on creates.
  • TB_CLUSTER_NAME: the name of the AKS cluster.
  • TB_DATABASE_NAME and TB_REDIS_NAME: the names of the PostgreSQL server and the Redis cache. You need them only if you use Azure managed services.

Create the resource group and a virtual network. The aks subnet holds the AKS nodes and pods; the postgres and endpoints subnets are for the managed services, if you use them:

Terminal window
az group create --name $AKS_RESOURCE_GROUP --location $AKS_LOCATION
az network vnet create --resource-group $AKS_RESOURCE_GROUP --name tbmq-vnet \
--address-prefixes 10.10.0.0/16 \
--subnet-name aks --subnet-prefixes 10.10.0.0/20
az network vnet subnet create --resource-group $AKS_RESOURCE_GROUP --vnet-name tbmq-vnet \
--name postgres --address-prefixes 10.10.17.0/24 \
--delegations Microsoft.DBforPostgreSQL/flexibleServers
az network vnet subnet create --resource-group $AKS_RESOURCE_GROUP --vnet-name tbmq-vnet \
--name endpoints --address-prefixes 10.10.18.0/24

Create a cluster with three Standard_D4s_v6 nodes, one in each availability zone of the region, and the Application Gateway ingress add-on, which creates the gateway in a new 10.10.16.0/24 subnet. TBMQ and the dependencies this guide deploys share these nodes:

Terminal window
export AKS_SUBNET_ID=$(az network vnet subnet show --resource-group $AKS_RESOURCE_GROUP \
--vnet-name tbmq-vnet --name aks --query id -o tsv)
az aks create --resource-group $AKS_RESOURCE_GROUP \
--name $TB_CLUSTER_NAME \
--vnet-subnet-id $AKS_SUBNET_ID \
--network-plugin azure \
--enable-addons ingress-appgw \
--appgw-name $AKS_GATEWAY \
--appgw-subnet-cidr 10.10.16.0/24 \
--node-vm-size Standard_D4s_v6 \
--node-count 3 \
--zones 1 2 3

This takes about 10 minutes. To size the nodes for production, change --node-vm-size and --node-count; see VM sizes. If the command fails with a quota error, the subscription’s vCPU quota for the VM family or the region is too low: request an increase or choose another region. If the region has no availability zones, drop --zones.

Add the cluster to your kubeconfig and switch the current context to it:

Terminal window
az aks get-credentials --resource-group $AKS_RESOURCE_GROUP --name $TB_CLUSTER_NAME
kubectl get nodes
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 in the cluster; size it for your load before production. To use Azure Database for PostgreSQL and Azure Managed Redis instead, deploy only Kafka here, then continue with Use Azure managed services.

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: 10Gi
users:
- name: postgres
databases:
- thingsboard_mqtt_broker
backups:
pgbackrest:
repos:
- name: repo1
volume:
volumeClaimSpec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi
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: 10Gi
deleteClaim: false
resources:
requests:
memory: "2Gi"
cpu: "500m"
limits:
memory: "2Gi"
cpu: "1"
---
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=600s

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.

To use Azure Database for PostgreSQL and Azure Managed Redis instead of the in-cluster PostgreSQL and Valkey, create them in the cluster’s virtual network, as described in Create the Azure managed services of the Azure cluster setup guide. Register their resource providers first:

Terminal window
for ns in Microsoft.DBforPostgreSQL Microsoft.Cache; do
az provider register --namespace $ns --wait
done

The commands there read the environment variables you defined above. Once the services are ready, get the PostgreSQL host name, and the Redis host name and access key:

Terminal window
az postgres flexible-server show --resource-group $AKS_RESOURCE_GROUP --name $TB_DATABASE_NAME \
--query fullyQualifiedDomainName -o tsv
az redisenterprise show --resource-group $AKS_RESOURCE_GROUP --name $TB_REDIS_NAME \
--query hostName -o tsv
az redisenterprise database list-keys --resource-group $AKS_RESOURCE_GROUP \
--cluster-name $TB_REDIS_NAME --query primaryKey -o tsv

Create Secrets for the PostgreSQL password and the Redis access key in the tbmq namespace:

Terminal window
kubectl create secret generic tbmq-db-secret -n tbmq --from-literal=password='YOUR_DB_PASSWORD'
kubectl create secret generic tbmq-redis-secret -n tbmq --from-literal=password='YOUR_REDIS_ACCESS_KEY'

Then set the host names in Connect to dependencies instead of the in-cluster values:

postgresql:
host: "tbmq-db.postgres.database.azure.com"
port: 5432
database: "thingsboard_mqtt_broker"
username: "tbmqadmin"
existingSecret: "tbmq-db-secret"
existingSecretPasswordKey: "password"
kafka:
bootstrapServers: "tbmq-kafka-kafka-bootstrap:9092"
redis:
connectionType: "standalone"
host: "tbmq-cache.eastus.redis.azure.net"
port: 10000
usePassword: true
existingSecret: "tbmq-redis-secret"
existingSecretPasswordKey: "password"

Azure Managed Redis accepts only TLS connections. In the same step, also enable TLS in customEnv of the tbmq section. TBMQ verifies the cache’s certificate against the CA certificates of its container image, which include the roots that Azure certificates chain to:

tbmq:
customEnv:
REDIS_SSL_ENABLED: "true"
REDIS_SSL_CERT_FILE: "/etc/ssl/certs/ca-certificates.crt"

For all postgresql, kafka, and redis keys, see the connection settings in the chart documentation.

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.

If you use Azure managed services, set the postgresql and redis values from Use Azure managed services instead, and add the Redis TLS settings from the same section to customEnv of the tbmq section. Without them, the broker nodes can’t connect to Redis.

Set the load balancer type to azure:

loadbalancer:
type: "azure"

The chart then creates two internet-facing load balancers:

Load balancer Kubernetes resource Ports
Application Gateway Ingress my-tbmq-cluster-http-lb 80 (HTTP); 443 (HTTPS) with HTTPS enabled
Azure Load Balancer Service my-tbmq-cluster-mqtt-lb 1883 (MQTT), 8084 (MQTT over WebSockets), 8883 (MQTTS), 8085 (MQTT over secure WebSockets)

The azure type needs chart version 2.3.2 or later; with earlier versions, helm install fails with spec.ingressClassName: Invalid value: "azure/application-gateway".

The Azure Load Balancer passes TCP through to TBMQ unchanged, so it can’t terminate TLS. MQTTS and secure WebSockets work once TBMQ terminates TLS itself, with mutual TLS.

The Application Gateway terminates HTTPS with a certificate that you upload to it. Prepare the certificate of your domain and its private key as a password-protected PFX file, then add it to the gateway. The ingress add-on creates the gateway in the cluster’s node resource group:

Terminal window
az network application-gateway ssl-cert create \
--resource-group $(az aks show --resource-group $AKS_RESOURCE_GROUP --name $TB_CLUSTER_NAME \
--query nodeResourceGroup -o tsv) \
--gateway-name $AKS_GATEWAY \
--name TBMQHTTPSCert \
--cert-file YOUR_CERT.pfx \
--cert-password YOUR_CERT_PASSWORD

Enable HTTPS in values.yaml, with the certificate’s name in the gateway:

loadbalancer:
type: "azure"
http:
enabled: true
ssl:
enabled: true
certificateRef: "TBMQHTTPSCert"

The gateway serves HTTPS on 443 and redirects HTTP on 80 to HTTPS. After installing, point your domain at the gateway’s address, shown in Validate HTTP access, with a DNS A record.

With mutual TLS, the Azure Load Balancer forwards ports 8883 and 8085 unchanged, and TBMQ terminates TLS itself. This also supports X.509 certificate authentication.

Create a Secret with the server certificate chain and its private key, in PEM format:

Terminal window
kubectl create secret generic tbmq-mqtts -n tbmq \
--from-file=server.pem=server-chain.pem \
--from-file=mqttserver_key.pem=server.key

Enable mutual TLS in values.yaml:

loadbalancer:
type: "azure"
mqtt:
enabled: true
mutualTls:
enabled: true
existingSecretName: "tbmq-mqtts"

This enables MQTTS on 8883. To also serve MQTT over secure WebSockets on 8085 with the same certificate, add to customEnv of the tbmq section:

tbmq:
customEnv:
LISTENER_WSS_ENABLED: "true"
LISTENER_WSS_PEM_CERT: "/ssl-config/server.pem"
LISTENER_WSS_PEM_KEY: "/ssl-config/mqttserver_key.pem"

For a password-protected key and the other options, see mutual TLS in the chart documentation.

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:

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 Application Gateway:

Terminal window
kubectl get ingress my-tbmq-cluster-http-lb -n tbmq
NAME CLASS HOSTS ADDRESS PORTS AGE
my-tbmq-cluster-http-lb azure-application-gateway * 20.56.253.254 80 2m

Open http://{ADDRESS} in your browser, or your domain over HTTPS if you enabled it, and sign in as System Administrator:

Username
sysadmin@thingsboard.org
Password
sysadmin

Change the password after the first sign-in.

Get the address of the Azure Load Balancer:

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.0.224.65 50.85.145.252 1883:31320/TCP,8084:30819/TCP,8883:31462/TCP,8085:31172/TCP 2m

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 aks' -q 1

The subscriber prints tbmq/demo/hello hello from aks. 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

If applying the Kafka manifest fails with no matches for kind "KafkaNodePool" in version "kafka.strimzi.io/v1", the cluster has the resource definitions of an older Strimzi release, which helm install doesn’t upgrade. Replace them with the definitions of Strimzi 0.50.0, then apply the manifest again:

Terminal window
kubectl apply --server-side --force-conflicts \
-f https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.50.0/strimzi-crds-0.50.0.yaml

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.

With Azure managed services, connection errors to PostgreSQL or Redis in the broker logs mean a wrong host name, or a private DNS zone that isn’t linked to tbmq-vnet. Redis authentication errors mean the tbmq-redis-secret Secret holds a wrong access key.

If the Ingress ADDRESS or the Service EXTERNAL-IP stays empty, its events give the reason. The ingress add-on logs how it configures the Application Gateway:

Terminal window
kubectl describe ingress my-tbmq-cluster-http-lb -n tbmq
kubectl describe svc my-tbmq-cluster-mqtt-lb -n tbmq
kubectl logs deployment/ingress-appgw-deployment -n kube-system

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, and AKS deletes the Azure Load Balancer rules and the Application Gateway configuration for them. 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, and so do the Secrets you created.

To remove the in-cluster dependencies 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. Deleting the namespace also deletes the remaining volumes and their disks.

If you use Azure managed services, only Kafka runs in the cluster. Delete it, then its operator and the namespace:

Terminal window
kubectl delete kafka tbmq-kafka -n tbmq
kubectl delete kafkanodepool combined -n tbmq
helm uninstall strimzi -n tbmq
kubectl delete namespace tbmq

The managed services aren’t affected; Delete the AKS cluster covers them.

Delete the resource group. This deletes everything in it: the AKS cluster with its node resource group and Application Gateway, the virtual network, and the managed services and their private endpoint and DNS zones, if you created them. It takes about 15 minutes:

Terminal window
az group delete --name $AKS_RESOURCE_GROUP

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.