From 94d88d795e88607d8f3997f55a0086f0f684e05a Mon Sep 17 00:00:00 2001 From: Devon Mackay Date: Sun, 12 Aug 2018 15:31:00 -0400 Subject: [PATCH] Add script for updating source image of ATST deploy --- deploy/kubernetes/atst-update-deploy.sh | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 deploy/kubernetes/atst-update-deploy.sh diff --git a/deploy/kubernetes/atst-update-deploy.sh b/deploy/kubernetes/atst-update-deploy.sh new file mode 100644 index 00000000..1ad9e9ee --- /dev/null +++ b/deploy/kubernetes/atst-update-deploy.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# deploy/kubernetes/atst-update-deploy.sh: Updates the existing ATST deployment +# with a new source image + +set -o pipefail +set -o errexit +set -o nounset +# set -o xtrace + +# Decode and save the K8S CA cert +echo "${K8S_CA_CRT}" | base64 --decode -i > "${HOME}/k8s_ca.crt" + +# Setup the local kubectl client +kubectl config set-cluster atat-cluster \ + --embed-certs=true \ + --server="${K8S_CLUSTER_ENDPOINT}" \ + --certificate-authority="${HOME}/k8s_ca.crt" + +kubectl config set-credentials atat-deployer --token="${K8S_USER_TOKEN}" + +kubectl config set-context travis \ + --cluster=atat-cluster \ + --user=atat-deployer \ + --namespace=atat + +kubectl config use-context travis +kubectl config current-context + +# Update the ATST deployment +kubectl set image deployment.apps/atst atst="${PROD_IMAGE_NAME}" + +# Remove the K8S CA file when the script exits +function cleanup { + printf "Cleaning up...\n" + rm -vf "${HOME}/k8s_ca.crt" + printf "Cleaning done." +} + +trap cleanup EXIT