Allows a drone user to update a statefulset

This commit is contained in:
Jorge M 2020-09-15 21:28:44 -05:00
parent a5776c44e9
commit f9a988af29
1 changed files with 38 additions and 13 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
set -e
if [ -z ${PLUGIN_NAMESPACE} ]; then if [ -z ${PLUGIN_NAMESPACE} ]; then
PLUGIN_NAMESPACE="default" PLUGIN_NAMESPACE="default"
fi fi
@ -33,16 +35,39 @@ kubectl config set-context default --cluster=default --user=${PLUGIN_KUBERNETES_
kubectl config use-context default kubectl config use-context default
# kubectl version # kubectl version
IFS=',' read -r -a DEPLOYMENTS <<< "${PLUGIN_DEPLOYMENT}" if [ ! -z ${PLUGIN_USE_STATEFULSET} ]; then
IFS=',' read -r -a CONTAINERS <<< "${PLUGIN_CONTAINER}" echo "WARNING: Currently updating statefulset ${PLUGIN_STATEFULSET}."
for DEPLOY in ${DEPLOYMENTS[@]}; do
echo Deploying to $KUBERNETES_SERVER IFS=',' read -r -a DEPLOYMENTS <<< "${PLUGIN_STATEFULSET}"
for CONTAINER in ${CONTAINERS[@]}; do IFS=',' read -r -a CONTAINERS <<< "${PLUGIN_CONTAINER}"
if [[ ${PLUGIN_FORCE} == "true" ]]; then for DEPLOY in ${DEPLOYMENTS[@]}; do
kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \ echo Deploying to $KUBERNETES_SERVER
${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG}FORCE for CONTAINER in ${CONTAINERS[@]}; do
fi if [[ ${PLUGIN_FORCE} == "true" ]]; then
kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \ kubectl -n ${PLUGIN_NAMESPACE} set image statefulset/${DEPLOY} \
${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG} --record ${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG}FORCE
done fi
done kubectl -n ${PLUGIN_NAMESPACE} set image statefulset/${DEPLOY} \
${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG} --record
done
done
else
echo "WARNING: Currently updating deployment ${PLUGIN_DEPLOYMENT}"
IFS=',' read -r -a DEPLOYMENTS <<< "${PLUGIN_DEPLOYMENT}"
IFS=',' read -r -a CONTAINERS <<< "${PLUGIN_CONTAINER}"
for DEPLOY in ${DEPLOYMENTS[@]}; do
echo Deploying to $KUBERNETES_SERVER
for CONTAINER in ${CONTAINERS[@]}; do
if [[ ${PLUGIN_FORCE} == "true" ]]; then
kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \
${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG}FORCE
fi
kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \
${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG} --record
done
done
fi