Monolith setup using GCP infrastructure
Primeiros Passos Documentação Guias Arquitetura API FAQ

Monolith setup using GCP infrastructure

This guide will help you to set up ThingsBoard in monolith mode in GKE.

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.

Step 1. Clone ThingsBoard CE K8S scripts repository

1
2
git clone https://github.com/thingsboard/thingsboard-ce-k8s.git
cd thingsboard-ce-k8s/gcp/monolith

Step 2. Configure and create GKE cluster

Please follow this guide to set up a GCP cluster.

For this deployment you’ll need 2 nodes of e2-standard-2 machine type. You can find this configuration in the NODE POOLS submenu:

image

To update context of Kubectl execute this command:

1
gcloud container clusters get-credentials $CLUSTER_NAME

where $CLUSTER_NAME is the name you gave to your cluster.

Step 3. Configure secure HTTP connection

Note: if you don’t need SSL connection over HTTP, you’ll need to remove tls: and - secretName: ssl-cert-secret lines in the routes.yml file and skip this step.

Follow this guide to create your own SSL certificate. After the certificate is created call the next command:

1
kubectl create secret tls ssl-cert-secret --cert CERT_FILE --key KEY_FILE

where:

  • CERT_FILE: the path to your certificate file.
  • KEY_FILE: the path to the key file that goes with your certificate.

Step 4. Configure secure MQTT connection

Follow this guide to create a .jks file with the SSL certificate. Afterwards, you need to set MQTT_SSL_KEY_STORE_PASSWORD and MQTT_SSL_KEY_PASSWORD environment variables in the tb-node.yml file to the corresponding key-store and certificate key passwords.

You’ll need to create a config-map with your JKS file, you can do it by calling command:

1
2
kubectl create configmap tb-mqtts-config \
             --from-file=server.jks=YOUR_JKS_FILENAME.jks -o yaml --dry-run=client | kubectl apply -f -

where YOUR_JKS_FILENAME is the name of your .jks file.

Note: if you don’t need SSL connection over MQTT, you’ll need to set MQTT_SSL_ENABLED environment variable to false and delete all notions of tb-mqtts-config in the tb-node.yml file.

Step 5. Installation

Execute the following command to run installation:

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

Where:

  • --loadDemo - optional argument. Whether to load additional demo data.

After this command finish you should see the next line in the console:

1
Installation finished successfully!

Step 6. Starting

Execute the following command to deploy resources:

1
 ./k8s-deploy-resources.sh

After few minutes you may call kubectl get pods. If everything went fine, you should be able to see tb-node-0 pod in the READY state.

Step 7. Using

Now you can open ThingsBoard web interface in your browser using DNS name of the load balancer.

You can see DNS name (the ADDRESS column) of the HTTP load-balancer using command:

1
kubectl get ingress

You should see the similar picture:

image

To connect to the cluster via MQTT or COAP you’ll need to get corresponding service, you can do it with command:

1
kubectl get service

You should see the similar picture:

image

There are two load-balancers:

  • tb-mqtt-loadbalancer-external - for MQTT protocol
  • tb-coap-loadbalancer-external - for COAP protocol

Use EXTERNAL-IP field of the load-balancers to connect to the cluster.

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
kubectl logs -f tb-node-0

Or use kubectl get pods to see the state of the pod. 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 tb-node and load-balancers:

1
./k8s-delete-resources.sh

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

1
./k8s-delete-all.sh

Upgrading

In case when database upgrade is needed, execute the following commands:

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

Where:

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