Oracle Cloud OKE Microservices Setup
This guide walks you through deploying ThingsBoard in microservices mode on Oracle Container Engine for Kubernetes (OKE). Terraform provisions the network, the OKE cluster, OCI Database with PostgreSQL, and an OCI Vault for the credentials. Kafka runs in the cluster under the Strimzi operator and Cassandra (optional) under K8ssandra. External Secrets Operator copies the credentials from the Vault into Kubernetes, and all device and user traffic enters through NGINX Gateway Fabric behind a single OCI network load balancer.
Prerequisites
Section titled “Prerequisites”Install and Configure Tools
Section titled “Install and Configure Tools”Install kubectl, Helm, Terraform 1.5 or later, and the OCI CLI.
Configure the OCI CLI with an API signing key for your user. The command creates the DEFAULT profile in ~/.oci/config:
oci setup configAlternatively, sign in through the browser with a session token. Then set auth = "SecurityToken" and config_file_profile = "thingsboard" in Step 2, and export the profile so that the OCI CLI and kubectl use it:
oci session authenticate --region YOUR_OCI_REGION --profile-name thingsboardexport OCI_CLI_PROFILE=thingsboardexport OCI_CLI_AUTH=security_tokenRepeat both export commands in every new terminal. A session token expires after one hour, and this guide takes longer. Renew the token before it expires, for example right before terraform apply:
oci session refresh --profile thingsboardVerify access:
oci iam region list --output tablePull ThingsBoard Images
Section titled “Pull ThingsBoard Images”Verify that you can pull the images from Docker Hub:
docker pull thingsboard/tb-node:4.4.1docker pull thingsboard/tb-web-report:4.4.1docker pull thingsboard/tb-web-ui:4.4.1docker pull thingsboard/tb-js-executor:4.4.1docker pull thingsboard/tb-http-transport:4.4.1docker pull thingsboard/tb-mqtt-transport:4.4.1docker pull thingsboard/tb-coap-transport:4.4.1docker pull thingsboard/tb-lwm2m-transport:4.4.1docker pull thingsboard/tb-snmp-transport:4.4.1docker pull thingsboard/tb-integration-executor:4.4.1Step 1. Clone ThingsBoard K8S Scripts Repository
Section titled “Step 1. Clone ThingsBoard K8S Scripts Repository”Clone the repository containing the Kubernetes deployment scripts:
git clone -b release-4.4.1 https://github.com/thingsboard/thingsboard-pe-k8s.git --depth 1cd thingsboard-pe-k8s/oci/microservicesStep 2. Provision the Infrastructure with Terraform
Section titled “Step 2. Provision the Infrastructure with Terraform”The infrastructure folder contains the Terraform configuration. Edit infrastructure/terraform.tfvars. Key fields:
| Field | Default | Description |
|---|---|---|
region |
— | OCI region identifier, for example eu-frankfurt-1 |
tenancy_ocid |
— | OCID of your tenancy |
compartment_ocid |
tenancy root | Compartment for all resources |
config_file_profile, auth |
DEFAULT, APIKey |
OCI CLI profile and authentication method |
cluster_name |
thingsboard |
Prefix for every resource name |
kubernetes_version |
— | Exact OKE version, for example v1.36.4 |
api_allowed_cidrs |
["0.0.0.0/0"] |
Addresses allowed to reach the Kubernetes API |
tb_node_pool |
3 × VM.Standard.E5.Flex, 2 OCPUs, 16 GB |
Nodes for ThingsBoard, Kafka, ZooKeeper, and Valkey |
cassandra_enabled |
false |
Adds three Cassandra nodes; see Step 7 |
cassandra_backups_enabled |
true |
Adds an Object Storage bucket for Cassandra backups |
service_user_email_domain |
— | Required for Cassandra backups: the email domain of the service user that writes them |
trendz_enabled |
false |
Adds a node for Trendz Analytics |
postgres_instance_count |
2 |
PostgreSQL nodes; a second node takes over on failure |
List the Kubernetes versions OKE supports:
oci ce cluster-options get --cluster-option-id all --query 'data."kubernetes-versions"'Create the infrastructure. It takes about 30 minutes:
cd infrastructureterraform initterraform applycd ..Terraform creates:
- A VCN with public subnets for the Kubernetes API and the load balancer, and private subnets for the worker nodes and the database.
- An enhanced OKE cluster with Kubernetes secrets encrypted by a Vault key, and its node pools.
- An OCI Database with PostgreSQL system. Its connection details are stored in the Vault as the
postgressecret. - An OCI Vault and the IAM policy that lets External Secrets Operator read it through OKE Workload Identity.
- A reserved public IP address for the gateway.
- With Cassandra backups: an Object Storage bucket and a service user limited to it.
Step 3. Configure kubectl
Section titled “Step 3. Configure kubectl”Add the cluster to your kubeconfig:
oci ce cluster create-kubeconfig \ --cluster-id $(terraform -chdir=infrastructure output -raw cluster_id) \ --region $(terraform -chdir=infrastructure output -raw region) \ --token-version 2.0.0 --kube-endpoint PUBLIC_ENDPOINTkubectl get nodesStep 4. Install the Operators
Section titled “Step 4. Install the Operators”Install cert-manager, External Secrets Operator, Strimzi, and NGINX Gateway Fabric with the Gateway API resources. Add --with-cassandra to also install the K8ssandra operator if you set cassandra_enabled = true:
./k8s-install-operators.shAfter this command finishes you should see:
Operators installed successfully!Step 5. Connect External Secrets to OCI Vault
Section titled “Step 5. Connect External Secrets to OCI Vault”Create the secret store for the Vault:
export VAULT_ID=$(terraform -chdir=infrastructure output -raw vault_id)export OCI_REGION=$(terraform -chdir=infrastructure output -raw region)sed -e "s|YOUR_VAULT_OCID|${VAULT_ID}|" -e "s|YOUR_OCI_REGION|${OCI_REGION}|" \ external-secrets/cluster-secret-store.yml | kubectl apply -f -kubectl get clustersecretstore oci-vaultThe store should report STATUS Valid and READY True. Then sync the PostgreSQL connection into the postgres Kubernetes secret:
kubectl apply -f external-secrets/postgres.ymlkubectl -n thingsboard get externalsecret postgresThe STATUS column should show SecretSynced.
Step 6. Obtain and Configure License Key
Section titled “Step 6. Obtain and Configure License Key”We assume you have already chosen your subscription plan or decided to purchase a perpetual license. If not, navigate to the pricing page.
Store the license key in the Vault and sync it into the tb-license Kubernetes secret:
export TB_LICENSE_KEY=PUT_YOUR_LICENSE_KEY_HEREoci vault secret create-base64 \ --compartment-id $(terraform -chdir=infrastructure output -raw compartment_id) \ --vault-id $(terraform -chdir=infrastructure output -raw vault_id) \ --key-id $(terraform -chdir=infrastructure output -raw vault_key_id) \ --secret-name tb-license \ --secret-content-content "$(printf '%s' "$TB_LICENSE_KEY" | base64 | tr -d '\n')"kubectl apply -f external-secrets/tb-license.ymlStep 7. Cassandra (Optional)
Section titled “Step 7. Cassandra (Optional)”Using Cassandra is optional. We recommend it if you plan to insert more than 5K data points per second or want to optimize storage space.
It requires cassandra_enabled = true in Step 2 and the --with-cassandra option in Step 4.
Deploy a three-node Cassandra datacenter, one node per Cassandra node pool, with daily backups to the bucket created by Terraform:
kubectl apply -f external-secrets/cassandra-backups.ymlsed -e "s|YOUR_BACKUP_BUCKET|$(terraform -chdir=infrastructure output -raw cassandra_backup_bucket)|" \ -e "s|YOUR_MEDUSA_HOST|$(terraform -chdir=infrastructure output -raw medusa_host)|" \ -e "s|YOUR_OCI_REGION|$(terraform -chdir=infrastructure output -raw region)|" \ cassandra/k8ssandra-cluster.yml | kubectl apply -f -kubectl apply -f cassandra/medusa-backup-schedule.ymlWait until the datacenter is ready. The first start takes about 15 minutes:
kubectl -n thingsboard wait cassandradatacenter/dc1 --for=condition=Ready --timeout=30mCreate the ThingsBoard keyspace:
CASS_USERNAME=$(kubectl -n thingsboard get secret cassandra-superuser -o jsonpath='{.data.username}' | base64 --decode)CASS_PASSWORD=$(kubectl -n thingsboard get secret cassandra-superuser -o jsonpath='{.data.password}' | base64 --decode)kubectl -n thingsboard exec cassandra-dc1-r1-sts-0 -c cassandra -- cqlsh -u "$CASS_USERNAME" -p "$CASS_PASSWORD" -e \ "CREATE KEYSPACE IF NOT EXISTS thingsboard WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': 3};"Edit tb-node-db-configmap.yml and set DATABASE_TS_TYPE to cassandra.
Step 8. CPU and Memory Resources Allocation
Section titled “Step 8. CPU and Memory Resources Allocation”The scripts have preconfigured values of resources for each service. You can change them in .yml files under the resources section.
Preconfigured resources per pod:
| Service | Pods | CPU request / limit | Memory request / limit |
|---|---|---|---|
| TB Node | 1 | 1000m / 1000m | 1000Mi / 3000Mi |
| TB Integration Executor | 1 | 1000m / 1000m | 1000Mi / 2000Mi |
| TB Web UI | 2 | 100m / 100m | 100Mi / 100Mi |
| TB Web Report | 1 | 100m / 100m | 500Mi / 500Mi |
| JS Executor | 5 | 100m / 100m | 100Mi / 400Mi |
| Each transport (HTTP, MQTT, CoAP, LwM2M, SNMP) | 2 | 500m / 1000m | 500Mi / 2000Mi |
| Valkey | 1 | 100m / 500m | 400Mi / 400Mi |
| Kafka | 3 | 200m / 2000m | 1500Mi / 1500Mi |
| ZooKeeper | 3 | 100m / 300m | 500Mi / 1000Mi |
| NGINX Gateway | 2 | 50m / 1000m | 200Mi / 1000Mi |
| Cassandra (optional) | 3 | 500m / 2000m | 6Gi / 6Gi |
| Trendz (optional) | 1 | 2000m / 2000m | 4000Mi / 4000Mi |
| Trendz Python Executor (optional) | 1 | 1000m / 1000m | 4000Mi / 4000Mi |
Step 9. Installation
Section titled “Step 9. Installation”Execute the following command to start ZooKeeper, Valkey, and a three-broker Kafka cluster, create the thingsboard database, and run the initial setup of the database:
./k8s-install-tb.shAfter this command finishes you should see:
Installation finished successfully!Step 10. Starting
Section titled “Step 10. Starting”Deploy ThingsBoard services:
./k8s-deploy-resources.shAfter a few minutes, call kubectl get pods. If everything went fine, you should see:
- 5x
tb-js-executor - 1x
tb-node(scale to more nodes if you have additional license instances) - 1x
tb-integration-executor - 2x
tb-web-ui - 1x
tb-web-report - 1x
tb-valkey - 3x
tb-kafka - 3x
zookeeper
Every pod should be in the READY state. The namespace also runs the Strimzi operator and, with Cassandra, the K8ssandra operators and the Cassandra pods.
Deploy Transport Microservices
Section titled “Deploy Transport Microservices”Deploy the transport microservices you need. Omit protocols you don’t use to save resources:
# HTTP Transport (optional)kubectl apply -f transports/tb-http-transport.yml
# MQTT Transport (optional)kubectl apply -f transports/tb-mqtt-transport.yml
# CoAP Transport (optional)kubectl apply -f transports/tb-coap-transport.yml
# LwM2M Transport (optional)kubectl apply -f transports/tb-lwm2m-transport.yml
# SNMP Transport (optional)kubectl apply -f transports/tb-snmp-transport.ymlStep 11. Configure the Gateway
Section titled “Step 11. Configure the Gateway”A single gateway serves every protocol on the reserved IP address from Step 2. Create its load balancer settings first, because the reserved address is only read when the load balancer is created:
export INGRESS_IP=$(terraform -chdir=infrastructure output -raw ingress_ip_address)sed "s|YOUR_INGRESS_IP|${INGRESS_IP}|" gateway/nginx-proxy.yml | kubectl apply -f -kubectl apply -f gateway/gateway.ymlkubectl -n thingsboard get gateway tb-gatewayAfter a few minutes the gateway reports PROGRAMMED True with the reserved IP address in the ADDRESS column.
11.1 Configure HTTP(S) Access
Section titled “11.1 Configure HTTP(S) Access”You have 2 options:
- HTTP — recommended for development. Works with the IP address only.
- HTTPS — recommended for production. Requires a domain name and uses a free Let’s Encrypt certificate.
kubectl apply -f gateway/routes/http.ymlUse http:// followed by the reserved IP address to access the web UI, and connect devices via HTTP API.
Administrator account creation on first access is covered next, in Step 12. Create Your Administrator Account.
Create a DNS A record that points your domain to the reserved IP address. Then request the certificate and enable HTTPS:
export TB_DOMAIN=PUT_YOUR_DOMAIN_HEREexport ACME_EMAIL=PUT_YOUR_EMAIL_HEREkubectl kustomize gateway | sed -e "s|YOUR_DOMAIN|${TB_DOMAIN}|" -e "s|YOUR_EMAIL|${ACME_EMAIL}|" | kubectl apply -f -kubectl -n thingsboard get certificate tb-tlsThe certificate is issued within a few minutes, when READY turns True. Plain HTTP then redirects to HTTPS, except for the device HTTP API.
11.2 Configure MQTT Access (Optional)
Section titled “11.2 Configure MQTT Access (Optional)”kubectl apply -f gateway/routes/mqtt.ymlThe gateway forwards TCP traffic on ports 1883 and 8883 to the MQTT transport.
To enable MQTT over TLS on port 8883, complete the HTTPS option of Step 11.1 first. Then uncomment the sections marked “Uncomment the following lines to enable MQTTS” in transports/tb-mqtt-transport.yml and apply it again:
kubectl apply -f transports/tb-mqtt-transport.ymlThe MQTT transport then uses the certificate issued for your domain. See MQTT over TLS for the client configuration.
11.3 Configure CoAP and LwM2M Access (Optional)
Section titled “11.3 Configure CoAP and LwM2M Access (Optional)”kubectl apply -f gateway/routes/coap.ymlkubectl apply -f gateway/routes/lwm2m.ymlThe gateway forwards UDP traffic on these ports:
| Port | Protocol |
|---|---|
| 5683 | CoAP non-secure |
| 5684 | CoAP secure DTLS |
| 5685 | LwM2M non-secure |
| 5686 | LwM2M secure DTLS |
| 5687 | LwM2M bootstrap non-secure |
| 5688 | LwM2M bootstrap secure DTLS |
For CoAP over DTLS, follow the CoAP over DTLS guide. For LwM2M over DTLS, follow the LwM2M over DTLS guide.
11.4 Configure Edge Access (Optional)
Section titled “11.4 Configure Edge Access (Optional)”kubectl apply -f gateway/routes/edge.ymlThe gateway forwards TCP traffic on port 7070 to ThingsBoard. Use the reserved IP address as CLOUD_RPC_HOST in Edge connection parameters.
11.5 Configure Remote Integrations Access (Optional)
Section titled “11.5 Configure Remote Integrations Access (Optional)”kubectl apply -f gateway/routes/integrations.ymlThe gateway forwards TCP traffic on port 9090 to ThingsBoard. Use the reserved IP address, or your domain, as RPC_HOST in the remote integration configuration.
Step 12. Create Your Administrator Account
Section titled “Step 12. Create Your Administrator Account”After launching ThingsBoard, open the web UI at the load balancer address. ThingsBoard prompts you to create your System Administrator account — the account that manages the platform itself (tenants, system settings, platform-wide resources).
- Enter Email, Password, and Confirm password.
- The Set up a demo tenant option is selected by default: it creates a ready-made tenant with dashboards, devices, and rule chains for exploring the platform before building your own solution. Clear it if you want to start with an empty platform.
- Click Create account. You are signed in as the system administrator.
Your ThingsBoard instance is now installed and running.
Validate the Setup
Section titled “Validate the Setup”Check that the gateway and its routes are accepted:
kubectl -n thingsboard get gateway tb-gatewaykubectl -n thingsboard get httproute,tcproute,udprouteOpen the web interface at the reserved IP address, or at your domain if you configured HTTPS. Devices connect to the same address on the ports from Step 11.
[Optional] Configure Trendz Analytics
Section titled “[Optional] Configure Trendz Analytics”Trendz runs on its own node, which requires trendz_enabled = true in Step 2.
Pull Trendz Images
Section titled “Pull Trendz Images”Pull the Trendz images from Docker Hub:
docker pull thingsboard/trendz:1.16.1.3docker pull thingsboard/trendz-python-executor:1.16.1.3Create a Trendz Database
Section titled “Create a Trendz Database”Sync the Trendz database credentials from the Vault and create the database in the existing PostgreSQL system:
kubectl apply -f external-secrets/trendz.ymlkubectl apply -f trendz/trendz-create-db.ymlCheck logs:
kubectl logs job/trendz-create-db -n thingsboardDeploy Trendz
Section titled “Deploy Trendz”./k8s-deploy-trendz.shExpose Trendz on the same listener as the web UI from Step 11:
kubectl apply -f gateway/routes/trendz.ymlsed "s|sectionName: http$|sectionName: https|" gateway/routes/trendz.yml | kubectl apply -f -Troubleshooting
Section titled “Troubleshooting”To examine ThingsBoard node logs:
kubectl logs -f tb-node-0Other useful commands:
kubectl get pods— see the state of all podskubectl get externalsecret— see whether the secrets are synced from the Vaultkubectl get kafka tb— see the state of the Kafka clusterkubectl describe gateway tb-gateway— see the state of the gateway and its listeners
See the kubectl Cheat Sheet for more details.
Cluster Deletion
Section titled “Cluster Deletion”Delete all ThingsBoard pods:
./k8s-delete-resources.shDelete all ThingsBoard resources, including the data volumes and the load balancer:
./k8s-delete-all.shIf you enabled Cassandra backups, empty the backup bucket. OCI doesn’t delete a bucket that still holds objects:
oci os object bulk-delete --bucket-name $(terraform -chdir=infrastructure output -raw cassandra_backup_bucket) --forceDelete the infrastructure:
cd infrastructureterraform destroyNext Steps
Section titled “Next Steps”With ThingsBoard running, these concept guides help you build your first solution:
- Getting Started — a guided walkthrough of the platform after installation.
- Multi-Tenancy & Hierarchy — how tenants, customers, and users are organized.
- Digital Twin Model — how devices and assets are modeled in the platform.
- Data Processing — how the Rule Engine transforms and routes incoming data.
- Alarms & Notifications — how to detect conditions and notify users.
- Data Visualization — how to build dashboards and widgets.
Was this helpful?