Top Banner
Container CI/CD with Google Cloud Platform Minku Lee CTO, Shakr
62

Shakr - Container CI/CD with Google Cloud Platform

Apr 16, 2017

Download

Technology

Minku Lee
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Shakr - Container CI/CD with Google Cloud Platform

Container CI/CD with Google Cloud PlatformMinku Lee

CTO, Shakr

Page 2: Shakr - Container CI/CD with Google Cloud Platform
Page 4: Shakr - Container CI/CD with Google Cloud Platform
Page 5: Shakr - Container CI/CD with Google Cloud Platform
Page 6: Shakr - Container CI/CD with Google Cloud Platform

GitHub

DEVELOPMENT

Page 7: Shakr - Container CI/CD with Google Cloud Platform

GitHub

DEVELOPMENT

Travis CI

CONTINUOUS INTEGRATION

Page 8: Shakr - Container CI/CD with Google Cloud Platform

GitHub

DEVELOPMENT

Travis CI

CONTINUOUS INTEGRATION

Container Registry

IMAGE REGISTRY

Page 9: Shakr - Container CI/CD with Google Cloud Platform

GitHub

DEVELOPMENT

Travis CI

CONTINUOUS INTEGRATION

Container Registry

IMAGE REGISTRY

Compute Engine & Container Engine

INFRASTRUCTURE

Page 10: Shakr - Container CI/CD with Google Cloud Platform

GitHub

Page 11: Shakr - Container CI/CD with Google Cloud Platform
Page 12: Shakr - Container CI/CD with Google Cloud Platform

Pull Request

Page 13: Shakr - Container CI/CD with Google Cloud Platform

Travis CI

Page 14: Shakr - Container CI/CD with Google Cloud Platform

Travis CI

Page 15: Shakr - Container CI/CD with Google Cloud Platform

Travis CI

Page 16: Shakr - Container CI/CD with Google Cloud Platform

.travis.yml

sudo: required

services: - docker

before_script: - docker build -t videobox:$TRAVIS_BUILD_NUMBER . - docker images

script: - docker run videobox:$TRAVIS_BUILD_NUMBER bundle exec rubocop - docker run videobox:$TRAVIS_BUILD_NUMBER bundle exec rspec - openssl aes-256-cbc -K $encrypt_key -iv $encrypt_iv -in service_account.json.enc \ -out service_account.json -d - docker login -e [email protected] -u _json_key -p "$(cat service_account.json)" https://us.gcr.io - docker tag videobox:$TRAVIS_BUILD_NUMBER gcr.io/shakr/videobox:$TRAVIS_BUILD_NUMBER - docker push gcr.io/shakr/videobox:$TRAVIS_BUILD_NUMBER

notifications: slack: "..."

Page 17: Shakr - Container CI/CD with Google Cloud Platform

Docker

sudo: required

services: - docker

https://docs.travis-ci.com/user/docker

Page 18: Shakr - Container CI/CD with Google Cloud Platform

Docker

before_script: - docker build -t videobox:$TRAVIS_BUILD_NUMBER . - docker images

Page 19: Shakr - Container CI/CD with Google Cloud Platform

Dockerfile

Page 20: Shakr - Container CI/CD with Google Cloud Platform

Dockerfile

Page 21: Shakr - Container CI/CD with Google Cloud Platform

script: - docker run videobox:$TRAVIS_BUILD_NUMBER bundle exec rubocop - docker run videobox:$TRAVIS_BUILD_NUMBER bundle exec rspec

Page 22: Shakr - Container CI/CD with Google Cloud Platform

Container Registry

- docker login -e [email protected] -u _json_key \ -p "$(cat service_account.json)" \ https://us.gcr.io

- docker tag videobox:$TRAVIS_BUILD_NUMBER \ gcr.io/shakr/videobox:$TRAVIS_BUILD_NUMBER

- docker push gcr.io/shakr/videobox:$TRAVIS_BUILD_NUMBER

