Last active
January 18, 2017 21:52
-
-
Save CaptChrisD/5c519fd56321cdef10ebc1e312f2a40e to your computer and use it in GitHub Desktop.
Cops For Hire Semaphore CD script
This file contains hidden or 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
| #!/bin/bash | |
| ## Usage: | |
| ## ./semaphore_cd_gcloud.sh service_name project zone cluster | |
| export PATH=$SEMAPHORE_CACHE_DIR/google-cloud-sdk/bin:$PATH | |
| if [ ! -f "$SEMAPHORE_CACHE_DIR/google-cloud-sdk/bin/gcloud" ] | |
| then | |
| curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-134.0.0-linux-x86_64.tar.gz | |
| tar -x -C $SEMAPHORE_CACHE_DIR -f google-cloud-sdk-134.0.0-linux-x86_64.tar.gz | |
| gcloud --quiet components update --version 134.0.0 | |
| fi | |
| if [ ! -f "$SEMAPHORE_CACHE_DIR/google-cloud-sdk/bin/kubectl" ] | |
| then | |
| gcloud --quiet components update --version 134.0.0 kubectl | |
| fi | |
| gcloud auth activate-service-account --key-file gcloud.json | |
| gcloud config set container/use_client_certificate True | |
| gcloud config set project $2 | |
| gcloud config set compute/zone $3 | |
| gcloud config set container/cluster $4 | |
| gcloud container clusters get-credentials $4 | |
| kubectl scale deployment $1 --replicas 0 | |
| kubectl scale deployment $1 --replicas 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment