Wait for rollout status complete; abort on failure

Fixes #9
This commit is contained in:
Seán C McCord 2017-09-20 14:10:15 -04:00
parent 03f15d59ca
commit 3c5a88eaab
1 changed files with 12 additions and 0 deletions

View File

@ -34,7 +34,19 @@ IFS=',' read -r -a CONTAINERS <<< "${PLUGIN_CONTAINER}"
for DEPLOY in ${DEPLOYMENTS[@]}; do for DEPLOY in ${DEPLOYMENTS[@]}; do
echo Deploying to $KUBERNETES_SERVER echo Deploying to $KUBERNETES_SERVER
for CONTAINER in ${CONTAINERS[@]}; do 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} \ kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \
${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG} --record ${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
done done