https://cloud.google.com/container-registry/docs/advanced-authentication

Page 23: Shakr - Container CI/CD with Google Cloud Platform

Container Registry

Page 24: Shakr - Container CI/CD with Google Cloud Platform

Google Container Registry

Page 25: Shakr - Container CI/CD with Google Cloud Platform

Google Compute Engine 인스턴스에서

Page 26: Shakr - Container CI/CD with Google Cloud Platform

Google Compute Engine 인스턴스에서

US, EU, ASIA

Page 27: Shakr - Container CI/CD with Google Cloud Platform

Google Compute Engine 인스턴스에서

US, EU, ASIA

Nearline GCS

Page 28: Shakr - Container CI/CD with Google Cloud Platform

gcloud CLI

$ gcloud docker pull gcr.io/google_appengine/nodejs

Using 'pull gcr.io/google_appengine/nodejs' for DOCKER_ARGS.

Using default tag: latest

latest: Pulling from google_appengine/nodejs

a3ed95caeb02: Pull complete

..

Digest: sha256:a7fcfb84b..

Status: Downloaded newer image for gcr.io/google_appengine/nodejs:latest

Page 29: Shakr - Container CI/CD with Google Cloud Platform

gcloud CLI

$ docker login -e [email protected] -u _json_key \ -p "$(cat service_account.json)" \ https://us.gcr.io

$ docker pull gcr.io/my_gcp_project/private_image:latest

https://cloud.google.com/container-registry/docs/advanced-authentication

Page 30: Shakr - Container CI/CD with Google Cloud Platform

Cloud Console

Page 31: Shakr - Container CI/CD with Google Cloud Platform

Google Container Engine

Page 32: Shakr - Container CI/CD with Google Cloud Platform

Google Container Engine

as a service

Page 33: Shakr - Container CI/CD with Google Cloud Platform

Google Container Engine

Container Scheduling Auto-healing Service Discovery

Config Management

Load Balancing

Page 34: Shakr - Container CI/CD with Google Cloud Platform

pod.yaml

apiVersion: v1 kind: Pod metadata: name: Videobox labels: name: videobox spec: containers: - name: videobox image: gcr.io/shakr/videobox:xxx imagePullPolicy: IfNotPresent env: - name: RACK_ENV value: production restartPolicy: Always dnsPolicy: default

Page 35: Shakr - Container CI/CD with Google Cloud Platform

rc.yaml

apiVersion: v1 kind: ReplicationController metadata: name: videobox spec: replicas: 3 selector: app: videobox template: metadata: name: videobox labels: app: videobox spec: # Pod spec here...

Page 36: Shakr - Container CI/CD with Google Cloud Platform
Page 37: Shakr - Container CI/CD with Google Cloud Platform
Page 38: Shakr - Container CI/CD with Google Cloud Platform

PodsNodes

Replication Controllers

Persistent Volumes

Stateful Sets (Pet Set)

Cron JobsSecrets

Services

Volumes

Replica Sets

Page 39: Shakr - Container CI/CD with Google Cloud Platform

PodsNodes

Replication Controllers

Persistent Volumes

Stateful Sets (Pet Set)

Cron JobsSecrets

Services

Volumes

Replica Sets

Page 40: Shakr - Container CI/CD with Google Cloud Platform

Podgcr.io/shakr/videobox:1

Page 41: Shakr - Container CI/CD with Google Cloud Platform

Podgcr.io/shakr/videobox:1

GCS PersistentVolume

Page 42: Shakr - Container CI/CD with Google Cloud Platform

Podgcr.io/shakr/videobox:1

Podgcr.io/shakr/videobox:1

Podgcr.io/shakr/videobox:1

Page 43: Shakr - Container CI/CD with Google Cloud Platform

Podgcr.io/shakr/videobox:1

Podgcr.io/shakr/videobox:1

Podgcr.io/shakr/videobox:1

ReplicationControllervideobox replicas=3

replica scale-up/

scale-down

k8s worker

