2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# Kubernetes resources configuration for ThingsBoard Microservices
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								This folder containing scripts and Kubernetes resources configurations to run ThingsBoard in Microservices mode.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Prerequisites
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								ThingsBoard Microservices run on the Kubernetes cluster.
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster.
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								If you do not have a cluster already, you can create one by using [Minikube ](https://kubernetes.io/docs/setup/minikube ), 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								or you can choose any other available [Kubernetes cluster deployment solutions ](https://kubernetes.io/docs/setup/pick-right-solution/ ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 16:22:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### Enable ingress addon
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								By default ingress addon is disabled in the Minikube, and available only in cluster providers.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								To enable ingress, please execute the following command:
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 16:22:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ minikube addons enable ingress
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								## Installation
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 15:20:30 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Before performing initial installation you can configure the type of database to be used with ThingsBoard and the type of deployment.
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								To set database type change the value of `DATABASE`  variable in `.env`  file to one of the following:
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  `postgres`  - use PostgreSQL database;
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 12:03:27 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								-  `hybrid`  - use PostgreSQL for entities database and Cassandra for timeseries database;
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								**NOTE**: According to the database type corresponding kubernetes resources will be deployed (see `postgres.yml` , `cassandra.yml`  for details).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								To set deployment type change the value of `DEPLOYMENT_TYPE`  variable in `.env`  file to one of the following:
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 15:20:30 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								-  `basic`  - startup with a single instance of Zookeeper, Kafka and Redis;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  `high-availability`  - startup with Zookeeper, Kafka, and Redis in cluster modes;
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 15:20:30 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								**NOTE**: According to the deployment type corresponding kubernetes resources will be deployed (see the content of the directories `./basic`  and `./high-availability`  for details).
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 15:20:30 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Execute the following command to run the installation:
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ ./k8s-install-tb.sh --loadDemo
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Where:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  `--loadDemo`  - optional argument. Whether to load additional demo data.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Running
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Execute the following command to deploy third-party resources:
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 09:54:49 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ ./k8s-deploy-thirdparty.sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 17:08:11 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Type ** 'yes'** when prompted, if you are running ThingsBoard in `high-availability`  `DEPLOYMENT_TYPE`  for the first time and don't have configured Redis cluster.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 09:54:49 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								Execute the following command to deploy resources:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ ./k8s-deploy-resources.sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								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 should see the ThingsBoard login page.
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								In case of any issues, you can examine service logs for errors.
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								For example to see ThingsBoard node logs execute the following commands:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								1) Get the list of the running tb-node pods:
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl get pods -l app=tb-node
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								2) Fetch logs of the tb-node pod:
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ 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 ](https://kubernetes.io/docs/reference/kubectl/cheatsheet/ ) command reference for details.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 17:17:45 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Execute the following command to delete all ThingsBoard microservices:
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ ./k8s-delete-resources.sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:33:51 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Execute the following command to delete all third-party microservices:
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 17:17:45 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ ./k8s-delete-thirdparty.sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-05 13:41:45 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								Execute the following command to delete all resources (including database):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ ./k8s-delete-all.sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Upgrading
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								In case when database upgrade is needed, execute the following commands:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ ./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 ](https://thingsboard.io/docs/user-guide/install/upgrade-instructions ) for valid `fromVersion`  values.