Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GoogleContainerBuilderOverview

 GoogleContainerBuilderOverview

sakajunquality

April 27, 2018
Tweet

More Decks by sakajunquality

Other Decks in Technology

Transcript

  1. - GCP Full-Managed CI - Build and Push Docker Image

    - Build and Upload Artifact Tarball Overview Container Builder Container Registry Source Code CI Registry/Storage Trigger Cloud Storage Upload Push
  2. - Also works as CI/CD Pipeline Overview Container Builder Container

    Registry Source Code CI Registry Compute Engine Kubernetes Engine Runtime Deployment
  3. Configuration: cloudbuild.yaml // cloudbuild.yaml steps: # build - name: 'gcr.io/cloud-builders/docker'

    args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/my-app:$REVISION_ID', '.' ] # push - name: 'gcr.io/cloud-builders/docker' args: ["push", "gcr.io/$PROJECT_ID/my-app:$REVISION_ID"] List build steps
  4. - Supported Build Steps - https://github.com/GoogleCloudPlatform/cloud-builders - bash is also

    available - - name: 'gcr.io/cloud-builders/gcloud' - entrypoint: 'bash' - Custom Build Steps - https://cloud.google.com/container-builder/docs/create-custom-build-steps?hl=ja Steps
  5. Notification - Every event is pushed to Cloud Pub/Sub topic

    - Topic: cloud-builds - https://cloud.google.com/container-builder/docs/pubsub?hl=ja Container Builder Cloud Functions Cloud Pub/Sub Event Subscribe
  6. Event Message Payload 1 { "id": "xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb", "projectId": "my-project", "status":

    "SUCCESS", "source": { "repoSource": { "projectId": "my-project", "repoName": "github-sakajunquality-my-app", "branchName": "master" } }, // ... }
  7. Event Message Payload 2 { // ... "steps": [ {

    "name": "gcr.io/cloud-builders/docker", "args": [ "build", "-t", "gcr.io/my-project/my-repo:hashhash", "." ] }, { "name": "gcr.io/cloud-builders/docker", "args": [ "push", "gcr.io/my-project/my-repo:hashhash"] }, // ... ] // ... }
  8. Event Message Payload 3 { // ... "createTime": "2018-04-06T09:17:45.069621980Z", "startTime":

    "2018-04-06T09:17:46.231838575Z", "finishTime": "2018-04-06T09:19:03.547323Z", "sourceProvenance": { "resolvedRepoSource": { "projectId": "my-project", "repoName": "github-sakajunquality-my-app", "commitSha": "88e07c6db8a03653598884dc94ad4e8910c0fd51" } }, // ... }
  9. Cloud Function deploy // deploy cloud function gcloud beta functions

    deploy cloudbuild-notify \ --entry-point subscribe \ --trigger-event providers/cloud.pubsub/eventTypes/topic.publish \ --trigger-resource cloud-builds \ --region us-central1 \ --stage-bucket [your bucket]
  10. Deployment // cloudbuild.yaml Steps: // build & push - name:

    'gcr.io/cloud-builders/kubectl' args: - set - image - deployment - [DEPLOYMENT-NAME] - [CONTAINER]=gcr.io/[PROJECT-ID]/[IMAGE]:[TAG] // see also https://cloud.google.com/container-builder/docs/configuring-builds/build-test-deploy-artifacts?hl=ja