Added commands for creating Redis cluster in k8s-deploy-thirdparty.sh

This commit is contained in:
viktor 2020-05-27 15:40:57 +03:00
parent 53b240a72b
commit 7c72233387
3 changed files with 22 additions and 14 deletions

View File

@ -1,6 +1,6 @@
# Can be either basic (with single instance of Zookeeper, Kafka and Redis) or high-availability (with Zookeeper, Kafka and Redis in cluster modes).
# According to the deployment type corresponding kubernetes resources will be deployed (see content of the directories ./basic and ./high-availability for details).
DEPLOYMENT_TYPE=basic
DEPLOYMENT_TYPE=high-availability
# Database used by ThingsBoard, can be either postgres (PostgreSQL) or cassandra (Cassandra).
# According to the database type corresponding kubernetes resources will be deployed (see postgres.yml, cassandra.yml for details).

View File

@ -53,19 +53,7 @@ Execute the following command to deploy thirdparty resources:
$ ./k8s-deploy-thirdparty.sh
`
Get list of the running tb-redis pods and verify that all of them are in running state:
`
$ kubectl get pods -l app=tb-redis
`
If you are running ThingsBoard in `high-availability` `DEPLOYMENT_TYPE` execute the following command to create redis cluster:
`
$ 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 ')
`
Type **'yes'** when prompted.
Type **'yes'** when prompted, if you are running ThingsBoard in `high-availability` `DEPLOYMENT_TYPE` for the first time and don't configured Redis cluster.
Execute the following command to deploy resources:

View File

@ -23,3 +23,23 @@ kubectl apply -f common/tb-namespace.yml
kubectl config set-context $(kubectl config current-context) --namespace=thingsboard
kubectl apply -f $DEPLOYMENT_TYPE/thirdparty.yml
if [ "$DEPLOYMENT_TYPE" == "high-availability" ]; then
echo -n "waiting for all redis pods to be ready";
while [[ $(kubectl get pods tb-redis-5 -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}' 2>/dev/null) != "True" ]];
do
echo -n "." && sleep 5;
done
if [[ $(kubectl exec -it tb-redis-0 -- redis-cli cluster info 2>&1 | head -n 1) =~ "cluster_state:ok" ]]
then
echo "redis cluster is already configured"
else
echo "starting redis cluster"
redisNodes=$(kubectl get pods -l app=tb-redis -o jsonpath='{range.items[*]}{.status.podIP}:6379 ')
kubectl exec -it tb-redis-0 -- redis-cli --cluster create --cluster-replicas 1 $redisNodes
fi
fi