From 3c5a88eaab5ab2a1a9ff625f1c0586d4cc148758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20C=20McCord?= Date: Wed, 20 Sep 2017 14:10:15 -0400 Subject: [PATCH] Wait for rollout status complete; abort on failure Fixes #9 --- update.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/update.sh b/update.sh index 98df6a9..60a9cf8 100755 --- a/update.sh +++ b/update.sh @@ -34,7 +34,19 @@ IFS=',' read -r -a CONTAINERS <<< "${PLUGIN_CONTAINER}" for DEPLOY in ${DEPLOYMENTS[@]}; do echo Deploying to $KUBERNETES_SERVER for CONTAINER in ${CONTAINERS[@]}; do + + # Collect the last revision number so we can track the next one + local LAST=$(kubectl -n ${PLUGIN_NAMESPACE} rollout history deployment/${DEPLOY} |grep -v '$^' |tail -n1 | awk '{print $1}') + + # Initiate the rolloout by modifying the image kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \ ${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG} --record + + # Wait for the rollout to complete + kubectl -n ${PLUGIN_NAMESPACE} rollout status -r $((++LAST)) --watch + if [ $? -ne 0 ]; then + echo "rollout of [${PLUGIN_NAMESPACE}]:deployment/${DEPLOY}/${CONTAINER} failed" + exit 1 + fi done done