bitbucket-pipelines.yml

Bitbucket Pipelines deployment to a Google Container Engine configuration

12

Votes

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

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote

Terms Of Use

Privacy Policy

Featured snippets are MIT license

Gears & Masters

Advertise

DevOpsnipp.com © 2020

medium.png