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

Container CI/CD with Google Cloud Platform

Minku Lee
December 14, 2016

Container CI/CD with Google Cloud Platform

2016년 12월 14일에 있었던 Google Cloud Korea Event에서 발표했던 자료입니다. 컨테이너를 이용하여 지속적 통합(CI)과 지속적 배포(CD) 파이프라인을 구축한 사례를 공유합니다.

Minku Lee

December 14, 2016
Tweet

More Decks by Minku Lee

Other Decks in Technology

Transcript

  1. 맪짪짝짾핂않핆 GitHub 콚큲슪큲 핂큖앦 펂읺쮾 DEVELOPMENT Travis CI 핂뻖찚슪 퓮삩큲킲

    핂뻖핂짆힎킪 CONTINUOUS INTEGRATION Container 
 Registry 핂짆힎헎핳 뫎읺 IMAGE REGISTRY
  2. 맪짪짝짾핂않핆 GitHub 콚큲슪큲 핂큖앦 펂읺쮾 DEVELOPMENT Travis CI 핂뻖찚슪 퓮삩큲킲

    핂뻖핂짆힎킪 CONTINUOUS INTEGRATION Container 
 Registry 핂짆힎헎핳 뫎읺 IMAGE REGISTRY Compute Engine & Container Engine 팮읺핂켦묺솧 뫎읺 INFRASTRUCTURE
  3. .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: "..."
  4. 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
  5. 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
  6. 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
  7. Google Container Engine 핂뻖큲흂잏 Container Scheduling 핞솧핺쫃묺 Auto-healing 컪찒큲싢큲쩒읺 Service

    Discovery 컲헣뫎읺 Config Management 쭎쭒칾
 Load Balancing 슿슿˘
  8. 컲헣폖헪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
  9. 컲헣폖헪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...
  10. 팮읺핂켦킲믾 Pod gcr.io/shakr/videobox:1 Pod gcr.io/shakr/videobox:1 Pod gcr.io/shakr/videobox:1 ReplicationController videobox replicas=3

    ˖ replica쿦펞싾않핞솧픊옪scale-up/ scale-down ˖ k8s worker많앦킪쇦펂솒핞솧픊옪 삲읆worker펞큲흂잏
  11. ˖ Preemptible VM픒핂푷찒푷헖맞핂쭖많쁳 ˖ PVM Node Pool (Beta)많헣킫킪쇦졂멾폖헣 ˖ 퀺풂폲큲핊잏핂쭖많쁳

    ˖ Cluster Autoscaler (Beta)많헣킫킪쇦졂멾폖헣 ˖ 싢큲(>50GB per pod)읊푢옪쁢핂뻖읊풂폏믾슺 ˖ 솧헏큲앦싢큲빦몮컿쁳Local SSDܳPod쪒옪샇쿦펔픚 몮짊섦헞
  12. ˖ Chromium OS 믾짦 Verified Boot ˖ Active-passive픦핞솧펓섾핂힎풞 ˖ systemd

    칺푷 ˖ cloud-init힎풞 ˖ 핊쭎싢엗읺읊헪푆욶핊킪큲핂핋믾헒푷 ˖ 힎잲삖헎펔픚핂뻖뺂펞컪팮읺핂켦픒킲쁢멑핂믾쫆 ˖ 읺뿓큲짾뫊삲읂멚Google핂헣킫힎풞 Container-Optimized OS (BETA)
  13. 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
  14. 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
  15. 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
  16. ˖ 믾홂VM뫎읺짷킫픒믆샎옪헏푷많쁳 ˖ Preemptible VM, Regional Managed Instance Group ١

    ˖ 핊짦헏핆읺뿓큲짾쫂삲폲쩒슪많헏픚 ˖ Kubernetes펞핃쿧힎믾헒펞솒핓많쁳 홙픎헞
  17. 맪짪짝짾핂않핆 GitHub 콚큲슪큲 핂큖앦 펂읺쮾 DEVELOPMENT Travis CI 핂뻖찚슪 퓮삩큲킲

    핂뻖핂짆힎킪 CONTINUOUS INTEGRATION Container 
 Registry 핂짆힎헎핳 뫎읺 IMAGE REGISTRY Compute Engine & Container Engine 팮읺핂켦묺솧 뫎읺 INFRASTRUCTURE