blob: 29ab84397dab3397764d9b73fe063aa994ac99b1 [file] [log] [blame]
Lusheng Ji649d2422018-03-25 00:21:12 -04001#!/bin/bash
2# ================================================================================
3# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
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# ============LICENSE_END=========================================================
17
18
19if [[ "$HOSTNAME" == *redis-cluster-0 ]]; then
20 {
21 NODES=""
22 echo "====> wait for all 6 redis pods up"
23 while [ "$(echo $NODES | wc -w)" -lt 6 ]
24 do
25 echo "======> $(echo $NODES |wc -w) / 6 pods up"
26 sleep 5
27 RESP=$(wget -vO- --ca-certificate /var/run/secrets/kubernetes.io/serviceaccount/ca.crt --header "Authorization: Bearer $(</var/run/secrets/kubernetes.io/serviceaccount/token)" https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/default/pods?labelSelector=name=onap-dcaegen2-redis-cluster)
28 NODES=$(echo $RESP | jq -r '.items[].status.podIP + ":6379"')
29 done
30 echo "====> all 6 redis cluster pods are up. wait 10 seconds before the next step"; echo
31 sleep 10
32
33 echo "====> Configure the cluster"
34
35 # we might want NODES w/o quotes
36 redis-trib create --replicas 1 $NODES
37 } &
38fi
39
40redis-server