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 Amazon Elastic Kubernetes Service (EKS) 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 Amazon RDS, Amazon MSK, and Amazon ElastiCache instead. Web traffic goes through an AWS Application Load Balancer (ALB) and MQTT traffic through an AWS Network Load Balancer (NLB).
EKS cluster · TBMQ Helm chart
Dependencies
Load balancer ports
Install the following tools:
Your AWS credentials need permission to create EKS clusters, VPCs, EC2 instances, IAM roles, and load balancers.
You need a TBMQ PE license key. To buy one, open the Pricing page, choose a pay-as-you-go subscription or a perpetual license, and use the calculator to size your deployment: session and throughput limits, production and development instances, and any add-ons.
You apply the key in Configure license and broker images.
Set your access key, secret key, and default region:
aws configureTo create access keys, see Manage access keys for IAM users.
Download the EKS cluster configuration:
curl -o cluster.yml https://raw.githubusercontent.com/thingsboard/tbmq/release-2.4.2/k8s/helm/aws/cluster.ymlReview these fields in cluster.yml:
region and availabilityZones: the AWS region and three of its availability zones. The defaults are us-east-1
and us-east-1a, us-east-1b, us-east-1c.version: the Kubernetes version. List the versions EKS offers in your region with
aws eks describe-cluster-versions --region {region} --query 'clusterVersions[].clusterVersion'.instanceType: the EC2 instance type of each node group. Not every type is offered in every region; see
Check instance types in your region.desiredCapacity: the number of nodes in each node group.volumeType: the EBS volume type of the node disks, gp3 by default.To size the instances for production, see Amazon EC2 instance types.
The default c7a instance types aren’t available in every region. Check that the region offers the types in your
cluster.yml:
aws ec2 describe-instance-type-offerings --region us-east-1 --location-type availability-zone \ --filters Name=instance-type,Values=c7a.large,c7a.medium \ --query 'InstanceTypeOfferings[].[InstanceType,Location]' --output textEach type must be listed for every zone in availabilityZones. If it isn’t, pick another type, such as c7i.large.
cluster.yml creates a node group for each workload. Each node carries a role label, which pins the workload to it:
| Node group | role label |
Runs |
|---|---|---|
tbmq-node |
tbmq |
TBMQ broker |
tbmq-ie |
tbmq-ie |
TBMQ Integration Executor |
tbmq-kafka |
kafka |
Kafka, deployed in this guide |
tbmq-redis |
redis |
Valkey, deployed in this guide |
tbmq-postgresql |
postgresql |
PostgreSQL, deployed in this guide |
If you use a managed AWS service instead, delete its node group from cluster.yml before you create the cluster:
tbmq-kafka for Amazon MSK, tbmq-redis for Amazon ElastiCache, tbmq-postgresql for Amazon RDS.
The iam block enables
IAM roles for service accounts
and creates the aws-load-balancer-controller service account with the IAM policy the
AWS Load Balancer Controller
needs:
iam: withOIDC: true serviceAccounts: - metadata: name: aws-load-balancer-controller namespace: kube-system wellKnownPolicies: awsLoadBalancerController: trueThe addons block installs these EKS add-ons:
aws-ebs-csi-driver: provisions EBS volumes for persistent volume claims. TBMQ and its dependencies need it.aws-efs-csi-driver: mounts Amazon EFS volumes. TBMQ doesn’t use it.vpc-cni: gives each pod an IP address in the VPC.coredns: cluster DNS.kube-proxy: routes Service traffic on each node.eksctl create cluster -f cluster.ymlThis takes about 20 minutes. When it finishes, eksctl adds the cluster to your kubeconfig and switches the current
context to it.
Download the storage class configuration and apply it:
curl -o gp3-def-sc.yml https://raw.githubusercontent.com/thingsboard/tbmq/release-2.4.2/k8s/helm/aws/gp3-def-sc.ymlkubectl apply -f gp3-def-sc.ymlkubectl get scNAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGEgp2 kubernetes.io/aws-ebs Delete WaitForFirstConsumer false 15mgp3 (default) ebs.csi.aws.com Delete WaitForFirstConsumer true 5sgp3 must be the only default. If gp2 is also marked (default), remove its flag:
kubectl patch storageclass gp2 -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'The controller creates the ALB and the NLB for TBMQ. eksctl already created its service account and IAM role, so
install it with that service account:
helm repo add eks https://aws.github.io/eks-chartshelm repo updatehelm install aws-load-balancer-controller eks/aws-load-balancer-controller \ -n kube-system \ --set clusterName=tbmq \ --set serviceAccount.create=false \ --set serviceAccount.name=aws-load-balancer-controllerkubectl rollout status deployment/aws-load-balancer-controller -n kube-system --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 the dedicated node groups; size it for your load before production. To use managed AWS services instead, skip to Use AWS managed services.
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 on the postgresql nodes:
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: 10Gi affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: role operator: In values: ["postgresql"] users: - name: postgres databases: - thingsboard_mqtt_broker backups: pgbackrest: repos: - name: repo1 volume: volumeClaimSpec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 10GiEOFWait 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 on the kafka nodes:
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: 10Gi deleteClaim: false resources: requests: memory: "2Gi" cpu: "500m" limits: memory: "2Gi" cpu: "1" template: pod: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: role operator: In values: ["kafka"]---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=600sKafka is reachable at tbmq-kafka-kafka-bootstrap:9092.
Install a standalone Valkey without a password on the redis node 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 tbmq --set nodeSelector.role=rediskubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=valkey -n tbmq --timeout=180sValkey is reachable at valkey:6379.
To use Amazon RDS, Amazon MSK, or Amazon ElastiCache instead of the in-cluster deployments, create them in the VPC that
eksctl created for the cluster, and allow traffic from the cluster nodes. The
AWS cluster setup guide
walks through creating each one. Then set their endpoints in Connect to dependencies
instead of the in-cluster values:
postgresql: host: "my-tbmq-db.xxxxxx.us-east-1.rds.amazonaws.com" port: 5432 database: "thingsboard_mqtt_broker" username: "postgres" existingSecret: "my-pg-secret" existingSecretPasswordKey: "password"
kafka: bootstrapServers: "b-1.my-msk.xxxxxx.c2.kafka.us-east-1.amazonaws.com:9092,b-2.my-msk.xxxxxx.c2.kafka.us-east-1.amazonaws.com:9092"
redis: connectionType: "cluster" nodes: "clustercfg.my-cache.xxxxxx.use1.cache.amazonaws.com:6379" usePassword: falseCreate the PostgreSQL password Secret in the tbmq namespace first:
kubectl create secret generic my-pg-secret -n tbmq --from-literal=password='YOUR_DB_PASSWORD'Amazon MSK: get the bootstrap servers with aws kafka get-bootstrap-brokers --cluster-arn {cluster-arn}. Port
9092 is the plaintext listener. For the TLS listener, use the port 9094 brokers and set
TB_KAFKA_DEFAULT_PRODUCER_CONSUMER_CONFIG: "security.protocol:SSL" in both tbmq.customEnv and tbmq-ie.customEnv.
IAM access control isn’t supported: the TBMQ images don’t include the MSK IAM authentication library.
Amazon ElastiCache: with cluster mode enabled, set connectionType: "cluster" and nodes to the configuration
endpoint with port 6379. With cluster mode disabled, set connectionType: "standalone" and host to the primary
endpoint. If the cache uses in-transit encryption, enable TLS in tbmq.customEnv. ElastiCache certificates are
issued by Amazon’s root CAs, which the CA bundle in the TBMQ image already contains:
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:
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, set nodeSelector in the tbmq and tbmq-ie sections to the node group labels:
tbmq: nodeSelector: role: tbmq
tbmq-ie: nodeSelector: role: tbmq-ieIn 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.
The chart defaults to the Community Edition images. In values.yaml, set the PE images in the tbmq.image and
tbmq-ie.image blocks:
tbmq: image: repository: thingsboard/tbmq-pe-node tag: 2.4.2PE
tbmq-ie: image: repository: thingsboard/tbmq-pe-integration-executor tag: 2.4.2PECreate a Secret with your license key in the tbmq namespace:
kubectl create secret generic tbmq-license -n tbmq \ --from-literal=license-key='YOUR_LICENSE_KEY'Reference it in the license section of values.yaml:
license: existingSecret: tbmq-licenseSet the load balancer type to aws:
loadbalancer: type: "aws"The chart then creates two internet-facing load balancers through the AWS Load Balancer Controller:
| Load balancer | Kubernetes resource | Ports |
|---|---|---|
| ALB | Ingress my-tbmq-cluster-http-lb |
80 (HTTP); 443 (HTTPS) with HTTPS enabled |
| NLB | Service my-tbmq-cluster-mqtt-lb |
1883 (MQTT), 8084 (MQTT over WebSockets), 8883 (MQTTS), 8085 (MQTT over secure WebSockets) |
MQTTS and secure WebSockets work only after you configure TLS for them: either TLS termination at the NLB or mutual TLS in TBMQ.
The ALB serves HTTPS with a certificate from
AWS Certificate Manager (ACM).
Request or import a certificate for your domain in the cluster’s region and note its ARN. Then enable HTTPS in
values.yaml:
loadbalancer: type: "aws" http: enabled: true ssl: enabled: true certificateRef: "<your-acm-certificate-arn>"The ALB then listens on 443 and redirects HTTP on 80 to HTTPS. After installing, point your domain at the ALB
address with a DNS CNAME record.
The NLB decrypts MQTTS and secure WebSockets traffic with an ACM certificate and forwards it to TBMQ’s plain ports:
8883 to 1883 and 8085 to 8084. Traffic between the NLB and TBMQ stays inside your VPC, unencrypted. Set the ACM
certificate ARN in values.yaml:
loadbalancer: type: "aws" mqtt: enabled: true tlsTermination: enabled: true certificateRef: "<your-acm-certificate-arn>"With mutual TLS, the NLB forwards ports 8883 and 8085 unchanged, and TBMQ terminates TLS itself. This supports
X.509 certificate authentication.
mutualTls takes precedence over tlsTermination.
Create a Secret with the server certificate chain and its private key, in PEM format:
kubectl create secret generic tbmq-mqtts -n tbmq \ --from-file=server.pem=server-chain.pem \ --from-file=mqttserver_key.pem=server.keyEnable mutual TLS in values.yaml:
loadbalancer: type: "aws" 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 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:
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:
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 ALB:
kubectl get ingress my-tbmq-cluster-http-lb -n tbmqNAME CLASS HOSTS ADDRESS PORTS AGEmy-tbmq-cluster-http-lb alb * k8s-tbmq-mytbmqcl-1dddafb123-2111810989.us-east-1.elb.amazonaws.com 80 3mThe ALB takes a few minutes to provision. Then open http://{ADDRESS} in your browser, or your domain over HTTPS if
you enabled it, and sign in as System Administrator:
sysadmin@thingsboard.orgsysadminChange the password after the first sign-in.
Get the address of the NLB:
kubectl get svc my-tbmq-cluster-mqtt-lb -n tbmqNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEmy-tbmq-cluster-mqtt-lb LoadBalancer 10.100.193.186 k8s-tbmq-mytbmqcl-58441a19fc-c53931afca4eb86a.elb.us-east-1.amazonaws.com 1883:30292/TCP,8084:31184/TCP,8883:30290/TCP,8085:30962/TCP 3mMQTT clients connect to EXTERNAL-IP on port 1883, and MQTT over WebSockets on port 8084. The NLB address
resolves a few minutes after it is created.
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 eks' -q 1The subscriber prints tbmq/demo/hello hello from eks. 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.
If the Ingress ADDRESS or the Service EXTERNAL-IP stays empty, the AWS Load Balancer Controller couldn’t create the
load balancer. Its events and logs give the reason:
kubectl describe ingress my-tbmq-cluster-http-lb -n tbmqkubectl describe svc my-tbmq-cluster-mqtt-lb -n tbmqkubectl logs deployment/aws-load-balancer-controller -n kube-systemBack up your PostgreSQL database before upgrading. Then review the upgrade instructions for the notes on every version between yours and the target.
To move a Community Edition release to PE, first upgrade it to the same TBMQ version as the target PE release. Then:
Switch values.yaml to PE.
In the values.yaml of your CE release, set the PE images and the license exactly as for a fresh PE install: see
Configure license and broker images, including the license Secret.
Stop TBMQ.
Scale the broker and Integration Executor to zero so nothing uses the database while it is migrated:
kubectl scale statefulset/my-tbmq-cluster-tbmq-node --replicas=0 -n tbmqkubectl scale statefulset/my-tbmq-cluster-tbmq-ie --replicas=0 -n tbmqRun the upgrade.
helm upgrade my-tbmq-cluster tbmq-helm-chart/tbmq-cluster -n tbmq \ -f values.yaml \ --set upgrade.upgradeDbSchema=true \ --set upgrade.fromVersion=ceThe migration converts the database to PE, then Helm starts the broker and Integration Executor on the PE images with their usual replica count.
Pass upgrade.fromVersion=ce only for this migration. On later PE upgrades, leave it out: with it, the migration fails.
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.2PE
tbmq-ie: image: tag: 2.4.2PERun 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, and the AWS Load Balancer Controller deletes the ALB and the NLB. 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.
The tbmq-license Secret is kept as well.
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. Deleting the namespace also deletes the remaining volumes and their EBS disks.
Amazon RDS, MSK, and ElastiCache instances aren’t affected; delete them in the AWS console if you no longer need them.
Uninstall TBMQ first, as in the previous section. A load balancer that still exists when the cluster is deleted is left behind and keeps the VPC from being deleted.
helm uninstall aws-load-balancer-controller -n kube-systemeksctl delete cluster -r us-east-1 -n tbmq -wUse your cluster’s region in -r. The deletion takes about 15 minutes.
Set 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?