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

OpsWorks で簡単プロビジョニング

Hitoshi Tsuda
October 06, 2014

OpsWorks で簡単プロビジョニング

社内勉強会で発表した、OpsWorks の紹介資料です。(そのため、デモ部分は削っています)
実際にプロジェクトで利用した所感も紹介しています。

Hitoshi Tsuda

October 06, 2014
Tweet

More Decks by Hitoshi Tsuda

Other Decks in Technology

Transcript

  1. ύονͷ͋ͨͬͨ bash Λ yum update ͢Ε͹OK $ env x='() {

    :;}; echo vulnerable' bash -c "echo this is a test"! vulnerable! this is a test $ env x='() { :;}; echo vulnerable' bash -c "echo this is a test"! bash: warning: x: ignoring function definition attempt! bash: error importing function definition for `x'! this is a test $ sudo yum update bash ※౰࣌໰୊͕ىͬͨ͜௚ޙ͸ɺAmazonLinux 2014.09 ҎલͰ͸ --releasever ΦϓγϣϯΛར༻ͯ͠ ϦϦʔεόʔδϣϯΛ 2014.09 ʹِ૷͢Δඞཁ͕͋Γ·ͨ͠ʢࠓ͸ڪΒ͘େৎ෉͔ͱʣ
  2. Chefͷಛ௃: Ruby Λ࢖ͬͯઃఆΛهड़͢Δ Ruby ࣗମ΋ॻ͖΍͍͢ݴޠͰɺؾܰʹม਺બ୒΍৚݅෼ذ͕ߦ͑Δ Ansible ͸ YAML Ͱهड़͢ΔͨΊɺ΍΍ࣗ༝౓͕௿͍ Puppet

    ͸ಠࣗݴޠͰهड़͢ΔͨΊɺशಘ΁ͷෑډ͕ߴ͍͔ هड़ͨ͠ॱ൪ʹॲཧ͕࣮ߦ͞ΕΔ ґଘؔ܎Λఆٛ͢Δ͜ͱ΋Մೳ ΫοΫϒοΫͱݺ͹ΕΔ୯ҐͰ؅ཧ͢ΔͨΊɺཧղɾ؅ཧ͕͠΍͍͢ ୈࡾऀ͕࡞੒ͨ͠ΫοΫϒοΫΛ࠶ར༻͢Δ͜ͱͰੜ࢈ੑΛߴΊΔ ࣾ಺Ͱ΋ɺϓϩδΣΫτؒͷΫοΫϒοΫͷڞ༗͸༗ޮ Facebook, αΠόʔΤʔδΣϯτ, Preziʢͦͯ͠ࠓճ঺հ͢Δ OpsWorks ͳ Ͳʣɺར༻ࣄྫ΋๛෋
  3. m(_ _)m ࠓճ͸࣌ؒͷؔ܎ͰɺChef ͷৄ͍͠આ໌͸͠ ·ͤΜ ͜ͷޙͰઆ໌͢Δ OpsWorks Λར༻͢Δ্Ͱ ͸ Chef

    ͷཧղ͕ෆՄܽͰ͢ͷͰɺӈͷຊ͕Φ εεϝͰ͢ OpsWorks ͸ Chef Solo Λར༻ͨ͠ AWS αʔ ϏεͰɺػೳ੍ݶ͕͋Γ·͢ʢޙड़ʣɻطʹ Chef ʹৄ͍͠ํ͸͝஫ҙ͍ͩ͘͞
  4. OpsWorks(1) -֓ཁ- “AWS OpsWorks ͸ɺ͢΂ͯͷछྨ͓ΑͼαΠζͷΞϓϦέʔγϣϯΛ༰қʹσϓ ϩΠ͓Αͼӡ༻Ͱ͖ΔΫϥ΢υΞϓϦέʔγϣϯ؅ཧαʔϏεͰ͢ɻ” Peritor ࣾͷ Scalarium Λ

    Amazon ͕ങऩ͠ 2013೥2݄ʹ OpsWorks ͱͯ͠ϩʔϯν Chef Solo ΛɺOpsWorks ಠࣗͷ֓೦Ͱ͋Δ LifeCycleEvents, Layer ্Ͱಈ͔͢ ϓϩϏδϣχϯάΑΓΦʔέετϨʔγϣϯʹ͍ۙαʔϏε ଞͷ AWS αʔϏεͰະରԠͷ΋ͷ΋͋Δ͕ɺগͣͭ͠૿͍͑ͯΔɿ σϑΥϧτVPC Ҏ֎ͷ VPC ͷར༻ RDS ͷར༻ ΧελϜ AMI ͷར༻ ELB ΁ͷରԠ
  5. OpsWorks(2) -ಛ௃- Πϯελϯε͸ 24/h, Time-based, Load-based ͕બ୒Մೳ Time-based ͸ܾ·ͬͨ࣌ؒʹͷΈىಈ͢ΔΠϯελϯε Load-based

    ͸ϨΠϠ಺ͷෛՙฏۉͷঢ়گʹԠͯ͡ىಈɾఀࢭ͢ΔΠϯελ ϯε
 OpsWorks Ͱ͸ AutoScaling ͕࢖͑ͳ͍ͨΊɺ͜Ε͕ AutoScaling ͷ୅ΘΓͱ ͳΔ ΞϓϦέʔγϣϯͷϩʔϧόοΫ͕Մೳʢະ֬ೝʣ Chef ʹ͸ͳ͍ػೳɻ5ੈ୅෼·ͰՄೳͱ͔ ଞΠϯελϯεͷ৘ใ͕ DataBagʢ࿈૝഑ྻʣʹ֨ೲ͞Ε͍ͯΔͨΊɺAWS ͷ API ͔Βλά৘ใͰΠϯελϯεΛߜΓࠐΜͰIPΞυϨεΛऔಘ… ͱ͍ͬͨΑ͏ ͳ໘౗ͳ࡞ۀ͕ཁΒͳ͍
  6. OpsWorks(3) -Chefؔ࿈- ΧελϜϨγϐ͸ site-cookbooks/ ഑Լʹ֨ೲ͢Δ΋ͷΛࢦఆ͢ΔͨΊɺ data_bags, environments, nodes, roles ͳͲͷػೳ͸Ϩγϐ಺͔Β͸ઃఆͰ͖ͳ͍

    nodes ͸ /var/lib/aws/opsworks/data/nodes ഑ԼʹΠϯελϯε͝ͱ ͷ json ͕֨ೲ͞Ε͍ͯΔʢOpsWorks ͕ੜ੒ͨ͠΋ͷʣ data_bags ͸ελοΫ͝ͱʹ OpsWorks ଆͰઃఆՄೳ
  7. ✅ Α͔ͬͨͱ͜Ζ Πϯελϯεͷঢ়گ΍ɺϨΠϠʹׂΓ౰͍ͨͬͯΔ ELB ͕ՄࢹԽ͞ΕΔ ͲͷΠϯελϯεʹ໰୊͕͋Δ͔ɺҰ໨Ͱ෼͔Δ νʔϜʹ৽͍͠ਓ͕ՃΘͬͨࡍ΋ɺݹ͍υΩϡϝϯτΛݟΔΑΓ෼͔Γ΍͍͢͸ͣ ʢωοτϫʔΫਤ͸ผͰ͢ʣ Configure ΠϕϯτͰଞΠϯελϯεʹ௨஌Ͱ͖Δͷ͕໘ന͍

    ελοΫશମͰ1ͭͷΞϓϦέʔγϣϯΛߏங͢Δɺ༗ػతͳಈ͖ʹͳΔ Deploy, Undeploy Πϕϯτ΋͋ΔͷͰɺOpsWorks ࢖ͬͯΕ͹ଞͷΦʔέετϨʔγϣϯ πʔϧʢSerf ͳͲʣ͸ཁΒͳ͍͔΋ ؂ࢹ΍ϞχλϦϯάର৅Λ௥͏ͷʹศར ELB Λܦ༝ͤͣɺઃఆϑΝΠϧͰෛՙ෼ࢄͤ͞Δ৔߹ʹ΋ॏๅʢfluentd ͷ forward ͳͲʣ ϨΠϠʹ஫ҙ͕޲͘ͷͰɺΠϯελϯεΛେࣄʹ͠ͳ͘ͳΔ ॊೈʹΠϯελϯε͕ೖΕସ͑Մೳͳӡ༻ʹʢAMI ӡ༻͔Βͷ୤٫ʣ AWS ͸ڧ੍ϝϯςφϯε͕͋ΔͷͰɺΠϯελϯεೖΕସ͕͑ग़དྷΔͱศར શϨγϐ͕ͨͼͨͼ࣮ߦ͞ΕΔͱɺϨγϐʹᆍ͕͔ͿΒͳ͍
  8. ❌ ΠϚΠνͳͱ͜Ζ Ϩγϐͷಈ࡞֬ೝதͷ଴͕ͪଟ͍ ৽ن Amazon AMI ͔ΒॳظઃఆΛߦ͏ͨΊɺॳճىಈ͸5෼ʙ10෼͔͔Δ ىಈதͷΠϯελϯε΁ͷϨγϐ࣮ߦ΋ɺݻఆͰ਺෼͸ֻ͔Δ ΧελϜ AMI

    ͕࢖͑ΔͷͰɺ࠷௿ݶͷॳظઃఆΛͨ͠΋ͷΛ༻ҙ͓ͯ͘͠ͷ΋Α͍͔΋ Load-based Πϯελϯεͷઃఆ͕ݪ࢝త ىಈڐՄ͢Δ࠷େΠϯελϯε਺·Ͱ͋Β͔͡Ίొ࿥͢Δͱ͍͏Ṗͷઃఆ ॳճىಈ͸5෼10෼ֻ͔ΔͷͰɺSetup Πϕϯτ͚ͩࡁ·͓ͤͯ͘ͷ͕Α͍Β͍͕͠ɺ࠷ େෛՙΛֻ͚Δඞཁ͕͋ΔͷͰ͔ͳΓΊΜͲ͍͘͞ AutoScaling ࢖͍͍ͨͰ͢ EIPʢݻఆIPʣ Λؒҧͬͯফͯ͠͠·͏͜ͱ͕͋Δ EC2 ͩͱΠϯελϯεΛ terminate ͯ͠΋ EIP ͸ফ͑ͳ͍͕ɺOpsWorks Ͱ͸ফ͑Δ ελοΫΛލ͍ͩҰׅσϓϩΠ͸Ͱ͖ͳ͍ ૉ௚ʹ API ࢖͍·͠ΐ͏
  9. ࢀߟจݙ ChefͱOpsWorksͰ EC2 ָνϯΫοΩϯά! / Ϋϥεϝιουגࣜձࣾ
 http://www.slideshare.net/classmethod/20130513-21235033?related=1 Πϯϑϥܥٕज़ͷྲྀΕ / @gosukenator

    ࢯ
 http://mizzy.org/blog/2013/10/29/1/ What is AWS OpsWorks?
 http://docs.aws.amazon.com/opsworks/latest/userguide/welcome.html ʲAWSൃදʳAWS OpsWorks - ChefΛ࢖ͬͯॊೈʹΫϥ΢υ಺ͷΞϓϦέʔγϣϯ؅ཧ͕Ͱ͖ Δ৽αʔϏεΛൃද
 http://aws.typepad.com/aws_japan/2013/02/aws-opsworks-flexible-application-management-in- the-cloud.html