Add handling environments

This commit is contained in:
Charles Martinot 2017-02-07 14:09:44 +08:00
parent 26454722a6
commit 3042727362
2 changed files with 37 additions and 3 deletions

View File

@ -12,9 +12,35 @@ This pipeline will update the `my-deployment` deployment with the image tagged `
deployment: my-deployment deployment: my-deployment
repo: myorg/myrepo repo: myorg/myrepo
container: my-container container: my-container
namespace: default
tag: ${DRONE_COMMIT_SHA:8} 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:
deploy-staging:
image: quay.io/honestbee/drone-kubernetes
kubernetes_server: ${KUBERNETES_SERVER_STAGING}
kubernetes_token: ${KUBERNETES_TOKEN_STAGING}
deployment: my-deployment
repo: myorg/myrepo
container: my-container
namespace: app
tag: ${DRONE_COMMIT_SHA:8}
when:
branch: [ staging ]
deploy-prod:
image: quay.io/honestbee/drone-kubernetes
kubernetes_server: ${KUBERNETES_SERVER_PROD}
kubernetes_token: ${KUBERNETES_TOKEN_PROD}
deployment: my-deployment
repo: myorg/myrepo
container: my-container
namespace: app
tag: ${DRONE_COMMIT_SHA:8}
when:
branch: [ master ]
## Required secrets ## Required secrets
drone secret add --image=honestbee/drone-kubernetes \ drone secret add --image=honestbee/drone-kubernetes \

View File

@ -4,8 +4,16 @@ if [ -z ${PLUGIN_NAMESPACE} ]; then
PLUGIN_NAMESPACE="default" PLUGIN_NAMESPACE="default"
fi fi
kubectl config set-credentials default --token=${KUBERNETES_TOKEN} if [ -z PLUGIN_KUBERNETES_TOKEN ]; then
kubectl config set-cluster default --server=${KUBERNETES_SERVER} --insecure-skip-tls-verify=true PLUGIN_KUBERNETES_TOKEN = $KUBERNETES_TOKEN
fi
if [ -z PLUGIN_KUBERNETES_SERVER ]; then
PLUGIN_KUBERNETES_SERVER = $KUBERNETES_SERVER
fi
kubectl config set-credentials default --token=${PLUGIN_KUBERNETES_TOKEN}
kubectl config set-cluster default --server=${PLUGIN_KUBERNETES_SERVER} --insecure-skip-tls-verify=true
kubectl config set-context default --cluster=default --user=default kubectl config set-context default --cluster=default --user=default
kubectl config use-context default kubectl config use-context default
kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${PLUGIN_DEPLOYMENT} ${PLUGIN_CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG} kubectl -n ${PLUGIN_NAMESPACE} set image deployment/${PLUGIN_DEPLOYMENT} ${PLUGIN_CONTAINER}=${PLUGIN_REPO}:${PLUGIN_TAG}