worker

Page 44: Shakr - Container CI/CD with Google Cloud Platform

Podgcr.io/shakr/videobox:1

Podgcr.io/shakr/videobox:1

Podgcr.io/shakr/videobox:1

ReplicationControllervideobox replicas=3

Podgcr.io/shakr/vault:1

ReplicationControllervault replicas=1

Page 45: Shakr - Container CI/CD with Google Cloud Platform

(Infrastructure as Code)

Git

Page 46: Shakr - Container CI/CD with Google Cloud Platform

(Infrastructure as Code)

Git

On-Premise

Page 47: Shakr - Container CI/CD with Google Cloud Platform

(Infrastructure as Code)

Git

On-Premise

PaaS PaaS

Page 48: Shakr - Container CI/CD with Google Cloud Platform

(Infrastructure as Code)

Git

On-Premise

PaaS PaaS

master/worker

Page 49: Shakr - Container CI/CD with Google Cloud Platform

Preemptible VM

PVM Node Pool (Beta)

Page 50: Shakr - Container CI/CD with Google Cloud Platform

Preemptible VM

PVM Node Pool (Beta)

Cluster Autoscaler (Beta)

Page 51: Shakr - Container CI/CD with Google Cloud Platform

Preemptible VM

PVM Node Pool (Beta)

Cluster Autoscaler (Beta)

(>50GB per pod)

Local SSD를 Pod

Page 52: Shakr - Container CI/CD with Google Cloud Platform

Google Compute Enginewith containers!

Page 53: Shakr - Container CI/CD with Google Cloud Platform

Container-Optimized OS (BETA)

Page 54: Shakr - Container CI/CD with Google Cloud Platform

Chromium OS Verified Boot

Active-passive

systemd

cloud-init

Google

Container-Optimized OS (BETA)

Page 55: Shakr - Container CI/CD with Google Cloud Platform

gcloud CLI

$ gcloud compute instances create gci-instance-test \

--image-project google-containers \

--image-family gci-stable \

--zone asia-northeast1-a \

--machine-type n1-standard-1

Page 56: Shakr - Container CI/CD with Google Cloud Platform

cloud-init

$ gcloud compute instances create gci-instance-test \

--image-project google-containers \

--image-family gci-stable \

--zone asia-northeast1-a \

--machine-type n1-standard-1 \

--metadata-from-file user-data=cloud-init.yml

Page 57: Shakr - Container CI/CD with Google Cloud Platform

cloud-init.yml#cloud-config

users: - name: myservice uid: 2000

write_files: - path: /etc/systemd/system/myservice.service permissions: 0644 owner: root content: | [Unit] Description=Start a simple docker container

[Service] ExecStartPre=/usr/share/google/dockercfg_update.sh ExecStart=/usr/bin/docker run --rm -u 2000 --net=host --name=myservice -e RACK_ENV=production -p 80:80 \ gcr.io/project/myservice:latest ExecStop=/usr/bin/docker stop myservice ExecStopPost=/usr/bin/docker rm myservice

runcmd: - systemctl daemon-reload - systemctl enable myservice.service - systemctl start myservice.service

Page 58: Shakr - Container CI/CD with Google Cloud Platform

systemd

Page 59: Shakr - Container CI/CD with Google Cloud Platform

VM

Preemptible VM, Regional Managed Instance Group 등

Kubernetes

Page 60: Shakr - Container CI/CD with Google Cloud Platform

GitHub

DEVELOPMENT

Travis CI

CONTINUOUS INTEGRATION

Container Registry

IMAGE REGISTRY

Compute Engine & Container Engine

INFRASTRUCTURE

Page 61: Shakr - Container CI/CD with Google Cloud Platform

Google Cloud Platform가장 앞선 컨테이너 기술을 빠르고 쉽게 적용 가능한 플랫폼

Page 62: Shakr - Container CI/CD with Google Cloud Platform

Thank youWe're looking for talented engineers!

Minku Lee [email protected]