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

Docker Compose PaaS の作り方、そして社内に導入した話 / #yapc8oji

Docker Compose PaaS の作り方、そして社内に導入した話 / #yapc8oji

YAP(achimon)C::Asia Hachioji 2016 mid in Shinagawa での発表資料です。

https://github.com/hachiojipm/yapcasia-8oji-2016mid-timetable/issues/80

Paus: https://github.com/dtan4/paus

Daisuke Fujita

July 03, 2016
Tweet

More Decks by Daisuke Fujita

Other Decks in Programming

Transcript

  1. Daisuke Fujita / @dtan4 Engineer, Infrastructure Team
 @ Wantedly, Inc.

    AWS, Terraform / Terraforming, Developer Productivity
  2. Deploy apps easily αʔϏεϦϦʔεʹ͋ͨͬͯɺΠϯϑϥߏஙʹ
 2ਓ೔͘Β͍අ΍͞ΕΔ • Production... ͸ Kubernetes ೖΕΑ͏ͱͯ͠Δ

    ΋ͬͱؾܰʹΞϓϦΛσϓϩΠͰ͖Δ؀ڥ͕΄͍͠ Heroku Έ͍ͨʹ؆୯ʹɺࣗ෼ͨͪͷ޷͖ͳߏ੒Ͱ
  3. Wantedly ❤ Docker Wantedly ͷશαʔϏε͸ 
 Docker on CoreOS ͰՔಇ͍ͯ͠Δ

    • Web app, Elasticsearch, ը૾ม׵αʔόɺ΄͔ॾʑ ৽نαʔϏε͸ Dockerfile ΛϦϙδτϦʹஔ͍ͯ΋Β͏ ผίϯϙʔωϯτʹґଘ͢Δ৔߹͸ docker-compose.yml ΋
  4. PaaS in the world • Heroku • Heroku Private Spaces

    OSS PaaS • dokku / dokku-alt • Flynn • Deis • Tutum • DCHQ.io • Empire • Convox • pool • …
  5. PaaS in the world Heroku ͩͱ buildpack + addons ߏ੒

    ͳͷͰ
 Ͱ͖Δ͜ͱ੍͕ݶ͞ΕΔ • ΧελϚΠζͨ͠ϛυϧ΢ΣΞͱ͔Λ࢖͑ͳ͍ • e.g. ಠࣗࣙॻΛ૊ΈࠐΜͩ Elasticsearch Docker Image
  6. Paus docker-compose.yml ॻ͍ͯ git push ͢Δ͚ͩͰσϓϩΠ طଘΠϝʔδ pull ͚ͩͰͳ͘ɺbuild ΋Մೳ

    αϒυϝΠϯׂΓ͋ͯ GitHub ΞΧ΢ϯτ࿈ܞ for Development / Test dtan4/paus
  7. –Johnny Appleseed “Type a quote here.” OS CoreOS Data store

    etcd Clustering Docker Swarm HTTP Reverse Proxy Vulcand git-push entrypoint paus-gitreceive
 w/ gitreceive Paus Components
  8. CoreOS ίϯςφલఏͷܰྔ Linux Distribution ͢΂ͯͷΞϓϦέʔγϣϯΛ
 Docker ίϯςφ্Ͱಈ͔͢ Production in Wantedly,

    Inc. Update channel: beta
 Reboot strategy: no https://coreos.com/assets/images/media/Host-Diagram.png
  9. etcd Raft Λ࠾༻ͨ͠෼ࢄ KVS CoreOS ͕։ൃ 
 & CoreOS ωΠςΟϒαϙʔτ

    Application metadata, Deployments, Routing rules,
 Cluster discovery coreos/etcd quay.io/coreos/etcd https://coreos.com/assets/images/media/5-Machine-Cluster.png
  10. Docker Swarm Docker ͕։ൃ͢Δ Clustering System ෳ਺ͷ Docker ϗετΛ·ͱΊͯ 


    1ͭͷڊେͳϦιʔεϓʔϧͱΈͳ͢ Docker Compose ΠϯςάϨʔγϣϯ Docker Engine 1.12 ʹ౷߹͞ΕΔ docker/swarm swarm
  11. Vulcand etcd όοΫΤϯυͷ HTTP Reverse Proxy Mailgun ͕։ൃ αʔϏεϦελʔτͳ͠Ͱ
 มߋΛଈ࠲ʹద༻Մೳ

    vulcand/vulcand vulcand https://camo.githubusercontent.com/b91054e9220422d7cdad498c229ae254b41601f5/687474703a2f2f636f72656f732e636f6d2f6173736574732f696d616765732f6d656469612f76756c63616e2d312d757073747265616d2e706e67
  12. paus-frontend Paus ͷ Web Dashboard GitHub ΞΧ΢ϯτͰαΠϯΠϯ ΞϓϦέʔγϣϯͷొ࿥ɺ
 build-time arguments,

    ؀ڥม਺ͷઃఆ Alpine Linux + (Go + gin-gonic/gin) dtan4/paus-frontend quay.io/dtan4/paus-frontend
  13. git push ͷड͚ޱ docker-compose build 
 + docker-compose up etcd

    ʹϝλσʔλ 
 + Vulcand ઃఆΛอଘ Ubuntu + gitreceive + receiver (by Go) paus-gitreceive dtan4/paus-gitreceive quay.io/dtan4/paus-gitreceive SFDFJWFS XFC EC XFC SFEJT
  14. Feedbacks ศར ύϑΥʔϚϯε͕ѱ͍
 ϝϞϦॏࢹͰ r3 ࢖ͬͯͨ => c4 ʹஔ͖׵͑ ઃఆ͕໘౗


    ϦϙδτϦʹσϑΥϧτ஋ຒΊࠐΜͩ .env ஔ͍ͯ
 docker-compose.yml Ͱಡ·ͤΔ progrium/gitreceive
  15. Deploy from CI ʮgit push ͢Δͷ΋໘౗ʯ GitHub ʹ push ͨ͠Β

    Paus ʹσϓϩΠʂ
 ؾ͕͍ͭͨΒউखʹσϓϩΠ͞ΕͯΔʂ CircleCI ͔Β git push paus <branch> σϓϩΠ਺্ݶΛઃఆͰ͖ΔΑ͏ʹ
  16. Replace backend to ECS Ϋϥελ؅ཧͱεέδϡʔϦϯάΛ ECS ʹ೚ͤΔ API ܦ༝ͰαʔϏε৘ใΛऔಘ CloudWatch

    Logs Ͱϩά΋औΕΔ ΫϥελϝτϦΫεʹج͍ͮͨΦʔτεέʔϧ => ECS ͸ PaaS backend ͱͯ͠࠷దͰ͸ʁ
  17. Recap ڞ༗ QA ؀ڥʹݶք͕དྷͨ & ؾܰʹσϓϩΠ͔ͨͬͨ͠ ෳ਺ͷ OSS Λ૊Έ߹Θͤɺࣗ෼ͨͪͷཁٻΛຬͨ͢
 Docker

    Compose PaaS: Paus Λ࡞ͬͨ ࣾ಺ಋೖͯ͠Έͨ΋ͷͷɺվળͷ༨஍͋Γ ECS ࢼ͍ͨ͠