From 4dd07c4a7375e3b0b42743b085151e14242cec64 Mon Sep 17 00:00:00 2001 From: Charles Martinot Date: Wed, 8 Feb 2017 13:45:22 +0800 Subject: [PATCH] Handle arrays in deployment --- README.md | 10 ++++++++++ update.sh | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f24034..4950d8f 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,16 @@ This pipeline will update the `my-deployment` deployment with the image tagged ` container: my-container tag: ${DRONE_COMMIT_SHA:8} +Deploying several new containers, eg in a scheduler-worker setup. + + pipeline: + deploy: + image: quay.io/honestbee/drone-kubernetes + deployment: [server-deploy, worker-deploy] + repo: myorg/myrepo + container: my-container + tag: ${DRONE_COMMIT_SHA:8} + This more complex example demonstrates how to deploy to several environments based on the branch, in a `app` namespace pipeline: diff --git a/update.sh b/update.sh index 44ef4c1..7234dcc 100644 --- a/update.sh +++ b/update.sh @@ -16,4 +16,9 @@ kubectl config set-credentials default --token=${KUBERNETES_TOKEN} kubectl config set-cluster default --server=${KUBERNETES_SERVER} --insecure-skip-tls-verify=true kubectl config set-context default --cluster=default --user=default kubectl config use-context default -kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${PLUGIN_DEPLOYMENT} ${PLUGIN_CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG} + +DEPLOYMENTS=$(echo $PLUGIN_DEPLOYMENT|tr -d '[],') +for DEPLOY in ${DEPLOYMENTS[@]}; do + kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${DEPLOY} \ + ${PLUGIN_CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG} +done