Commit ed7623af2c968484cbc27b2413cc0db6578f9276

Authored by Volodymyr Babak
1 parent 60046e83

Added cassandra upgrade docker image and kubernetes yaml file

  1 +#
  2 +# Copyright © 2016-2018 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 +FROM openjdk:8-jre
  18 +
  19 +ADD upgrade.sh /upgrade.sh
  20 +ADD thingsboard.deb /thingsboard.deb
  21 +
  22 +RUN apt-get update \
  23 + && apt-get install -y nmap \
  24 + && chmod +x /upgrade.sh
... ...
  1 +VERSION=2.0.3
  2 +PROJECT=thingsboard
  3 +APP=cassandra-upgrade
  4 +
  5 +build:
  6 + cp ../../application/target/thingsboard.deb .
  7 + docker build --pull -t ${PROJECT}/${APP}:${VERSION} -t ${PROJECT}/${APP}:latest .
  8 + rm thingsboard.deb
  9 +
  10 +push: build
  11 + docker push ${PROJECT}/${APP}:${VERSION}
  12 + docker push ${PROJECT}/${APP}:latest
... ...
  1 +#!/bin/bash
  2 +#
  3 +# Copyright © 2016-2018 The Thingsboard Authors
  4 +#
  5 +# Licensed under the Apache License, Version 2.0 (the "License");
  6 +# you may not use this file except in compliance with the License.
  7 +# You may obtain a copy of the License at
  8 +#
  9 +# http://www.apache.org/licenses/LICENSE-2.0
  10 +#
  11 +# Unless required by applicable law or agreed to in writing, software
  12 +# distributed under the License is distributed on an "AS IS" BASIS,
  13 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 +# See the License for the specific language governing permissions and
  15 +# limitations under the License.
  16 +#
  17 +
  18 +
  19 +dpkg -i /thingsboard.deb
  20 +
  21 +until nmap $CASSANDRA_HOST -p $CASSANDRA_PORT | grep "$CASSANDRA_PORT/tcp open"
  22 +do
  23 + echo "Wait for cassandra db to start..."
  24 + sleep 10
  25 +done
  26 +
  27 +echo "Upgrading 'Thingsboard' schema..."
  28 +/usr/share/thingsboard/bin/install/upgrade.sh --fromVersion=$UPGRADE_FROM_VERSION
... ...
  1 +#
  2 +# Copyright © 2016-2018 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: Pod
  19 +metadata:
  20 + name: cassandra-upgrade
  21 +spec:
  22 + containers:
  23 + - name: cassandra-upgrade
  24 + imagePullPolicy: Always
  25 + image: thingsboard/cassandra-upgrade:2.0.3
  26 + env:
  27 + - name: ADD_DEMO_DATA
  28 + value: "true"
  29 + - name : CASSANDRA_HOST
  30 + value: "cassandra-headless"
  31 + - name : CASSANDRA_PORT
  32 + value: "9042"
  33 + - name : DATABASE_TYPE
  34 + value: "cassandra"
  35 + - name : CASSANDRA_URL
  36 + value: "cassandra-headless:9042"
  37 + - name : UPGRADE_FROM_VERSION
  38 + value: "1.4.0"
  39 + command:
  40 + - sh
  41 + - -c
  42 + - /upgrade.sh
  43 + restartPolicy: Never
... ...