From fc53d1264a504073e290a1da37e0d78f252d4f9e Mon Sep 17 00:00:00 2001 From: vladyslavtk Date: Tue, 3 Oct 2023 17:23:37 +0300 Subject: [PATCH] Update int/prod deploy scripts and docs --- DEPLOY_ABBREVIATOR.md | 28 +++++++--------------------- DEPLOY_VIEWER.md | 8 ++++++++ scripts/deploy-to-env.sh | 18 +++++++++--------- scripts/deploy_viewer.sh | 8 ++------ 4 files changed, 26 insertions(+), 36 deletions(-) diff --git a/DEPLOY_ABBREVIATOR.md b/DEPLOY_ABBREVIATOR.md index b54cd06f4..21d5feee8 100644 --- a/DEPLOY_ABBREVIATOR.md +++ b/DEPLOY_ABBREVIATOR.md @@ -17,24 +17,10 @@ The data is stored in a sqlite db located in a shared NFS drive. 2. Create a tag starting with `int` or `prod` to trigger the GitHub action to build and push a docker image to `camptocamp/abbreviator` on [dockerhub](https://hub.docker.com/repository/docker/camptocamp/abbreviator). -3. Redeploy the instances on Fargate. - - The aws credentials are stored in the [ngm gopass password store](https://git.swisstopo.admin.ch/ngm/password-store-ngm). - - ```bash - export AWS_REGION=eu-west-1 - export AWS_ACCESS_KEY_ID=$(gopass cat ngm/fargate/urlshortener/AWS_ACCESS_KEY_ID) - export AWS_SECRET_ACCESS_KEY=$(gopass cat ngm/fargate/urlshortener/AWS_SECRET_ACCESS_KEY) - ``` - - ```bash - # development - aws ecs update-service --cluster urlshortener_dev --service urlshortener_dev --force-new-deployment - watch --interval=5 curl -s https://link.dev-viewer.swissgeol.ch/health_check - # integration - aws ecs update-service --cluster urlshortener_int --service urlshortener_int --force-new-deployment - watch --interval=5 curl -s https://link.int-viewer.swissgeol.ch/health_check - # production - aws ecs update-service --cluster urlshortener_prod --service urlshortener_prod --force-new-deployment - watch --interval=5 curl -s https://link.swissgeol.ch/health_check - ``` +3. Update version in argocd: + 1. Go to [argocd repo](https://git.swisstopo.admin.ch/ngm/argocd) + 2. Checkout branch according to environment (dev / int / prod) + 3. Update image version in apps/urlshortener/values.yaml + 4. Trigger sync in [argocd dashboard](https://dev-argocd.swissgeol.ch/applications) + + ``` diff --git a/DEPLOY_VIEWER.md b/DEPLOY_VIEWER.md index a04596495..d08cd5294 100644 --- a/DEPLOY_VIEWER.md +++ b/DEPLOY_VIEWER.md @@ -87,6 +87,8 @@ git checkout $VERSION scripts/deploy_viewer.sh int ``` +Go to the [ArgoCD dashboard](#argocd) to check if everything went well. + ### Prod-viewer (manual) The version should have been created and tested on int first. @@ -96,6 +98,12 @@ export VERSION="" # the version (like 2022.02.0) git checkout $VERSION scripts/deploy_viewer.sh prod ``` +Go to the [ArgoCD dashboard](#argocd) to check if everything went well. + +## Argo CD + +* Argo CD dashboard: https://dev-argocd.swissgeol.ch/applications +* Argo CD repository: https://git.swisstopo.admin.ch/ngm/argocd/ ## Invalidating some paths from cloudfront diff --git a/scripts/deploy-to-env.sh b/scripts/deploy-to-env.sh index abfea0f65..a37a9bc05 100755 --- a/scripts/deploy-to-env.sh +++ b/scripts/deploy-to-env.sh @@ -61,14 +61,14 @@ THE_TAG="${target}_`date +'%Y-%m-%d'`_$VERSION" cd ../ rm -rf argocd -#if [[ -n $CI ]] -#then -# echo "In CI: skipping argocd SYNC (auto-sync enabled)" -#else -# # Ask argocd to sync the app -# ARGOCD_SERVER="dev-argocd.swissgeol.ch" -# echo argocd login --sso $ARGOCD_SERVER -# argocd --grpc-web app sync api-${target} --prune --force --server $ARGOCD_SERVER -#fi +if [[ -n $CI ]] +then + echo "In CI: skipping argocd SYNC (auto-sync enabled)" +else + # Ask argocd to sync the app + ARGOCD_SERVER="dev-argocd.swissgeol.ch" + echo argocd login --sso $ARGOCD_SERVER + argocd --grpc-web app sync api-${target} --prune --force --server $ARGOCD_SERVER +fi echo "the end" diff --git a/scripts/deploy_viewer.sh b/scripts/deploy_viewer.sh index 3c1c0b3fe..4b8185e01 100755 --- a/scripts/deploy_viewer.sh +++ b/scripts/deploy_viewer.sh @@ -43,12 +43,10 @@ function deploy_ui { function deploy_api { tag="$1" - export AWS_ACCESS_KEY_ID=$(gopass cat ngm/fargate/api/AWS_ACCESS_KEY_ID) - export AWS_SECRET_ACCESS_KEY=$(gopass cat ngm/fargate/api/AWS_SECRET_ACCESS_KEY) docker pull $IMAGE_NAME:$VERSION docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:$tag docker push $IMAGE_NAME:$tag - aws ecs update-service --region $AWS_REGION --cluster api_$tag --service api_$tag --force-new-deployment + ./deploy-to-env "$1" } @@ -73,9 +71,7 @@ fi if [[ "$1" == "dev" ]] then echo "Special api-only deploy" - export AWS_ACCESS_KEY_ID=$(gopass cat ngm/fargate/api/AWS_ACCESS_KEY_ID) - export AWS_SECRET_ACCESS_KEY=$(gopass cat ngm/fargate/api/AWS_SECRET_ACCESS_KEY) - aws ecs update-service --region $AWS_REGION --cluster api_dev --service api_dev --force-new-deployment + ./deploy-to-env "$1" watch --interval=5 curl -s https://api.dev-viewer.swissgeol.ch/api/health_check exit 0 fi