Skip to content

Commit

Permalink
Update int/prod deploy scripts and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vladyslav-tk committed Oct 3, 2023
1 parent 6bffc01 commit fc53d12
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 36 deletions.
28 changes: 7 additions & 21 deletions DEPLOY_ABBREVIATOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

```
8 changes: 8 additions & 0 deletions DEPLOY_VIEWER.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 <a name="argocd"></a>

* Argo CD dashboard: https://dev-argocd.swissgeol.ch/applications
* Argo CD repository: https://git.swisstopo.admin.ch/ngm/argocd/

## Invalidating some paths from cloudfront

Expand Down
18 changes: 9 additions & 9 deletions scripts/deploy-to-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 2 additions & 6 deletions scripts/deploy_viewer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}


Expand All @@ -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
Expand Down

0 comments on commit fc53d12

Please sign in to comment.