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. #cndjp5 @sakajunquality Google Container Builder

  2. Overview

  3. - 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
  4. - Also works as CI/CD Pipeline Overview Container Builder Container

    Registry Source Code CI Registry Compute Engine Kubernetes Engine Runtime Deployment
  5. - Version (as of 26 April 2018) 17.05? Docker

  6. Basic Usage & Configuration

  7. Configuration: GCP Console

  8. 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
  9. - 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
  10. Supported Builder Images

  11. Notification

  12. 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
  13. 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" } }, // ... }
  14. 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"] }, // ... ] // ... }
  15. 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" } }, // ... }
  16. 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]
  17. Slack Notification Sample

  18. Logging & Debugging

  19. Logging & Debugging - Container Builder Console - Stackdriver Logging

  20. Logging: Container Builder

  21. Logging: Stackdriver

  22. Deployment

  23. 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
  24. Online Resources

  25. - Official Document - https://cloud.google.com/container-builder/docs/?hl=ja - Speeding-up - https://cloud.google.com/container-builder/docs/speeding-up-builds?hl=ja#using_a _cached_docker_image

    Online Resources
  26. Thank you