Last active
April 16, 2024 12:03
-
-
Save adilsoncarvalho/e0e8da81dbf52bf90c671887ef7e04d3 to your computer and use it in GitHub Desktop.
Bitbucket Pipelines deployment to a Google Container Engine configuration
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
options: | |
docker: true | |
pipelines: | |
branches: | |
master: | |
- step: | |
image: google/cloud-sdk:latest | |
name: Deploy to production | |
deployment: production | |
caches: | |
- docker | |
script: | |
# SETUP | |
- export IMAGE_NAME=us.gcr.io/$GCLOUD_PROJECT/$BITBUCKET_REPO_SLUG:$BITBUCKET_COMMIT | |
- export ENVIRONMENT=production | |
- echo $GCLOUD_API_KEYFILE | base64 -d > ~/.gcloud-api-key.json | |
- gcloud auth activate-service-account --key-file ~/.gcloud-api-key.json | |
- gcloud config set project $GCLOUD_PROJECT | |
- gcloud container clusters get-credentials $GCLOUD_CLUSTER --zone=$GCLOUD_ZONE --project $GCLOUD_PROJECT | |
- gcloud auth configure-docker --quiet | |
# BUILD IMAGE | |
- docker build . -t $IMAGE_NAME | |
# PUBLISH IMAGE | |
- docker push $IMAGE_NAME | |
# DEPLOYMENT | |
- kubectl set image deployment $BITBUCKET_REPO_SLUG-$ENVIRONMENT $BITBUCKET_REPO_SLUG=$IMAGE_NAME --record --namespace=$K8S_NAMESPACE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for a detailed explanation, this gist helps me a lot and enables me to accomplish what I want to perform. However is it necessary to do the export and setting of environment part or I can just authenticate, select the project and run a
gcloud
commands I need? Will there be any side effect if I skip that part, also can you help me where can I possibly find this exported image perhaps in the Cloud Console?