立即试用 商务报价
专业版
ThingsBoard Professional Edition cluster setup with Kubernetes and Minikube guide

本页目录

ThingsBoard Professional Edition cluster setup with Kubernetes and Minikube guide

This guide will help you to setup ThingsBoard in cluster mode with Kubernetes and Minikube. For this purpose, we will use docker container images available on Docker Hub.

Prerequisites

ThingsBoard Microservices run on the Kubernetes cluster. You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. If you don’t have Minikube installed, please follow these instructions.

Enable ingress addon

Ingress addon disabled by default in the Minikube, and available only in cluster providers. To enable ingress, please execute the following command:

1
minikube addons enable ingress

Pull ThingsBoard PE images from docker hub

Run the following commands to verify that you can pull the images from the Docker hub.

1
2
3
4
5
6
7
8
9
docker pull thingsboard/tb-pe-node:3.5.1PE
docker pull thingsboard/tb-pe-web-report:3.5.1PE
docker pull thingsboard/tb-pe-web-ui:3.5.1PE
docker pull thingsboard/tb-pe-js-executor:3.5.1PE
docker pull thingsboard/tb-pe-http-transport:3.5.1PE
docker pull thingsboard/tb-pe-mqtt-transport:3.5.1PE
docker pull thingsboard/tb-pe-coap-transport:3.5.1PE
docker pull thingsboard/tb-pe-lwm2m-transport:3.5.1PE
docker pull thingsboard/tb-pe-snmp-transport:3.5.1PE

Step 1. Review the architecture page

Starting ThingsBoard v2.2, it is possible to install ThingsBoard cluster using new microservices architecture and docker containers. See microservices architecture page for more details.

Step 2. Clone ThingsBoard PE Kubernetes scripts

1
2
git clone -b release-3.5.1 https://github.com/thingsboard/thingsboard-pe-k8s.git
cd thingsboard-pe-k8s/minikube

Step 3. Obtain your license key

We assume you have already chosen your subscription plan or decided to purchase a perpetual license. If not, please navigate to pricing page to select the best license option for your case and get your license. See How-to get pay-as-you-go subscription or How-to get perpetual license for more details.

IMPORTANT NOTE: Make sure you have purchased a license key for at least two instances of ThingsBoard PE. Otherwise you need to modify local copy of docker-compose.yml to use only one ThingsBoard instance. We will reference the license key you have obtained during this step as PUT_YOUR_LICENSE_SECRET_HERE later in this guide.

Step 4. Configure your license key

1
nano tb-node.yml

and put the license secret parameter:

1
2
3
4
# tb-node StatefulSet configuration

- name: TB_LICENSE_SECRET
  value: "PUT_YOUR_LICENSE_SECRET_HERE"

Step 5. Review the architecture page

Starting ThingsBoard v2.2, it is possible to install ThingsBoard cluster using new microservices architecture and docker containers. See microservices architecture page for more details.

Step 6. Configure Minikube

By default ingress addon is disabled in the Minikube, and available only in cluster providers. To enable ingress, please execute the following command:

1
minikube addons enable ingress

Step 7. Configure ThingsBoard database

在执行初始安装之前可以配置与ThingsBoard一起使用的数据库的类型。 设置数据库类型在.env文件中的DATABASE变量的值更改为以下值:

  • postgres - use PostgreSQL database;
  • hybrid - use PostgreSQL for entities database and Cassandra for timeseries database;

NOTE: According to the database type corresponding kubernetes resources will be deployed (see postgres.yml, cassandra.yml for details).

Step 8. Running

Execute the following command to run installation:

1
./k8s-install-tb.sh --loadDemo

Where:

  • --loadDemo -可选参数用于是否加载演示数据。

Execute the following command to deploy third-party resources:

1
./k8s-deploy-thirdparty.sh

Type ‘yes’ when prompted, if you are running ThingsBoard in high-availability DEPLOYMENT_TYPE for the first time or don’t have configured Redis cluster.

Execute the following command to deploy ThingsBoard resources:

1
./k8s-deploy-resources.sh

After a while when all resources will be successfully started you can open http://{your-cluster-ip} in your browser (for ex. http://192.168.99.101). You can see your cluster IP using command:

1
minikube ip

You should see ThingsBoard login page.

Use the following default credentials:

  • System Administrator: sysadmin@thingsboard.org / sysadmin

If you installed DataBase with demo data (using --loadDemo flag) you can also use the following credentials:

  • Tenant Administrator: tenant@thingsboard.org / tenant
  • Customer User: customer@thingsboard.org / customer

In case of any issues you can examine service logs for errors. For example to see ThingsBoard node logs execute the following command:

1) Get the list of the running tb-node pods:

1
kubectl get pods -l app=tb-node

2) Fetch logs of the tb-node pod:

1
kubectl logs -f [tb-node-pod-name]

Where:

  • tb-node-pod-name - tb-node pod name obtained from the list of the running tb-node pods.

Or use kubectl get pods to see the state of all the pods. Or use kubectl get services to see the state of all the services. Or use kubectl get deployments to see the state of all the deployments. See kubectl Cheat Sheet command reference for details.

Execute the following command to delete all ThingsBoard microservices:

1
./k8s-delete-resources.sh

Execute the following command to delete all third-party microservices:

1
./k8s-delete-thirdparty.sh

Execute the following command to delete all resources (including database):

1
./k8s-delete-all.sh

Upgrading

In case you would like to upgrade, please pull the latest changes from master branch:

1
git pull origin master

and then execute the following commands:

1
./k8s-delete-resources.sh
1
./k8s-upgrade-tb.sh --fromVersion=[FROM_VERSION]
1
./k8s-deploy-resources.sh

Where:

  • FROM_VERSION - from which version upgrade should be started. See Upgrade Instructions for valid fromVersion values.

Next steps

  • 入门指南 - 快速学习ThingsBoard相关功能。

  • 连接设备 - 学习如何根据你的连接方式或解决方案连接设备。

  • 可 视 化 - 学习如何配置复杂的ThingsBoard仪表板说明。

  • 数据处理 - 学习如何使用ThingsBoard规则引擎。

  • 数据分析 - 学习如何使用规则引擎执行基本的分析任务。

  • 硬件样品 - 学习如何将各种硬件平台连接到ThingsBoard。

  • 高级功能 - 学习高级ThingsBoard功能。

  • 开发指南 - 学习ThingsBoard中的贡献和开发。