From a994d458fc02f414e0e5160d9b1f1be7bbe9bcda Mon Sep 17 00:00:00 2001 From: Lusheng Ji Date: Thu, 26 Apr 2018 16:37:17 -0400 Subject: Fix Redis cluster initialization Issue-ID: DCAEGEN2-245 Change-Id: Ieb234a72897c5f307193cd998bcf64ce7658b700 Signed-off-by: Lusheng Ji --- .../resources/redis/scripts/redis-cluster-config.sh | 19 ++++++++++++++----- .../charts/dcae-redis/templates/statefulset.yaml | 3 +-- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'kubernetes/dcaegen2/charts/dcae-redis') diff --git a/kubernetes/dcaegen2/charts/dcae-redis/resources/redis/scripts/redis-cluster-config.sh b/kubernetes/dcaegen2/charts/dcae-redis/resources/redis/scripts/redis-cluster-config.sh index 3431e7e6e7..f4547525c9 100755 --- a/kubernetes/dcaegen2/charts/dcae-redis/resources/redis/scripts/redis-cluster-config.sh +++ b/kubernetes/dcaegen2/charts/dcae-redis/resources/redis/scripts/redis-cluster-config.sh @@ -15,8 +15,9 @@ # limitations under the License. # ============LICENSE_END========================================================= - -if [[ "$HOSTNAME" == *{{.Chart.Name}}-0 ]]; then +(if [[ "$HOSTNAME" == *{{.Chart.Name}}-0 ]]; then + echo "delay by 10 seconds for redis server starting" + sleep 10 NODES="" echo "====> wait for all {{.Values.replicaCount}} redis pods up" @@ -24,11 +25,16 @@ if [[ "$HOSTNAME" == *{{.Chart.Name}}-0 ]]; then do echo "======> $(echo $NODES |wc -w) / {{.Values.replicaCount}} pods up" sleep 5 - RESP=$(wget -vO- --ca-certificate /var/run/secrets/kubernetes.io/serviceaccount/ca.crt --header "Authorization: Bearer $( IPs: ["$IPS2"]" NODES="" - for I in $IPS; do NODES="$NODES $I:{{.Values.service.externalPort}}"; done + for I in $IPS2; do NODES="$NODES $I:{{.Values.service.externalPort}}"; done + echo "======> nodes: ["$NODES"]" done echo "====> all {{.Values.replicaCount}} redis cluster pods are up. wait 10 seconds before the next step"; echo sleep 10 @@ -36,6 +42,9 @@ if [[ "$HOSTNAME" == *{{.Chart.Name}}-0 ]]; then echo "====> Configure the cluster" # $NODES w/o quotes + echo "======> nodes: [$(echo $NODES |paste -s)]" redis-trib create --replicas 1 $(echo $NODES |paste -s) +fi ) & + +redis-server /conf/redis.conf -fi diff --git a/kubernetes/dcaegen2/charts/dcae-redis/templates/statefulset.yaml b/kubernetes/dcaegen2/charts/dcae-redis/templates/statefulset.yaml index 472471416b..63d921aa8b 100644 --- a/kubernetes/dcaegen2/charts/dcae-redis/templates/statefulset.yaml +++ b/kubernetes/dcaegen2/charts/dcae-redis/templates/statefulset.yaml @@ -41,8 +41,7 @@ spec: - /bin/sh - -c - | - /opt/scripts/redis-cluster-config.sh & - /usr/local/bin/redis-server-config.sh + /opt/scripts/redis-cluster-config.sh ports: - containerPort: {{ .Values.service.internalPort }} name: {{ .Values.service.name }} -- cgit 1.2.3-korg