Slide 1

Slide 1 text

#cndjp5 @sakajunquality Google Container Builder

Slide 2

Slide 2 text

Overview

Slide 3

Slide 3 text

- 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

Slide 4

Slide 4 text

- Also works as CI/CD Pipeline Overview Container Builder Container Registry Source Code CI Registry Compute Engine Kubernetes Engine Runtime Deployment

Slide 5

Slide 5 text

- Version (as of 26 April 2018) 17.05? Docker

Slide 6

Slide 6 text

Basic Usage & Configuration

Slide 7

Slide 7 text

Configuration: GCP Console

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

- 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

Slide 10

Slide 10 text

Supported Builder Images

Slide 11

Slide 11 text

Notification

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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" } }, // ... }

Slide 14

Slide 14 text

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"] }, // ... ] // ... }

Slide 15

Slide 15 text

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" } }, // ... }

Slide 16

Slide 16 text

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]

Slide 17

Slide 17 text

Slack Notification Sample

Slide 18

Slide 18 text

Logging & Debugging

Slide 19

Slide 19 text

Logging & Debugging - Container Builder Console - Stackdriver Logging

Slide 20

Slide 20 text

Logging: Container Builder

Slide 21

Slide 21 text

Logging: Stackdriver

Slide 22

Slide 22 text

Deployment

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

Online Resources

Slide 25

Slide 25 text

- 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

Slide 26

Slide 26 text

Thank you