thingsboard-aplcache
Changes
docker/cassandra-upgrade/Dockerfile 24(+24 -0)
docker/cassandra-upgrade/Makefile 12(+12 -0)
docker/cassandra-upgrade/upgrade.sh 28(+28 -0)
docker/k8s/cassandra-upgrade.yaml 43(+43 -0)
Details
docker/cassandra-upgrade/Dockerfile 24(+24 -0)
diff --git a/docker/cassandra-upgrade/Dockerfile b/docker/cassandra-upgrade/Dockerfile
new file mode 100644
index 0000000..312db0d
--- /dev/null
+++ b/docker/cassandra-upgrade/Dockerfile
@@ -0,0 +1,24 @@
+#
+# Copyright © 2016-2018 The Thingsboard Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+FROM openjdk:8-jre
+
+ADD upgrade.sh /upgrade.sh
+ADD thingsboard.deb /thingsboard.deb
+
+RUN apt-get update \
+ && apt-get install -y nmap \
+ && chmod +x /upgrade.sh
docker/cassandra-upgrade/Makefile 12(+12 -0)
diff --git a/docker/cassandra-upgrade/Makefile b/docker/cassandra-upgrade/Makefile
new file mode 100644
index 0000000..f4c6825
--- /dev/null
+++ b/docker/cassandra-upgrade/Makefile
@@ -0,0 +1,12 @@
+VERSION=2.0.3
+PROJECT=thingsboard
+APP=cassandra-upgrade
+
+build:
+ cp ../../application/target/thingsboard.deb .
+ docker build --pull -t ${PROJECT}/${APP}:${VERSION} -t ${PROJECT}/${APP}:latest .
+ rm thingsboard.deb
+
+push: build
+ docker push ${PROJECT}/${APP}:${VERSION}
+ docker push ${PROJECT}/${APP}:latest
docker/cassandra-upgrade/upgrade.sh 28(+28 -0)
diff --git a/docker/cassandra-upgrade/upgrade.sh b/docker/cassandra-upgrade/upgrade.sh
new file mode 100755
index 0000000..dac4919
--- /dev/null
+++ b/docker/cassandra-upgrade/upgrade.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Copyright © 2016-2018 The Thingsboard Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+dpkg -i /thingsboard.deb
+
+until nmap $CASSANDRA_HOST -p $CASSANDRA_PORT | grep "$CASSANDRA_PORT/tcp open"
+do
+ echo "Wait for cassandra db to start..."
+ sleep 10
+done
+
+echo "Upgrading 'Thingsboard' schema..."
+/usr/share/thingsboard/bin/install/upgrade.sh --fromVersion=$UPGRADE_FROM_VERSION
docker/k8s/cassandra-upgrade.yaml 43(+43 -0)
diff --git a/docker/k8s/cassandra-upgrade.yaml b/docker/k8s/cassandra-upgrade.yaml
new file mode 100644
index 0000000..881c5b8
--- /dev/null
+++ b/docker/k8s/cassandra-upgrade.yaml
@@ -0,0 +1,43 @@
+#
+# Copyright © 2016-2018 The Thingsboard Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+apiVersion: v1
+kind: Pod
+metadata:
+ name: cassandra-upgrade
+spec:
+ containers:
+ - name: cassandra-upgrade
+ imagePullPolicy: Always
+ image: thingsboard/cassandra-upgrade:2.0.3
+ env:
+ - name: ADD_DEMO_DATA
+ value: "true"
+ - name : CASSANDRA_HOST
+ value: "cassandra-headless"
+ - name : CASSANDRA_PORT
+ value: "9042"
+ - name : DATABASE_TYPE
+ value: "cassandra"
+ - name : CASSANDRA_URL
+ value: "cassandra-headless:9042"
+ - name : UPGRADE_FROM_VERSION
+ value: "1.4.0"
+ command:
+ - sh
+ - -c
+ - /upgrade.sh
+ restartPolicy: Never