2017-02-08 06:04:53 +00:00
|
|
|
#!/bin/bash
|
2017-01-13 10:07:48 +00:00
|
|
|
|
2019-05-30 17:15:32 +00:00
|
|
|
if [[ -z ${PLUGIN_NAMESPACE} ]]; then
|
2017-01-16 02:00:29 +00:00
|
|
|
PLUGIN_NAMESPACE="default"
|
|
|
|
fi
|
|
|
|
|
2019-05-30 17:15:32 +00:00
|
|
|
if [[ -z ${PLUGIN_KUBERNETES_USER} ]]; then
|
2018-04-06 10:39:06 +00:00
|
|
|
PLUGIN_KUBERNETES_USER="default"
|
|
|
|
fi
|
|
|
|
|
2019-05-30 17:15:32 +00:00
|
|
|
if [[ ! -z ${PLUGIN_KUBERNETES_TOKEN} ]]; then
|
2017-02-08 02:49:32 +00:00
|
|
|
KUBERNETES_TOKEN=$PLUGIN_KUBERNETES_TOKEN
|
2017-02-07 06:09:44 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-30 17:15:32 +00:00
|
|
|
if [[ ! -z ${PLUGIN_KUBERNETES_SERVER} ]]; then
|
2017-02-08 02:49:32 +00:00
|
|
|
KUBERNETES_SERVER=$PLUGIN_KUBERNETES_SERVER
|
2017-02-07 06:09:44 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-30 17:15:32 +00:00
|
|
|
if [[ ! -z ${PLUGIN_KUBERNETES_CERT} ]]; then
|
2017-02-20 10:06:46 +00:00
|
|
|
KUBERNETES_CERT=${PLUGIN_KUBERNETES_CERT}
|
|
|
|
fi
|
|
|
|
|
|
|
|
kubectl config set-credentials default --token=${KUBERNETES_TOKEN}
|
2019-05-30 17:15:32 +00:00
|
|
|
if [[ ! -z ${KUBERNETES_CERT} ]]; then
|
2017-02-20 10:20:47 +00:00
|
|
|
echo ${KUBERNETES_CERT} | base64 -d > ca.crt
|
2017-02-20 09:22:24 +00:00
|
|
|
kubectl config set-cluster default --server=${KUBERNETES_SERVER} --certificate-authority=ca.crt
|
|
|
|
else
|
2017-02-20 10:20:47 +00:00
|
|
|
echo "WARNING: Using insecure connection to cluster"
|
2017-02-20 09:22:24 +00:00
|
|
|
kubectl config set-cluster default --server=${KUBERNETES_SERVER} --insecure-skip-tls-verify=true
|
|
|
|
fi
|
|
|
|
|
2018-04-06 10:39:06 +00:00
|
|
|
kubectl config set-context default --cluster=default --user=${PLUGIN_KUBERNETES_USER}
|
2017-01-13 10:07:48 +00:00
|
|
|
kubectl config use-context default
|
2017-02-20 10:20:47 +00:00
|
|
|
|
2017-02-20 11:08:45 +00:00
|
|
|
# kubectl version
|
2017-03-07 09:53:50 +00:00
|
|
|
IFS=',' read -r -a DEPLOYMENTS <<< "${PLUGIN_DEPLOYMENT}"
|
|
|
|
IFS=',' read -r -a CONTAINERS <<< "${PLUGIN_CONTAINER}"
|
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-03-07 09:53:50 +00:00
|
|
|
for CONTAINER in ${CONTAINERS[@]}; do
|
2018-04-06 10:39:06 +00:00
|
|
|
if [[ ${PLUGIN_FORCE} == "true" ]]; then
|
|
|
|
kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \
|
|
|
|
${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG}FORCE
|
|
|
|
fi
|
2017-03-07 09:53:50 +00:00
|
|
|
kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \
|
2017-05-10 02:50:51 +00:00
|
|
|
${CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG} --record
|
2017-03-07 09:53:50 +00:00
|
|
|
done
|
2017-02-08 05:45:22 +00:00
|
|
|
done
|