drone-kubernetes/update.sh

26 lines
794 B
Bash
Raw Normal View History

2017-02-08 06:04:53 +00:00
#!/bin/bash
2017-01-13 10:07:48 +00:00
2017-01-16 02:00:29 +00:00
if [ -z ${PLUGIN_NAMESPACE} ]; then
PLUGIN_NAMESPACE="default"
fi
2017-02-08 02:49:32 +00:00
if [ ! -z ${PLUGIN_KUBERNETES_TOKEN} ]; then
KUBERNETES_TOKEN=$PLUGIN_KUBERNETES_TOKEN
2017-02-07 06:09:44 +00:00
fi
2017-02-08 02:49:32 +00:00
if [ ! -z ${PLUGIN_KUBERNETES_SERVER} ]; then
KUBERNETES_SERVER=$PLUGIN_KUBERNETES_SERVER
2017-02-07 06:09:44 +00:00
fi
2017-02-08 02:49:32 +00:00
kubectl config set-credentials default --token=${KUBERNETES_TOKEN}
kubectl config set-cluster default --server=${KUBERNETES_SERVER} --insecure-skip-tls-verify=true
2017-01-13 10:07:48 +00:00
kubectl config set-context default --cluster=default --user=default
kubectl config use-context default
2017-02-08 05:45:22 +00:00
IFS=',' read -r -a DEPLOYMENTS <<< "$PLUGIN_DEPLOYMENT"
2017-02-08 06:22:54 +00:00
for DEPLOY in ${DEPLOYMENTS[@]}; do
2017-02-08 07:39:11 +00:00
echo Deploying to $KUBERNETES_SERVER
2017-02-08 05:45:22 +00:00
kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \
${PLUGIN_CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG}
done