From b54e3147c3f847666288e048b4843c38f5aaab2a Mon Sep 17 00:00:00 2001 From: dandds Date: Fri, 30 Nov 2018 11:32:14 -0500 Subject: [PATCH] try scheduling nightly deploys for test env with CircleCI config --- .circleci/config.yml | 28 +++++++++++++++++++++++++ deploy/kubernetes/atst-update-deploy.sh | 16 +++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e17a8f4..43ecbd83 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -195,6 +195,19 @@ jobs: name: "Update Kubernetes Deployment" command: ./deploy/kubernetes/atst-update-deploy.sh + deploy_test: + docker: + - image: *sourceImage + auth: *sourceAuth + environment: *dockerCmdEnvironment + working_directory: *workingDirectory + steps: + - attach_workspace: + at: . + - run: + name: "Update Kubernetes Deployment" + command: ./deploy/kubernetes/atst-update-deploy.sh atat-test + workflows: version: 2 run-tests: @@ -215,3 +228,18 @@ workflows: filters: branches: only: master + nightly: + triggers: + - schedule: + cron: "0 0 * * *" + filters: + branches: + only: + - master + jobs: + - deploy_test: + requires: + - build_and_push_image + filters: + branches: + only: master diff --git a/deploy/kubernetes/atst-update-deploy.sh b/deploy/kubernetes/atst-update-deploy.sh index ff6d93e7..ed4ce0ce 100755 --- a/deploy/kubernetes/atst-update-deploy.sh +++ b/deploy/kubernetes/atst-update-deploy.sh @@ -11,6 +11,12 @@ set -o nounset # Config MAX_DEPLOY_WAIT='300' +if [[ $# -eq 0 ]]; then + NAMESPACE=atat +else + NAMESPACE=$1 +fi + if [ "${IMAGE_NAME}x" = "x" ] then IMAGE_NAME="${ATAT_DOCKER_REGISTRY_URL}/${PROD_IMAGE_NAME}:${GIT_SHA}" @@ -44,15 +50,15 @@ kubectl config use-context atst-deployer kubectl config current-context # Update the ATST deployment -kubectl -n atat set image deployment.apps/atst atst="${IMAGE_NAME}" -kubectl -n atat set image deployment.apps/atst-worker atst-worker="${IMAGE_NAME}" +kubectl -n ${NAMESPACE} set image deployment.apps/atst atst="${IMAGE_NAME}" +kubectl -n ${NAMESPACE} set image deployment.apps/atst-worker atst-worker="${IMAGE_NAME}" # Wait for deployment to finish -if ! timeout -t "${MAX_DEPLOY_WAIT}" -s INT kubectl -n atat rollout status deployment/atst +if ! timeout -t "${MAX_DEPLOY_WAIT}" -s INT kubectl -n ${NAMESPACE} rollout status deployment/atst then # Deploy did not finish before max wait time; abort and rollback the deploy - kubectl -n atat rollout undo deployment/atst - kubectl -n atat rollout undo deployment/atst-worker + kubectl -n ${NAMESPACE} rollout undo deployment/atst + kubectl -n ${NAMESPACE} rollout undo deployment/atst-worker # Exit with a non-zero return code exit 2 fi