From 3416aee7d52557ff7f54c02b2565fdf266fb159b Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Mon, 2 Jul 2018 12:41:33 -0700 Subject: [PATCH] k8s/cartservice: add init container to wait redis otherwise nullpointerexception persists Signed-off-by: Ahmet Alp Balkan --- kubernetes-manifests/cartservice.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kubernetes-manifests/cartservice.yaml b/kubernetes-manifests/cartservice.yaml index 4d40548..ca2f649 100644 --- a/kubernetes-manifests/cartservice.yaml +++ b/kubernetes-manifests/cartservice.yaml @@ -8,6 +8,20 @@ spec: labels: app: cartservice spec: + terminationGracePeriodSeconds: 5 + initContainers: + - name: wait-redis + image: redis:alpine + command: ['sh', '-c', 'set -x; + until timeout -t 5 redis-cli -h "${REDIS_HOST}" -p "${REDIS_PORT}" ping; do + echo "waiting for redis at ${REDIS_HOST}:${REDIS_PORT}..."; + sleep 2; + done;'] + env: + - name: REDIS_HOST + value: "redis-cart" + - name: REDIS_PORT + value: "6379" containers: - name: server image: cartservice