Created
November 12, 2019 17:58
-
-
Save andsilver/595cee4ae61d3ff7d3ee4a21f4183182 to your computer and use it in GitHub Desktop.
Bitbucket pipeline to auto deploy Docker Compose app to Google Kubernetes Engine
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
pipelines: | |
branches: | |
<BRANCH_NAME>: | |
- step: | |
services: | |
- docker | |
name: Deploy to GKE | |
deployment: staging | |
image: google/cloud-sdk:latest | |
script: | |
- export DOCKER_COMPOSE_VERSION=1.23.1 | |
- export DOCKER_COMPOSE_URL=https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m) | |
- export GCP_PROJECT=<GOOGLE_PROJECT_ID> | |
- curl -L $DOCKER_COMPOSE_URL > docker-compose | |
- chmod +x docker-compose | |
- mv docker-compose /usr/local/bin | |
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl | |
- chmod +x ./kubectl | |
- mv ./kubectl /usr/local/bin/kubectl | |
- gcloud auth activate-service-account --key-file <SERVICE_ACCOUNT_KEY_FILE> | |
- gcloud docker --authorize-only --project=$GCP_PROJECT | |
- gcloud container clusters get-credentials <CLUSTER_NAME> --zone=<CLUSTER_ZONE> --project=$GCP_PROJECT | |
- kubectl config set-context <K8S_CONTEXT> | |
- docker-compose build | |
- docker-compose push | |
- kubectl rollout restart deployments/<APP_DEPLOYMENT> | |
definitions: | |
services: | |
docker: | |
memory: 3072 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment