Skip to content

Example Automatic Deployment of GCE Container Instance Using Cloud Build

License

Notifications You must be signed in to change notification settings

aoyagi9936/cloudbuild-gce-container-example

Repository files navigation

cloudbuild-gce-container-example

Architecture Diagram

This script is create and update gce container by cloud build.

Docker Container in GCE will publish Angular application on Nginx.

You need to make two triggers for initialization and update (cloudbuild.init.yaml, cloudbuild.yaml).

I setted each trigger the following condition.

Set Service Account Permission

To execute this build, please add the following roles to the automatically generated Cloud Build Service Account. ([YOUR_PROJECT_NUM]@cloudbuild.gserviceaccount.com)

  • roles/compute.instanceAdmin (OR roles/compute.instanceAdmin.v1)
  • roles/iam.serviceAccountUser

Please see following.

Cloud Build Document

Cloud Build Configuration

At the moment you can choose the following Repositoriy Hosting.

  • Cloud Source Repositories
  • Bitbucket
  • GitHub

Init Trigger (Create GCE instance with container)

  • Trigger Name: gce-container-example-init
  • Trigger Type: branch
  • Pattern Match: init-trigger
  • Include File Filter: .init

Operation is

$ git checkout -b init-trigger
$ echo >> .init
$ git commit .init -m "start init trigger"
# verify commit
# git commit .init -m "start init trigger" -S
$ git push origin HEAD

Update Trigger (Update GCE instance with container)

  • Trigger Name: gce-container-example
  • Trigger Type: tag
  • Pattern Match: release_v*

In addition, please set the following key for update trigger.

  • _GIT_MAIL=[YourGitEmail]
  • _GIT_USER=[YourGitUser]

Operation is

$ git tag release_v1 -m "first release"
# verify tag
# git tag -s release_v1 -m "first release"
$ git push origin release_v1

NOTE

This script uses following ZONE and GCR HOST

  • ZONE:us-central1-a
  • GCR HOST:gcr.io

About

Example Automatic Deployment of GCE Container Instance Using Cloud Build

Resources

License

Stars

Watchers

Forks

Packages

No packages published