Skip to content
Stand with Ukraine flag

Helm · AWS EKS

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

  • TBMQ × 2
  • Integration Executor × 2
  • AWS Load Balancer Controller

Dependencies

  • PostgreSQL (PGO or RDS)
  • Kafka (Strimzi or MSK)
  • Valkey (or ElastiCache)

Load balancer ports

  • 80 HTTP · ALB TBMQ UI and REST API
  • 443 HTTPS · ALB TBMQ UI and REST API, once you enable HTTPS access
  • 1883 MQTT · NLB MQTT clients
  • 8084 MQTT over WebSockets · NLB MQTT clients that connect over WebSockets
  • 8883 MQTTS · NLB MQTT clients that connect over TLS, once you configure TLS termination or mutual TLS
  • 8085 MQTT over secure WebSockets · NLB MQTT clients that connect over secure WebSockets, once you configure TLS termination or mutual TLS

Install the following tools:

Your AWS credentials need permission to create EKS clusters, VPCs, EC2 instances, IAM roles, and load balancers.

Set your access key, secret key, and default region:

Terminal window
aws configure

To create access keys, see Manage access keys for IAM users.

Download the EKS cluster configuration:

Terminal window
curl -o cluster.yml https://raw.githubusercontent.com/thingsboard/tbmq/release-2.4.2/k8s/helm/aws/cluster.yml

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

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

Each 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: true

The 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.
Terminal window
eksctl create cluster -f cluster.yml

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

Terminal window
curl -o gp3-def-sc.yml https://raw.githubusercontent.com/thingsboard/tbmq/release-2.4.2/k8s/helm/aws/gp3-def-sc.yml
Terminal window
kubectl apply -f gp3-def-sc.yml
kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
gp2 kubernetes.io/aws-ebs Delete WaitForFirstConsumer false 15m
gp3 (default) ebs.csi.aws.com Delete WaitForFirstConsumer true 5s

gp3 must be the only default. If gp2 is also marked (default), remove its flag:

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

Terminal window
helm repo add eks https://aws.github.io/eks-charts
helm repo update
helm 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-controller
kubectl rollout status deployment/aws-load-balancer-controller -n kube-system --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 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:

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 on the postgresql nodes:

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
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: 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 on the kafka nodes:

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"
template:
pod:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: role
operator: In
values: ["kafka"]
---
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 on the redis node 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 --set nodeSelector.role=redis
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=valkey -n tbmq --timeout=180s

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

Create the PostgreSQL password Secret in the tbmq namespace first:

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

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, set nodeSelector in the tbmq and tbmq-ie sections to the node group labels:

tbmq:
nodeSelector:
role: tbmq
tbmq-ie:
nodeSelector:
role: tbmq-ie

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.

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

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

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

Terminal window
kubectl get ingress my-tbmq-cluster-http-lb -n tbmq
NAME CLASS HOSTS ADDRESS PORTS AGE
my-tbmq-cluster-http-lb alb * k8s-tbmq-mytbmqcl-1dddafb123-2111810989.us-east-1.elb.amazonaws.com 80 3m

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

Username
sysadmin@thingsboard.org
Password
sysadmin

Change the password after the first sign-in.

Get the address of the NLB:

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.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 3m

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

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

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

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.

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:

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/aws-load-balancer-controller -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 the AWS Load Balancer Controller deletes the ALB and the NLB. 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. 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.

Terminal window
helm uninstall aws-load-balancer-controller -n kube-system
eksctl delete cluster -r us-east-1 -n tbmq -w

Use your cluster’s region in -r. The deletion takes about 15 minutes.

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.