Showing
26 changed files
with
472 additions
and
152 deletions
1 | +# Can be either basic (with single instance of Zookeeper, Kafka and Redis) or high-availability (with Zookeeper, Kafka and Redis in cluster modes). | |
2 | +# According to the deployment type corresponding kubernetes resources will be deployed (see content of the directories ./basic and ./high-availability for details). | |
3 | +DEPLOYMENT_TYPE=high-availability | |
1 | 4 | |
2 | -# Database used by ThingsBoard, can be either postgres (PostgreSQL) or cassandra (Cassandra). | |
5 | +# Database used by ThingsBoard, can be either postgres (PostgreSQL) or hybrid (PostgreSQL for entities database and Cassandra for timeseries database). | |
3 | 6 | # According to the database type corresponding kubernetes resources will be deployed (see postgres.yml, cassandra.yml for details). |
4 | - | |
5 | 7 | DATABASE=postgres |
8 | + | ... | ... |
... | ... | @@ -20,7 +20,7 @@ $ minikube addons enable ingress |
20 | 20 | |
21 | 21 | ## Installation |
22 | 22 | |
23 | -Before performing initial installation you can configure the type of database to be used with ThingsBoard. | |
23 | +Before performing initial installation you can configure the type of database to be used with ThingsBoard and the type of deployment. | |
24 | 24 | In order to set database type change the value of `DATABASE` variable in `.env` file to one of the following: |
25 | 25 | |
26 | 26 | - `postgres` - use PostgreSQL database; |
... | ... | @@ -28,6 +28,13 @@ In order to set database type change the value of `DATABASE` variable in `.env` |
28 | 28 | |
29 | 29 | **NOTE**: According to the database type corresponding kubernetes resources will be deployed (see `postgres.yml`, `cassandra.yml` for details). |
30 | 30 | |
31 | +In order to set deployment type change the value of `DEPLOYMENT_TYPE` variable in `.env` file to one of the following: | |
32 | + | |
33 | +- `basic` - start up with single instance of Zookeeper, Kafka and Redis; | |
34 | +- `high-availability` - start up with Zookeeper, Kafka and Redis in cluster modes; | |
35 | + | |
36 | +**NOTE**: According to the deployment type corresponding kubernetes resources will be deployed (see content of the directories `./basic` and `./high-availability` for details). | |
37 | + | |
31 | 38 | Execute the following command to run installation: |
32 | 39 | |
33 | 40 | ` |
... | ... | @@ -46,19 +53,7 @@ Execute the following command to deploy thirdparty resources: |
46 | 53 | $ ./k8s-deploy-thirdparty.sh |
47 | 54 | ` |
48 | 55 | |
49 | -Get list of the running tb-redis pods and verify that all of them are in running state: | |
50 | - | |
51 | -` | |
52 | -$ kubectl get pods -l app=tb-redis | |
53 | -` | |
54 | - | |
55 | -Execute the following command to create redis cluster: | |
56 | - | |
57 | -` | |
58 | -$ kubectl exec -it tb-redis-0 -- redis-cli --cluster create --cluster-replicas 1 $(kubectl get pods -l app=tb-redis -o jsonpath='{range.items[*]}{.status.podIP}:6379 ') | |
59 | -` | |
60 | - | |
61 | -Type **'yes'** when prompted. | |
56 | +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. | |
62 | 57 | |
63 | 58 | Execute the following command to deploy resources: |
64 | 59 | |
... | ... | @@ -102,12 +97,18 @@ Or use `kubectl get services` to see the state of all the services. |
102 | 97 | Or use `kubectl get deployments` to see the state of all the deployments. |
103 | 98 | See [kubectl Cheat Sheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/) command reference for details. |
104 | 99 | |
105 | -Execute the following command to delete all deployed microservices: | |
100 | +Execute the following command to delete all ThingsBoard microservices: | |
106 | 101 | |
107 | 102 | ` |
108 | 103 | $ ./k8s-delete-resources.sh |
109 | 104 | ` |
110 | 105 | |
106 | +Execute the following command to delete all thirdparty microservices: | |
107 | + | |
108 | +` | |
109 | +$ ./k8s-delete-thirdparty.sh | |
110 | +` | |
111 | + | |
111 | 112 | Execute the following command to delete all resources (including database): |
112 | 113 | |
113 | 114 | ` | ... | ... |
k8s/basic/tb-node-cache-configmap.yml
0 → 100644
1 | +# | |
2 | +# Copyright © 2016-2020 The Thingsboard Authors | |
3 | +# | |
4 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | +# you may not use this file except in compliance with the License. | |
6 | +# You may obtain a copy of the License at | |
7 | +# | |
8 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
9 | +# | |
10 | +# Unless required by applicable law or agreed to in writing, software | |
11 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | +# See the License for the specific language governing permissions and | |
14 | +# limitations under the License. | |
15 | +# | |
16 | + | |
17 | +apiVersion: v1 | |
18 | +kind: ConfigMap | |
19 | +metadata: | |
20 | + name: tb-node-cache-config | |
21 | + namespace: thingsboard | |
22 | + labels: | |
23 | + name: tb-node-cache-config | |
24 | +data: | |
25 | + CACHE_TYPE: redis | |
26 | + REDIS_HOST: tb-redis | |
\ No newline at end of file | ... | ... |
k8s/basic/thirdparty.yml
0 → 100644
1 | +# | |
2 | +# Copyright © 2016-2020 The Thingsboard Authors | |
3 | +# | |
4 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | +# you may not use this file except in compliance with the License. | |
6 | +# You may obtain a copy of the License at | |
7 | +# | |
8 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
9 | +# | |
10 | +# Unless required by applicable law or agreed to in writing, software | |
11 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | +# See the License for the specific language governing permissions and | |
14 | +# limitations under the License. | |
15 | +# | |
16 | + | |
17 | +apiVersion: apps/v1 | |
18 | +kind: Deployment | |
19 | +metadata: | |
20 | + name: zookeeper | |
21 | + namespace: thingsboard | |
22 | +spec: | |
23 | + selector: | |
24 | + matchLabels: | |
25 | + app: zookeeper | |
26 | + template: | |
27 | + metadata: | |
28 | + labels: | |
29 | + app: zookeeper | |
30 | + spec: | |
31 | + containers: | |
32 | + - name: server | |
33 | + imagePullPolicy: Always | |
34 | + image: zookeeper:3.5 | |
35 | + ports: | |
36 | + - containerPort: 2181 | |
37 | + readinessProbe: | |
38 | + periodSeconds: 5 | |
39 | + tcpSocket: | |
40 | + port: 2181 | |
41 | + livenessProbe: | |
42 | + initialDelaySeconds: 15 | |
43 | + periodSeconds: 5 | |
44 | + tcpSocket: | |
45 | + port: 2181 | |
46 | + env: | |
47 | + - name: ZOO_MY_ID | |
48 | + value: "1" | |
49 | + - name: ZOO_SERVERS | |
50 | + value: "server.1=0.0.0.0:2888:3888;0.0.0.0:2181" | |
51 | + restartPolicy: Always | |
52 | +--- | |
53 | +apiVersion: v1 | |
54 | +kind: Service | |
55 | +metadata: | |
56 | + name: zookeeper | |
57 | + namespace: thingsboard | |
58 | +spec: | |
59 | + type: ClusterIP | |
60 | + selector: | |
61 | + app: zookeeper | |
62 | + ports: | |
63 | + - name: zk-port | |
64 | + port: 2181 | |
65 | +--- | |
66 | +apiVersion: apps/v1 | |
67 | +kind: Deployment | |
68 | +metadata: | |
69 | + name: tb-kafka | |
70 | + namespace: thingsboard | |
71 | +spec: | |
72 | + selector: | |
73 | + matchLabels: | |
74 | + app: tb-kafka | |
75 | + template: | |
76 | + metadata: | |
77 | + labels: | |
78 | + app: tb-kafka | |
79 | + spec: | |
80 | + containers: | |
81 | + - name: server | |
82 | + imagePullPolicy: Always | |
83 | + image: wurstmeister/kafka:2.12-2.2.1 | |
84 | + ports: | |
85 | + - containerPort: 9092 | |
86 | + readinessProbe: | |
87 | + periodSeconds: 20 | |
88 | + tcpSocket: | |
89 | + port: 9092 | |
90 | + livenessProbe: | |
91 | + initialDelaySeconds: 25 | |
92 | + periodSeconds: 5 | |
93 | + tcpSocket: | |
94 | + port: 9092 | |
95 | + env: | |
96 | + - name: KAFKA_ZOOKEEPER_CONNECT | |
97 | + value: "zookeeper:2181" | |
98 | + - name: KAFKA_LISTENERS | |
99 | + value: "INSIDE://:9093,OUTSIDE://:9092" | |
100 | + - name: KAFKA_ADVERTISED_LISTENERS | |
101 | + value: "INSIDE://:9093,OUTSIDE://tb-kafka:9092" | |
102 | + - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP | |
103 | + value: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT" | |
104 | + - name: KAFKA_INTER_BROKER_LISTENER_NAME | |
105 | + value: "INSIDE" | |
106 | + - name: KAFKA_CREATE_TOPICS | |
107 | + value: "js_eval.requests:100:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb_transport.api.requests:30:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb_rule_engine:30:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600" | |
108 | + - name: KAFKA_AUTO_CREATE_TOPICS_ENABLE | |
109 | + value: "false" | |
110 | + - name: KAFKA_LOG_RETENTION_BYTES | |
111 | + value: "1073741824" | |
112 | + - name: KAFKA_LOG_SEGMENT_BYTES | |
113 | + value: "268435456" | |
114 | + - name: KAFKA_LOG_RETENTION_MS | |
115 | + value: "300000" | |
116 | + - name: KAFKA_LOG_CLEANUP_POLICY | |
117 | + value: "delete" | |
118 | + restartPolicy: Always | |
119 | +--- | |
120 | +apiVersion: v1 | |
121 | +kind: Service | |
122 | +metadata: | |
123 | + name: tb-kafka | |
124 | + namespace: thingsboard | |
125 | +spec: | |
126 | + type: ClusterIP | |
127 | + selector: | |
128 | + app: tb-kafka | |
129 | + ports: | |
130 | + - name: tb-kafka-port | |
131 | + port: 9092 | |
132 | +--- | |
133 | +apiVersion: apps/v1 | |
134 | +kind: Deployment | |
135 | +metadata: | |
136 | + name: tb-redis | |
137 | + namespace: thingsboard | |
138 | +spec: | |
139 | + selector: | |
140 | + matchLabels: | |
141 | + app: tb-redis | |
142 | + template: | |
143 | + metadata: | |
144 | + labels: | |
145 | + app: tb-redis | |
146 | + spec: | |
147 | + containers: | |
148 | + - name: server | |
149 | + imagePullPolicy: Always | |
150 | + image: redis:4.0 | |
151 | + ports: | |
152 | + - containerPort: 6379 | |
153 | + readinessProbe: | |
154 | + periodSeconds: 5 | |
155 | + tcpSocket: | |
156 | + port: 6379 | |
157 | + livenessProbe: | |
158 | + periodSeconds: 5 | |
159 | + tcpSocket: | |
160 | + port: 6379 | |
161 | + volumeMounts: | |
162 | + - mountPath: /data | |
163 | + name: redis-data | |
164 | + volumes: | |
165 | + - name: redis-data | |
166 | + emptyDir: {} | |
167 | + restartPolicy: Always | |
168 | +--- | |
169 | +apiVersion: v1 | |
170 | +kind: Service | |
171 | +metadata: | |
172 | + name: tb-redis | |
173 | + namespace: thingsboard | |
174 | +spec: | |
175 | + type: ClusterIP | |
176 | + selector: | |
177 | + app: tb-redis | |
178 | + ports: | |
179 | + - name: tb-redis-port | |
180 | + port: 6379 | |
181 | +--- | |
\ No newline at end of file | ... | ... |
k8s/common/cassandra.yml
renamed from
k8s/cassandra.yml
k8s/common/database-setup.yml
renamed from
k8s/database-setup.yml
k8s/common/postgres.yml
renamed from
k8s/postgres.yml
k8s/common/tb-coap-transport-configmap.yml
renamed from
k8s/tb-coap-transport-configmap.yml
k8s/common/tb-http-transport-configmap.yml
renamed from
k8s/tb-http-transport-configmap.yml
k8s/common/tb-mqtt-transport-configmap.yml
renamed from
k8s/tb-mqtt-transport-configmap.yml
k8s/common/tb-namespace.yml
renamed from
k8s/tb-namespace.yml
k8s/common/tb-node-configmap.yml
renamed from
k8s/tb-node-configmap.yml
k8s/common/tb-node-hybrid-configmap.yml
renamed from
k8s/tb-node-cassandra-configmap.yml
... | ... | @@ -22,7 +22,11 @@ metadata: |
22 | 22 | labels: |
23 | 23 | name: tb-node-db-config |
24 | 24 | data: |
25 | + SPRING_JPA_DATABASE_PLATFORM: org.hibernate.dialect.PostgreSQLDialect | |
26 | + SPRING_DRIVER_CLASS_NAME: org.postgresql.Driver | |
27 | + SPRING_DATASOURCE_URL: jdbc:postgresql://tb-database:5432/thingsboard | |
28 | + SPRING_DATASOURCE_USERNAME: postgres | |
29 | + SPRING_DATASOURCE_PASSWORD: postgres | |
25 | 30 | DATABASE_TS_TYPE: cassandra |
26 | - DATABASE_ENTITIES_TYPE: cassandra | |
27 | 31 | CASSANDRA_URL: cassandra:9042 |
28 | 32 | CASSANDRA_SOCKET_READ_TIMEOUT: "60000" | ... | ... |
k8s/common/tb-node-postgres-configmap.yml
renamed from
k8s/tb-node-postgres-configmap.yml
... | ... | @@ -23,7 +23,6 @@ metadata: |
23 | 23 | name: tb-node-db-config |
24 | 24 | data: |
25 | 25 | DATABASE_TS_TYPE: sql |
26 | - DATABASE_ENTITIES_TYPE: sql | |
27 | 26 | SPRING_JPA_DATABASE_PLATFORM: org.hibernate.dialect.PostgreSQLDialect |
28 | 27 | SPRING_DRIVER_CLASS_NAME: org.postgresql.Driver |
29 | 28 | SPRING_DATASOURCE_URL: jdbc:postgresql://tb-database:5432/thingsboard | ... | ... |
k8s/common/tb-node.yml
0 → 100644
1 | +# | |
2 | +# Copyright © 2016-2020 The Thingsboard Authors | |
3 | +# | |
4 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | +# you may not use this file except in compliance with the License. | |
6 | +# You may obtain a copy of the License at | |
7 | +# | |
8 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
9 | +# | |
10 | +# Unless required by applicable law or agreed to in writing, software | |
11 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | +# See the License for the specific language governing permissions and | |
14 | +# limitations under the License. | |
15 | +# | |
16 | + | |
17 | +apiVersion: apps/v1 | |
18 | +kind: Deployment | |
19 | +metadata: | |
20 | + name: tb-node | |
21 | + namespace: thingsboard | |
22 | +spec: | |
23 | + replicas: 2 | |
24 | + selector: | |
25 | + matchLabels: | |
26 | + app: tb-node | |
27 | + template: | |
28 | + metadata: | |
29 | + labels: | |
30 | + app: tb-node | |
31 | + spec: | |
32 | + volumes: | |
33 | + - name: tb-node-config | |
34 | + configMap: | |
35 | + name: tb-node-config | |
36 | + items: | |
37 | + - key: conf | |
38 | + path: thingsboard.conf | |
39 | + - key: logback | |
40 | + path: logback.xml | |
41 | + containers: | |
42 | + - name: server | |
43 | + imagePullPolicy: Always | |
44 | + image: thingsboard/tb-node:latest | |
45 | + ports: | |
46 | + - containerPort: 8080 | |
47 | + name: http | |
48 | + - containerPort: 9001 | |
49 | + name: rpc | |
50 | + env: | |
51 | + - name: TB_SERVICE_ID | |
52 | + valueFrom: | |
53 | + fieldRef: | |
54 | + fieldPath: metadata.name | |
55 | + - name: TB_SERVICE_TYPE | |
56 | + value: "monolith" | |
57 | + - name: TB_QUEUE_TYPE | |
58 | + value: "kafka" | |
59 | + - name: ZOOKEEPER_ENABLED | |
60 | + value: "true" | |
61 | + - name: ZOOKEEPER_URL | |
62 | + value: "zookeeper:2181" | |
63 | + - name: TB_KAFKA_SERVERS | |
64 | + value: "tb-kafka:9092" | |
65 | + - name: JS_EVALUATOR | |
66 | + value: "remote" | |
67 | + - name: TRANSPORT_TYPE | |
68 | + value: "remote" | |
69 | + - name: HTTP_LOG_CONTROLLER_ERROR_STACK_TRACE | |
70 | + value: "false" | |
71 | + envFrom: | |
72 | + - configMapRef: | |
73 | + name: tb-node-db-config | |
74 | + - configMapRef: | |
75 | + name: tb-node-cache-config | |
76 | + volumeMounts: | |
77 | + - mountPath: /config | |
78 | + name: tb-node-config | |
79 | + livenessProbe: | |
80 | + httpGet: | |
81 | + path: /login | |
82 | + port: http | |
83 | + initialDelaySeconds: 300 | |
84 | + timeoutSeconds: 10 | |
85 | + restartPolicy: Always | |
86 | +--- | |
87 | +apiVersion: v1 | |
88 | +kind: Service | |
89 | +metadata: | |
90 | + name: tb-node | |
91 | + namespace: thingsboard | |
92 | +spec: | |
93 | + type: ClusterIP | |
94 | + selector: | |
95 | + app: tb-node | |
96 | + ports: | |
97 | + - port: 8080 | |
98 | + name: http | |
\ No newline at end of file | ... | ... |
k8s/common/thingsboard.yml
renamed from
k8s/thingsboard.yml
... | ... | @@ -35,7 +35,7 @@ spec: |
35 | 35 | image: thingsboard/tb-js-executor:latest |
36 | 36 | env: |
37 | 37 | - name: REMOTE_JS_EVAL_REQUEST_TOPIC |
38 | - value: "js.eval.requests" | |
38 | + value: "js_eval.requests" | |
39 | 39 | - name: TB_KAFKA_SERVERS |
40 | 40 | value: "tb-kafka:9092" |
41 | 41 | - name: LOGGER_LEVEL |
... | ... | @@ -53,93 +53,6 @@ spec: |
53 | 53 | apiVersion: apps/v1 |
54 | 54 | kind: Deployment |
55 | 55 | metadata: |
56 | - name: tb-node | |
57 | - namespace: thingsboard | |
58 | -spec: | |
59 | - replicas: 2 | |
60 | - selector: | |
61 | - matchLabels: | |
62 | - app: tb-node | |
63 | - template: | |
64 | - metadata: | |
65 | - labels: | |
66 | - app: tb-node | |
67 | - spec: | |
68 | - volumes: | |
69 | - - name: tb-node-config | |
70 | - configMap: | |
71 | - name: tb-node-config | |
72 | - items: | |
73 | - - key: conf | |
74 | - path: thingsboard.conf | |
75 | - - key: logback | |
76 | - path: logback.xml | |
77 | - containers: | |
78 | - - name: server | |
79 | - imagePullPolicy: Always | |
80 | - image: thingsboard/tb-node:latest | |
81 | - ports: | |
82 | - - containerPort: 8080 | |
83 | - name: http | |
84 | - - containerPort: 9001 | |
85 | - name: rpc | |
86 | - env: | |
87 | - - name: TB_SERVICE_ID | |
88 | - valueFrom: | |
89 | - fieldRef: | |
90 | - fieldPath: metadata.name | |
91 | - - name: TB_SERVICE_TYPE | |
92 | - value: "monolith" | |
93 | - - name: ZOOKEEPER_ENABLED | |
94 | - value: "true" | |
95 | - - name: ZOOKEEPER_URL | |
96 | - value: "zookeeper:2181" | |
97 | - - name: TB_KAFKA_SERVERS | |
98 | - value: "tb-kafka:9092" | |
99 | - - name: JS_EVALUATOR | |
100 | - value: "remote" | |
101 | - - name: TRANSPORT_TYPE | |
102 | - value: "remote" | |
103 | - - name: CACHE_TYPE | |
104 | - value: "redis" | |
105 | - - name: REDIS_HOST | |
106 | - value: "tb-redis" | |
107 | - - name: REDIS_CONNECTION_TYPE | |
108 | - value: "cluster" | |
109 | - - name: REDIS_NODES | |
110 | - value: "tb-redis:6379" | |
111 | - - name: HTTP_LOG_CONTROLLER_ERROR_STACK_TRACE | |
112 | - value: "false" | |
113 | - envFrom: | |
114 | - - configMapRef: | |
115 | - name: tb-node-db-config | |
116 | - volumeMounts: | |
117 | - - mountPath: /config | |
118 | - name: tb-node-config | |
119 | - livenessProbe: | |
120 | - httpGet: | |
121 | - path: /login | |
122 | - port: http | |
123 | - initialDelaySeconds: 120 | |
124 | - timeoutSeconds: 10 | |
125 | - restartPolicy: Always | |
126 | ---- | |
127 | -apiVersion: v1 | |
128 | -kind: Service | |
129 | -metadata: | |
130 | - name: tb-node | |
131 | - namespace: thingsboard | |
132 | -spec: | |
133 | - type: ClusterIP | |
134 | - selector: | |
135 | - app: tb-node | |
136 | - ports: | |
137 | - - port: 8080 | |
138 | - name: http | |
139 | ---- | |
140 | -apiVersion: apps/v1 | |
141 | -kind: Deployment | |
142 | -metadata: | |
143 | 56 | name: tb-mqtt-transport |
144 | 57 | namespace: thingsboard |
145 | 58 | spec: |
... | ... | @@ -173,8 +86,8 @@ spec: |
173 | 86 | valueFrom: |
174 | 87 | fieldRef: |
175 | 88 | fieldPath: metadata.name |
176 | - - name: TB_SERVICE_TYPE | |
177 | - value: "monolith" | |
89 | + - name: TB_QUEUE_TYPE | |
90 | + value: "kafka" | |
178 | 91 | - name: MQTT_BIND_ADDRESS |
179 | 92 | value: "0.0.0.0" |
180 | 93 | - name: MQTT_BIND_PORT |
... | ... | @@ -191,6 +104,7 @@ spec: |
191 | 104 | tcpSocket: |
192 | 105 | port: 1883 |
193 | 106 | livenessProbe: |
107 | + initialDelaySeconds: 120 | |
194 | 108 | periodSeconds: 20 |
195 | 109 | tcpSocket: |
196 | 110 | port: 1883 |
... | ... | @@ -246,8 +160,8 @@ spec: |
246 | 160 | valueFrom: |
247 | 161 | fieldRef: |
248 | 162 | fieldPath: metadata.name |
249 | - - name: TB_SERVICE_TYPE | |
250 | - value: "monolith" | |
163 | + - name: TB_QUEUE_TYPE | |
164 | + value: "kafka" | |
251 | 165 | - name: HTTP_BIND_ADDRESS |
252 | 166 | value: "0.0.0.0" |
253 | 167 | - name: HTTP_BIND_PORT |
... | ... | @@ -264,6 +178,7 @@ spec: |
264 | 178 | tcpSocket: |
265 | 179 | port: 8080 |
266 | 180 | livenessProbe: |
181 | + initialDelaySeconds: 120 | |
267 | 182 | periodSeconds: 20 |
268 | 183 | tcpSocket: |
269 | 184 | port: 8080 |
... | ... | @@ -319,8 +234,8 @@ spec: |
319 | 234 | valueFrom: |
320 | 235 | fieldRef: |
321 | 236 | fieldPath: metadata.name |
322 | - - name: TB_SERVICE_TYPE | |
323 | - value: "monolith" | |
237 | + - name: TB_QUEUE_TYPE | |
238 | + value: "kafka" | |
324 | 239 | - name: COAP_BIND_ADDRESS |
325 | 240 | value: "0.0.0.0" |
326 | 241 | - name: COAP_BIND_PORT |
... | ... | @@ -423,17 +338,33 @@ spec: |
423 | 338 | backend: |
424 | 339 | serviceName: tb-http-transport |
425 | 340 | servicePort: 8080 |
341 | + - path: /api/.* | |
342 | + backend: | |
343 | + serviceName: tb-node | |
344 | + servicePort: 8080 | |
345 | + - path: /swagger.* | |
346 | + backend: | |
347 | + serviceName: tb-node | |
348 | + servicePort: 8080 | |
349 | + - path: /webjars.* | |
350 | + backend: | |
351 | + serviceName: tb-node | |
352 | + servicePort: 8080 | |
353 | + - path: /v2/.* | |
354 | + backend: | |
355 | + serviceName: tb-node | |
356 | + servicePort: 8080 | |
426 | 357 | - path: /static/rulenode/.* |
427 | 358 | backend: |
428 | 359 | serviceName: tb-node |
429 | 360 | servicePort: 8080 |
430 | - - path: /static/.* | |
361 | + - path: /oauth2/.* | |
431 | 362 | backend: |
432 | - serviceName: tb-web-ui | |
363 | + serviceName: tb-node | |
433 | 364 | servicePort: 8080 |
434 | - - path: /index.html.* | |
365 | + - path: /login/oauth2/.* | |
435 | 366 | backend: |
436 | - serviceName: tb-web-ui | |
367 | + serviceName: tb-node | |
437 | 368 | servicePort: 8080 |
438 | 369 | - path: / |
439 | 370 | backend: |
... | ... | @@ -441,6 +372,6 @@ spec: |
441 | 372 | servicePort: 8080 |
442 | 373 | - path: /.* |
443 | 374 | backend: |
444 | - serviceName: tb-node | |
375 | + serviceName: tb-web-ui | |
445 | 376 | servicePort: 8080 |
446 | ---- | |
\ No newline at end of file | ||
377 | +--- | ... | ... |
1 | +# | |
2 | +# Copyright © 2016-2020 The Thingsboard Authors | |
3 | +# | |
4 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | +# you may not use this file except in compliance with the License. | |
6 | +# You may obtain a copy of the License at | |
7 | +# | |
8 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
9 | +# | |
10 | +# Unless required by applicable law or agreed to in writing, software | |
11 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | +# See the License for the specific language governing permissions and | |
14 | +# limitations under the License. | |
15 | +# | |
16 | + | |
17 | +apiVersion: v1 | |
18 | +kind: ConfigMap | |
19 | +metadata: | |
20 | + name: tb-node-cache-config | |
21 | + namespace: thingsboard | |
22 | + labels: | |
23 | + name: tb-node-cache-config | |
24 | +data: | |
25 | + CACHE_TYPE: redis | |
26 | + REDIS_CONNECTION_TYPE: cluster | |
27 | + REDIS_NODES: tb-redis:6379 | |
\ No newline at end of file | ... | ... |
k8s/high-availability/thirdparty.yml
renamed from
k8s/thirdparty.yml
... | ... | @@ -169,7 +169,7 @@ spec: |
169 | 169 | - name: KAFKA_CONTROLLER_SHUTDOWN_ENABLE |
170 | 170 | value: "true" |
171 | 171 | - name: KAFKA_CREATE_TOPICS |
172 | - value: "js_eval.requests:100:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb_transport.api.requests:30:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600" | |
172 | + value: "js_eval.requests:100:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb_transport.api.requests:30:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb_rule_engine:30:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600" | |
173 | 173 | - name: KAFKA_AUTO_CREATE_TOPICS_ENABLE |
174 | 174 | value: "false" |
175 | 175 | - name: KAFKA_LOG_RETENTION_BYTES | ... | ... |
... | ... | @@ -17,6 +17,9 @@ |
17 | 17 | |
18 | 18 | set -e |
19 | 19 | |
20 | +source .env | |
21 | + | |
20 | 22 | kubectl config set-context $(kubectl config current-context) --namespace=thingsboard |
21 | -kubectl delete -f thingsboard.yml | |
22 | -kubectl delete -f thirdparty.yml | |
23 | + | |
24 | +kubectl delete -f common/thingsboard.yml | |
25 | +kubectl delete -f common/tb-node.yml | ... | ... |
... | ... | @@ -17,10 +17,14 @@ |
17 | 17 | |
18 | 18 | set -e |
19 | 19 | |
20 | -kubectl apply -f tb-namespace.yml | |
20 | +source .env | |
21 | + | |
22 | +kubectl apply -f common/tb-namespace.yml | |
21 | 23 | kubectl config set-context $(kubectl config current-context) --namespace=thingsboard |
22 | -kubectl apply -f tb-node-configmap.yml | |
23 | -kubectl apply -f tb-mqtt-transport-configmap.yml | |
24 | -kubectl apply -f tb-http-transport-configmap.yml | |
25 | -kubectl apply -f tb-coap-transport-configmap.yml | |
26 | -kubectl apply -f thingsboard.yml | |
24 | +kubectl apply -f common/tb-node-configmap.yml | |
25 | +kubectl apply -f common/tb-mqtt-transport-configmap.yml | |
26 | +kubectl apply -f common/tb-http-transport-configmap.yml | |
27 | +kubectl apply -f common/tb-coap-transport-configmap.yml | |
28 | +kubectl apply -f common/thingsboard.yml | |
29 | +kubectl apply -f $DEPLOYMENT_TYPE/tb-node-cache-configmap.yml | |
30 | +kubectl apply -f common/tb-node.yml | ... | ... |
... | ... | @@ -17,6 +17,29 @@ |
17 | 17 | |
18 | 18 | set -e |
19 | 19 | |
20 | -kubectl apply -f tb-namespace.yml | |
20 | +source .env | |
21 | + | |
22 | +kubectl apply -f common/tb-namespace.yml | |
21 | 23 | kubectl config set-context $(kubectl config current-context) --namespace=thingsboard |
22 | -kubectl apply -f thirdparty.yml | |
24 | + | |
25 | +kubectl apply -f $DEPLOYMENT_TYPE/thirdparty.yml | |
26 | + | |
27 | + | |
28 | +if [ "$DEPLOYMENT_TYPE" == "high-availability" ]; then | |
29 | + echo -n "waiting for all redis pods to be ready"; | |
30 | + while [[ $(kubectl get pods tb-redis-5 -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}' 2>/dev/null) != "True" ]]; | |
31 | + do | |
32 | + echo -n "." && sleep 5; | |
33 | + done | |
34 | + | |
35 | + if [[ $(kubectl exec -it tb-redis-0 -- redis-cli cluster info 2>&1 | head -n 1) =~ "cluster_state:ok" ]] | |
36 | + then | |
37 | + echo "redis cluster is already configured" | |
38 | + else | |
39 | + echo "starting redis cluster" | |
40 | + redisNodes=$(kubectl get pods -l app=tb-redis -o jsonpath='{range.items[*]}{.status.podIP}:6379 ') | |
41 | + kubectl exec -it tb-redis-0 -- redis-cli --cluster create --cluster-replicas 1 $redisNodes | |
42 | + fi | |
43 | + | |
44 | +fi | |
45 | + | ... | ... |
... | ... | @@ -19,8 +19,8 @@ function installTb() { |
19 | 19 | |
20 | 20 | loadDemo=$1 |
21 | 21 | |
22 | - kubectl apply -f tb-node-configmap.yml | |
23 | - kubectl apply -f database-setup.yml && | |
22 | + kubectl apply -f common/tb-node-configmap.yml | |
23 | + kubectl apply -f common/database-setup.yml && | |
24 | 24 | kubectl wait --for=condition=Ready pod/tb-db-setup --timeout=120s && |
25 | 25 | kubectl exec tb-db-setup -- sh -c 'export INSTALL_TB=true; export LOAD_DEMO='"$loadDemo"'; start-tb-node.sh; touch /tmp/install-finished;' |
26 | 26 | |
... | ... | @@ -30,17 +30,19 @@ function installTb() { |
30 | 30 | |
31 | 31 | function installPostgres() { |
32 | 32 | |
33 | - kubectl apply -f postgres.yml | |
34 | - kubectl apply -f tb-node-postgres-configmap.yml | |
33 | + kubectl apply -f common/postgres.yml | |
34 | + kubectl apply -f common/tb-node-postgres-configmap.yml | |
35 | 35 | |
36 | 36 | kubectl rollout status deployment/postgres |
37 | 37 | } |
38 | 38 | |
39 | -function installCassandra() { | |
39 | +function installHybrid() { | |
40 | 40 | |
41 | - kubectl apply -f cassandra.yml | |
42 | - kubectl apply -f tb-node-cassandra-configmap.yml | |
41 | + kubectl apply -f common/postgres.yml | |
42 | + kubectl apply -f common/cassandra.yml | |
43 | + kubectl apply -f common/tb-node-hybrid-configmap.yml | |
43 | 44 | |
45 | + kubectl rollout status deployment/postgres | |
44 | 46 | kubectl rollout status statefulset/cassandra |
45 | 47 | |
46 | 48 | kubectl exec -it cassandra-0 -- bash -c "cqlsh -e \ |
... | ... | @@ -75,19 +77,30 @@ fi |
75 | 77 | |
76 | 78 | source .env |
77 | 79 | |
78 | -kubectl apply -f tb-namespace.yml | |
80 | +kubectl apply -f common/tb-namespace.yml | |
79 | 81 | kubectl config set-context $(kubectl config current-context) --namespace=thingsboard |
80 | 82 | |
83 | +case $DEPLOYMENT_TYPE in | |
84 | + basic) | |
85 | + ;; | |
86 | + high-availability) | |
87 | + ;; | |
88 | + *) | |
89 | + echo "Unknown DEPLOYMENT_TYPE value specified: '${DEPLOYMENT_TYPE}'. Should be either basic or high-availability." >&2 | |
90 | + exit 1 | |
91 | +esac | |
92 | + | |
81 | 93 | case $DATABASE in |
82 | 94 | postgres) |
83 | 95 | installPostgres |
84 | 96 | installTb ${loadDemo} |
85 | 97 | ;; |
86 | - cassandra) | |
87 | - installCassandra | |
98 | + hybrid) | |
99 | + installHybrid | |
88 | 100 | installTb ${loadDemo} |
89 | 101 | ;; |
90 | 102 | *) |
91 | - echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either postgres or cassandra." >&2 | |
103 | + echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either postgres or hybrid." >&2 | |
92 | 104 | exit 1 |
93 | 105 | esac |
106 | + | ... | ... |
... | ... | @@ -36,7 +36,7 @@ else |
36 | 36 | fromVersion="${FROM_VERSION// }" |
37 | 37 | fi |
38 | 38 | |
39 | -kubectl apply -f database-setup.yml && | |
39 | +kubectl apply -f common/database-setup.yml && | |
40 | 40 | kubectl wait --for=condition=Ready pod/tb-db-setup --timeout=120s && |
41 | 41 | kubectl exec tb-db-setup -- sh -c 'export UPGRADE_TB=true; export FROM_VERSION='"$fromVersion"'; start-tb-node.sh; touch /tmp/install-finished;' |
42 | 42 | ... | ... |
... | ... | @@ -1428,7 +1428,7 @@ |
1428 | 1428 | }, |
1429 | 1429 | "enabled": { |
1430 | 1430 | "version": "1.0.2", |
1431 | - "resolved": "http://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", | |
1431 | + "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", | |
1432 | 1432 | "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", |
1433 | 1433 | "requires": { |
1434 | 1434 | "env-variable": "0.0.x" |
... | ... | @@ -1779,7 +1779,7 @@ |
1779 | 1779 | }, |
1780 | 1780 | "fecha": { |
1781 | 1781 | "version": "2.3.3", |
1782 | - "resolved": "http://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", | |
1782 | + "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", | |
1783 | 1783 | "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" |
1784 | 1784 | }, |
1785 | 1785 | "file-stream-rotator": { |
... | ... | @@ -2486,7 +2486,7 @@ |
2486 | 2486 | }, |
2487 | 2487 | "get-stream": { |
2488 | 2488 | "version": "3.0.0", |
2489 | - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", | |
2489 | + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", | |
2490 | 2490 | "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", |
2491 | 2491 | "dev": true |
2492 | 2492 | }, |
... | ... | @@ -2611,7 +2611,7 @@ |
2611 | 2611 | }, |
2612 | 2612 | "got": { |
2613 | 2613 | "version": "6.7.1", |
2614 | - "resolved": "http://registry.npmjs.org/got/-/got-6.7.1.tgz", | |
2614 | + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", | |
2615 | 2615 | "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", |
2616 | 2616 | "dev": true, |
2617 | 2617 | "requires": { |
... | ... | @@ -2934,7 +2934,7 @@ |
2934 | 2934 | }, |
2935 | 2935 | "is-obj": { |
2936 | 2936 | "version": "1.0.1", |
2937 | - "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", | |
2937 | + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", | |
2938 | 2938 | "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", |
2939 | 2939 | "dev": true |
2940 | 2940 | }, |
... | ... | @@ -3618,7 +3618,7 @@ |
3618 | 3618 | }, |
3619 | 3619 | "path-is-absolute": { |
3620 | 3620 | "version": "1.0.1", |
3621 | - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", | |
3621 | + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", | |
3622 | 3622 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", |
3623 | 3623 | "dev": true |
3624 | 3624 | }, |
... | ... | @@ -4175,7 +4175,7 @@ |
4175 | 4175 | }, |
4176 | 4176 | "safe-regex": { |
4177 | 4177 | "version": "1.1.0", |
4178 | - "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", | |
4178 | + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", | |
4179 | 4179 | "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", |
4180 | 4180 | "dev": true, |
4181 | 4181 | "requires": { |
... | ... | @@ -4588,7 +4588,7 @@ |
4588 | 4588 | }, |
4589 | 4589 | "strip-eof": { |
4590 | 4590 | "version": "1.0.0", |
4591 | - "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", | |
4591 | + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", | |
4592 | 4592 | "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", |
4593 | 4593 | "dev": true |
4594 | 4594 | }, | ... | ... |
... | ... | @@ -4858,6 +4858,7 @@ |
4858 | 4858 | "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", |
4859 | 4859 | "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", |
4860 | 4860 | "dev": true, |
4861 | + "optional": true, | |
4861 | 4862 | "requires": { |
4862 | 4863 | "kind-of": "^6.0.0" |
4863 | 4864 | } |
... | ... | @@ -5751,6 +5752,7 @@ |
5751 | 5752 | "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", |
5752 | 5753 | "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", |
5753 | 5754 | "dev": true, |
5755 | + "optional": true, | |
5754 | 5756 | "requires": { |
5755 | 5757 | "kind-of": "^6.0.0" |
5756 | 5758 | } |
... | ... | @@ -5760,6 +5762,7 @@ |
5760 | 5762 | "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", |
5761 | 5763 | "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", |
5762 | 5764 | "dev": true, |
5765 | + "optional": true, | |
5763 | 5766 | "requires": { |
5764 | 5767 | "kind-of": "^6.0.0" |
5765 | 5768 | } |
... | ... | @@ -5882,6 +5885,7 @@ |
5882 | 5885 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", |
5883 | 5886 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", |
5884 | 5887 | "dev": true, |
5888 | + "optional": true, | |
5885 | 5889 | "requires": { |
5886 | 5890 | "ms": "2.0.0" |
5887 | 5891 | } |
... | ... | @@ -5968,6 +5972,7 @@ |
5968 | 5972 | "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", |
5969 | 5973 | "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", |
5970 | 5974 | "dev": true, |
5975 | + "optional": true, | |
5971 | 5976 | "requires": { |
5972 | 5977 | "find-up": "^4.0.0" |
5973 | 5978 | } | ... | ... |