Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Docker をフル活用したインフラの紹介と成長し続けるためのインフラ戦略 / #abejam...

Docker をフル活用したインフラの紹介と成長し続けるためのインフラ戦略 / #abejameetup

Innovation Meetup ~Startup Infrastructure~ の発表資料です
http://abeja-innovation-meetup.connpass.com/event/36707/

Daisuke Fujita

August 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. 2014/08~ Docker on AWS ೔ຊ <-> ถࠃ౦ւ؛ ԟ෮ʹΑΔϨΠςϯγΛແ͍ͨ͘͠ Πϯϑϥઐ೚ͷΤϯδχΞ΋ join

    ͨ͠ ౦ژϦʔδϣϯ͕ଘࡏ͢Δ AWS ΁Ҡߦ Heroku ಉ౳ͷ UX Λఏڙ͢ΔͨΊ Docker Λ࠾༻
  3. 2014/08~ Docker on AWS Capistrano Λ࢖ͬͨಠࣗͷσϓϩΠγεςϜ 
 + Heroku CLI

    ಉ༷ͷΠϯλʔϑΣΠεΛ࣋ͭ CLI EC2 Πϯελϯε (Ubuntu 14.04) ͱ Docker image ͸
 Chef + Packer ͰϓϩϏδϣχϯά
  4. CoreOS ίϯςφલఏͷܰྔ Linux Distribution ͢΂ͯͷΞϓϦέʔγϣϯΛ
 Docker ίϯςφ্Ͱಈ͔͢ Chrome ͱಉ͡ Update

    System Update channel: beta
 Reboot strategy: no https://coreos.com/assets/images/media/Host-Diagram.png
  5. Infrastructure at Wantedly Web, DB, Storage
 
 DNS AWS
 EC2,

    ELB, RDS, Elasticache, S3,
 Route53, VPC, Lambda DNSimple
  6. Web (Rails) Docker image ͸2ஈߏ੒ ि1Ͱ intermediate image ΛϏϧυ
 σϓϩΠ࣌ʹ

    web image ΛϏϧυ bundle install git clone wantedly/wantedly Ruby FROM Ubuntu 14.04 rake assets:precompile bundle install git checkout <branch> git fetch FROM intermediate web intermediate
  7. Web (Rails) ࠩ෼ͷΈͷ fetch + bundle install Ͱ
 σϓϩΠΛߴ଎Խ intermediate

    ͸ Chef + Packer bundle install git clone wantedly/wantedly Ruby FROM Ubuntu 14.04 rake assets:precompile bundle install git checkout <branch> git fetch FROM intermediate web intermediate
  8. ެࣜ Elasticsearch image ϕʔεͷ Docker image ֤छϓϥάΠϯ + ಠࣗࣙॻʢਓ໊ etc...ʣ

    --net=host + EC2 discovery ։ൃ؀ڥͰ΋ຊ൪ͱಉ౳ͷ Elasticsearch Λ࢖͑Δ Elasticsearch
  9. Nginx + ngx_small_light ը૾ม׵αʔό S3 ʹอ؅ͨ͠ը૾ΛϦαΠζ / ϒϥʔ / WebP

    ม׵… CloudFront Ͱ഑৴ + Ωϟογϡ nginx-image-server wantedly/nginx-image-server quay.io/wantedly/nginx-image-server Docker Image
 ެ։͍ͯ͠·͢
  10. All services on Docker Facebook ࢓ࣄ૬ஊ bot (Python) จॻϓϨϏϡʔ࡞੒αʔό (Golang)

    ࣾ಺ Slack bot (Node.js) ...
 ৽نαʔϏε͸ϦϙδτϦʹ Dockerfile Λஔ͍ͯ΋Β͏
  11. Private Docker Registry (S3 backed) Λհͨ͠
 Docker image ͷ΍ΓऔΓ Deploy

    Web Build server $ docker push $ docker pull $ git fetch $ docker build $ docker run
  12. ϗετϨϕϧͰͷ Blue-Green Deployment Deploy Web Blue Web Green if (-e

    /etc/nginx/switch/blue) { proxy_pass http://blue-container; } if (-e /etc/nginx/switch/green) { proxy_pass http://green-container; }
  13. Heroku ಉ౳ͷΠϯλʔϑΣΠεΛ࣋ͭ CLI (Capistrano) Deploy $ cap -T cap config

    # Display the config vars for an app cap deploy[revision] # Deploy an application cap deploy:diff[ref] # Display diff deployed revision and the revision to cap deploy:rollback # Rollback application cap logs:t[container_name] # Display stream logs for an container cap maintenance:on # Enable maintenance mode cap ps # Display web, worker, scheduler, run type containers cap ps:scale[role,num] # Scale out/in containers cap ps:restart:web[color,chained_task?] # Start web containers cap releases # Display deploy history cap run[command] # Run on-off commands cap scheduler # Display scheduling cap scheduler:clear # Clear scheduler config cap scheduler:update # Update scheduler cap status # Show application status
  14. SSH + Docker ίϯςφܦ༝Ͱ Deploy ࣮ߦ (sap)
 
 CLI ߋ৽࣌ʹ΋֤ࣗͷϚγϯͰΞοϓσʔτͯ͠΋Β͏ඞཁ

    ͕ͳ͍ ֤࡞ۀͷϩάΛ Docker container ϩάͱͯ͠࢒ͤΔ & Ӿཡ
 Ͱ͖Δ Deploy
  15. Wantedly Open API ͸ͨΒ͘Λ໘ന͘ʯΛςʔϚʹ͜Ε·ͰαʔϏε։ൃΛల։͖ͯͨ͠ 8BOUFEMZ͕ͦͷՁ஋Λ8BOUFEMZDPNυϝΠϯҎ֎ʹ΋޿͍͖͛ͯ·͢ɻ ੈͷதͷҰਓͰ΋ଟ͘ͷਓ͕ɺ͸ͨΒ͘Λ໘ന͘ʯײ͡ΒΕΔੈͷதʹͳΓ·͢Α͏ʹɻ Ͱ͖Δ͜ͱ ࣗಈೖྗ ΫοΫύουגࣜձࣾ ΫοΫύουגࣜձࣾ

    5݄13೔ʹฐࣾΦϑΟε಺ͷεϖʔεʹͯʮʲୈ17ճʳpotatotips(iOS/Android։ൃTips ڞ༗ձ)ʯ http://connpass.com/event/14143/ Λ։࠵͠·ͨ͠ʂ 18໊ͷൃදऀ͕5෼ؒͷLTʢϥΠτχϯάτʔΫɿΧϯϑΝϨϯεͳͲͰߦΘΕΔ୹͍ ΋ͬͱݟΔ ஑ా୓࢘ ϢʔβʔϑΝʔετਪਐ෦෦௕   ਓ͕ϑΥϩʔத  ਓ͕ϑΥϩʔத ϑΥϩʔ͢Δ ձࣾϑΟʔυϘοΫε ࿩Λฉ͖ʹߦ͘Ϙλϯ ϑΥʔϜࣗಈೖྗϘλϯ Wantedly্ʹ͋ΔʮձࣾϑΟʔυʯ Λɺϒϩά΍ίʔϙϨʔταΠτͳ Ͳɺ޷͖ͳϖʔδʹ؆୯ʹຒΊࠐΉ͜ ͱ͕Ͱ͖·͢ɻखܰͳ࠾༻ϒϥϯσΟ ϯά΍৘ใൃ৴ʹར༻Ͱ͖·͢ɻ ৄ͘͠ ৄ͘͠ ৄ͘͠ ࣗࣾαΠτ౳ͷืूཁ߲ʹɺʮ࿩Λฉ ͖ʹߦ͖͍ͨʯϘλϯΛઃஔ͠ɺ Wantedly্ͷʮ༡ͼʹ͍͘ମݧʯΛࣗ ࣾαΠτͰ΋ల։Ͱ͖·͢ɻ ࠾༻؅ཧγεςϜఏڙاۀ༷౳΁ͷಛ ผఏڙAPIͰ͢ɻީิऀ͕ืूʹΤϯ τϦ͢ΔࡍʹɺWantedly্ͷϓϩϑΟ ʔϧ৘ใΛ׆༻ͯ͠ΤϯτϦ͕Մೳʹ ͳΓ·͢ɻ https://www.wantedly.com/developers
  16. WANTEDLY JOURNAL ͸ͨΒ͘Λ໘ന͘͢ΔϝσΟΞ γΰτͰίίϩΦυϧͬͯͳΜͩΖ͏ʁ 8BOUFMEZ͸ɺγΰτͰίίϩΦυϧਓΛ;΍͍ͨ͠ͱߟ͍͑ͯ·͢ɻ Ͱ͸ɺzγΰτͰίίϩΦυϧzͱ͸Ͳ͏͍͏ঢ়ଶͳͷͰ͠ΐ͏ʁ ͓٬͞Μʹʮ͋Γ͕ͱ͏ʯͱݴΘΕͨͱ͖ ໨ඪͷച্Λୡ੒ͨ͠ͱ͖ νʔϜϝϯόʔͷসإΛݟͨͱ͖ʜ ͦΕ͸ɺਓʹΑͬͯҧ͏Ͱ͠ΐ͏͠ɺ

    ࣌୅΍ࠃʹΑͬͯ΋·ͬͨ͘ҟͳΔͰ͠ΐ͏ɻ ࠓճϦϦʔε͢Δʮ8"/5&%-:+063/"-ʯͰ͸ɺ 8BOUFEMZΛ௨ͯ͠స৬ͨ͠ํ΍ɺීஈ͋·Γݟͨ͜ͱ͕ͳ͍اۀ΁ͷ ΠϯλϏϡʔΛ௨ͯ͠ɺzγΰτͰίίϩΦυϧzͱ͸Կͳͷ͔Λ୳ٻ͠·͢ɻ γΰτΛ୳͍ͯ͠Δਓ΋ɺͦ͏Ͱͳ͍ਓʹͱͬͯ΋ɺ ʮ8"/5&%-:+063/"-ʯ͕ಇ͖ํͷώϯτʹͳΕ͹޾͍Ͱ͢ɻ https://www.wantedly.com/journals
  17. Solution 2: API React.js ϜʔϒϝϯτʹΑΔ Web ϑϩϯτΤϯυͷ෼཭ Kong Λར༻ͨ͠ೝূ͖ͭ API

    Gateway apig ʹΑΔϞσϧఆ͔ٛΒͷ 
 REST API αʔόɺυΩϡϝϯτͷੜ੒ webmock-proxy ʹΑΔαʔϏεؒ Integration Test ؆ུԽ wantedly/apig wantedly/webmock-proxy