-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script to flip the prod bluegreen defelctor service
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
# Ensure that our cloudbuild has everything we need | ||
for cmd in git yq; do | ||
if ! command -v $cmd &> /dev/null; then | ||
echo "Error: $cmd is not installed." >&2 | ||
exit 1 | ||
fi | ||
done | ||
|
||
|
||
mkdir -p /root/.ssh && chmod 0700 /root/.ssh | ||
echo "$DEPLOY_KEY" > /root/.ssh/id_rsa | ||
chmod 400 /root/.ssh/id_rsa | ||
ssh-keyscan -t rsa github.com > /root/.ssh/known_hosts | ||
git clone git@github.com:broadinstitute/gnomad-deployments.git | ||
|
||
cd gnomad-deployments/browser-test/prod-deflector | ||
|
||
CURRENT_DEPLOYMENT=$(yq '.spec.selector.deployment' < gnomad-bluegreen.service.yaml) | ||
|
||
echo "Current deployment is: $CURRENT_DEPLOYMENT" | ||
|
||
if [[ "$CURRENT_DEPLOYMENT" != "blue" && "$CURRENT_DEPLOYMENT" != "green" ]]; then | ||
echo "Error: Current deployment is not either green or blue, unknown state. Exiting." | ||
exit 1 | ||
fi | ||
|
||
if [[ "$CURRENT_DEPLOYMENT" == "blue" ]]; then | ||
TARGET_DEPLOYMENT="green" | ||
else | ||
TARGET_DEPLOYMENT="blue" | ||
fi | ||
|
||
yq -i ".spec.selector.deployment = \"${TARGET_DEPLOYMENT}\"" gnomad-bluegreen.service.yaml | ||
|
||
git add gnomad-bluegreen.service.yaml | ||
git -c user.name="TGG Automation" -c user.email="tgg-automation@broadinstitute.org" commit -m "Updating gnomad-browser active service to $TARGET_DEPLOYMENT" | ||
git show | ||
|
||
git push origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
steps: | ||
- name: 'us-central1-docker.pkg.dev/${PROJECT_ID}/tgg-sre-images/tgg-deploykit:testing-4' | ||
entrypoint: 'bash' | ||
args: ['./bluegreen-flip.sh'] | ||
dir: '.cloudbuild' | ||
secretEnv: | ||
- 'DEPLOY_KEY' | ||
availableSecrets: | ||
secretManager: | ||
- versionName: projects/$PROJECT_ID/secrets/GITHUB_DEPLOY_KEY/versions/latest | ||
env: 'DEPLOY_KEY' |