try scheduling nightly deploys for test env with CircleCI config

This commit is contained in:
dandds 2018-11-30 11:32:14 -05:00
parent 23294b2e2b
commit b54e3147c3
2 changed files with 39 additions and 5 deletions

View File

@ -195,6 +195,19 @@ jobs:
name: "Update Kubernetes Deployment" name: "Update Kubernetes Deployment"
command: ./deploy/kubernetes/atst-update-deploy.sh 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: workflows:
version: 2 version: 2
run-tests: run-tests:
@ -215,3 +228,18 @@ workflows:
filters: filters:
branches: branches:
only: master only: master
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs:
- deploy_test:
requires:
- build_and_push_image
filters:
branches:
only: master

View File

@ -11,6 +11,12 @@ set -o nounset
# Config # Config
MAX_DEPLOY_WAIT='300' MAX_DEPLOY_WAIT='300'
if [[ $# -eq 0 ]]; then
NAMESPACE=atat
else
NAMESPACE=$1
fi
if [ "${IMAGE_NAME}x" = "x" ] if [ "${IMAGE_NAME}x" = "x" ]
then then
IMAGE_NAME="${ATAT_DOCKER_REGISTRY_URL}/${PROD_IMAGE_NAME}:${GIT_SHA}" 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 kubectl config current-context
# Update the ATST deployment # Update the ATST deployment
kubectl -n atat set image deployment.apps/atst atst="${IMAGE_NAME}" kubectl -n ${NAMESPACE} 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-worker atst-worker="${IMAGE_NAME}"
# Wait for deployment to finish # 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 then
# Deploy did not finish before max wait time; abort and rollback the deploy # Deploy did not finish before max wait time; abort and rollback the deploy
kubectl -n atat rollout undo deployment/atst kubectl -n ${NAMESPACE} rollout undo deployment/atst
kubectl -n atat rollout undo deployment/atst-worker kubectl -n ${NAMESPACE} rollout undo deployment/atst-worker
# Exit with a non-zero return code # Exit with a non-zero return code
exit 2 exit 2
fi fi