Haconiwa - mrubyによるLinuxコンテナランタイム / haconiwa-fukuoka-ruby-award-presentation-2017

Haconiwa - mrubyによるLinuxコンテナランタイム / haconiwa-fukuoka-ruby-award-presentation-2017

福岡Ruby大賞本審査資料 @ 2017/03/01

2cf373725ded741824c50fd571eda6e1?s=128

KONDO Uchio

March 01, 2017
Tweet

Transcript

  1. Haconiwa mrubyʹΑΔॊೈ͔ͭಈతͳɺOSSͷLinuxίϯςφϥϯλΠϜ Presentation by Uchio Kondo

  2. ൃදऀʹ͍ͭͯ • ۙ౻͏͓ͪ / GMOϖύϘٕज़ج൫νʔϜ ϓϦϯγύϧ • ग़਎͸౦ࡾՏɺݱࡏ෱Ԭࢢ಺ࡏॅ • ίϛϡχςΟ:

    Fukuoka.rb
 ·ͨɺRailsGirls Fukuoka #1 ΦʔΨφΠβʔ • RubyKaigi 2016 Speaker
  3. ΞδΣϯμ 1. ιϑτ΢ΣΞͷ֓ཁ 2. औΓ૊ΈͷಈػͳͲ 3. ιϑτ΢ΣΞͷಛ௃ɾ༏Ґੑ 4. ࣮੷ͱࠓޙʹ͍ͭͯ 5.

    ࢀߟࢿྉ
  4. ιϑτ΢ΣΞͷ֓ཁ

  5. Haconiwaͱ͸ʁ • LinuxίϯςφͷϥϯλΠϜͰ͋Δ • Linuxίϯςφͱ͸...LinuxͷΧʔωϧͷ༷ʑͳػೳΛ༻͍ ͯಠཱͨ͠ҰछͷԾ૝؀ڥΛ࡞Δٕज़ • ϥϯλΠϜͱ͸...ͦͷԾ૝؀ڥΛ࡞੒͠ɺ্ཱͪ͛ɺϥΠ ϑαΠΫϧΛ؅ཧ͢Διϑτ΢ΣΞ

  6. Haconiwa͸Ͳ͏͍͏ϥϯλΠϜ͔ • LinuxίϯςφϥϯλΠϜʹ͸ɺޙड़͢Δ௨Γઌߦ࣮૷͕ ͍͔ͭ͘ଘࡏ͢ΔʢLXC, Docker, rkt, ...ʣɻ • Haconiwa͸ɺLinuxίϯςφϥϯλΠϜͷதͰ΋ɺ Ruby(mruby)ͷεΫϦϓτʹΑͬͯConfiguration

    as Code Λ࣮ݱ͢Δ
 ʢॊೈͳઃఆͷهड़ɺϑοΫͷهड़ͳͲʣ
  7. औΓ૊Έͷಈػ

  8. ݩʑͷಈػ • ͍ΘΏΔSaaSαʔϏε(*)ͷ։ൃɾӡ༻ͷܦݧ্ɺ಺෦Ͱ ར༻͍ͯ͠ΔίϯςφϥϯλΠϜ࣮૷ʹෆ଍Λײ͡ɺࣗ෼ ͷඞཁͱ͢ΔػೳΛ࣮૷ͨ͠΋ͷΛ࡞ͬͨɻ • ϗεςΟϯάܥαʔϏεͷதͰ࢖͏ͷ͕ͦ΋ͦ΋ͷಈػ • RubyKaigi 2016ͷCFPʹԠื͠ɺ௨աͨ͜͠ͱ΋͖͔ͬ

    ͚ͷҰͭ (*) http://sqale.jp/
  9. ։ൃͷաఔͰͷؾ͖ͮ • Πϯλʔωοτ͕େ͍ʹීٴ͠ɺ΢ΣϒαΠτ΁ͷΞΫηεٸ ૿ͳͲʹର͢ΔॊೈͳαʔόϦιʔεͷίϯτϩʔϧ͕՝୊ͱ ͳ͍ͬͯΔɻ • KubernetesͳͲͷ஫໨౓΋͋Δ௨ΓɺίϯςφԾ૝Խٕज़ʹ͓ ͚Δٕज़ֵ৽ʹظ଴͕͋Δ • ͦ͏͍ͬͨഎܠΛ౿·͑ɺΑΓ൚༻తͳίϯςφϥϯλΠϜʹ

    ͢΂͘։ൃΛଓ͚͍ͯΔ
  10. Rubyͷ࠾༻ಈػ • ։ൃͷ౰ॳ͔ΒɺʮॊೈͰϓϩάϥϚϒϧʯͳ͜ͱΛ૝ఆ • PaaS಺෦ͰͷϦιʔεׂΓ౰ͯɺΞΫηεٸ૿࣌ͷϦιʔ εͷߜΓࠐΈɺFastContainer(*)ͳͲ৽ΞʔΩςΫνϟ΁ ͷରԠ • ͦ͏͍ͬͨ໨తʹRuby͸ඇৗʹ޲͍͍ͯΔ (*)

    http://hb.matsumoto-r.jp/entry/2016/11/11/234915
  11. RubyͷϝϦοτ ͦͷ1 • ಺෦DSLͱͷ૬ੑͷྑ͞
 ίϯςφهड़ݴޠ͸ɺઃఆͱϓϩάϥϜͷͪΐ͏Ͳதؒ • namespace/cgroup/capabilityͳͲͷࢦఆʹઃఆ • ίϯςφىಈ࣌ͷಉظ/ඇಈػͷϑοΫɺγάφϧϋϯυϥ
 ʹϓϩάϥϜ

    • Rubyͷจ๏Ͱ͋Ε͹ɺ಺෦DSLͱͯ͠౷Ұతʹهड़Մೳ
  12. RubyͷϝϦοτ ͦͷ2 • mruby͸૊ΈࠐΈʹ޲͍ͨɺચ࿅͞ΕͨCͷAPIΛ࣮૷͍ͯ͠ Δɻͦͷ෭࢈෺ͱͯ͠ɺCݴޠΛܦ༝ͨ͠γεςϜίʔϧͷόΠ ϯσΟϯά͕ඇৗʹॻ͖΍͘͢ͳ͍ͬͯΔ • ·ͨɺΞΫηε͢ΔͨΊͷίʔυྔ΋Cͱͯ͠͸খ͘͞ࡁΉ • ࣮੷ͱͯ͠ɺ༷ʑͳmruby

    gemΛ࡞੒ࡁΈ:
 ɹcgroup, capability, linux namespace, seccomp...
  13. ιϑτ΢ΣΞͷ ಛ௃ɾ༏Ґੑ

  14. طଘ࣮૷ʹൺ΂ͨ༏Ґੑ - ॊೈੑ • ྫ͑͹Dockerͱൺ΂ͯ: • Docker͸Ծ૝؀ڥͱͯ͠ͷಠཱੑΛॏࢹͨ݁͠Ռɺີ݁߹ͷ ίϯςφͰ͋Δ • ҰํͰHaconiwa͸ɺඞཁͳίϯϙʔωϯτΛ૊Έ߹Θͤɺঢ়

    گʹԠͯ͡ແޮԽ͢Δ͜ͱ͑͞Ͱ͖·͢ɻྫ͑͹ىಈ࣌ͷΦʔ όϔουͷ࡟ݮͳͲɺΑΓଟ͘ͷ༻్ʹίϯςφΛར༻Ͱ͖Δ
  15. طଘ࣮૷ʹൺ΂ͨ༏Ґੑ - ಈతͳੑ࣭ • ྫ͑͹LXCͱൺ΂ͯ: • LXC΋APIΛ࣋ͪɺόΠϯσΟϯάΛ࡞੒Ͱ͖Δɻ͔ͦ͠͠ͷAPI ͸ىಈɺఀࢭͳͲɺݶఆతͳૢ࡞ͷΈ • ҰํͰHaconiwa͸ɺίϯςφʹؔ͢Δઃఆ஋͸Ұ௨Γ͢΂ͯ

    DSLͰઃఆՄೳɻͳ͓͔ͭɺىಈͷ༷ʑͳλΠϛϯάͰ͋ͬͨ Γɺ͋Δ͍͸γάφϧϋϯυϥ΍ɺىಈޙͷඇಉظతϑοΫॲཧ ΋αϙʔτ͢ΔͨΊɺΑΓϓϩάϥϜͳͲͰͷ੍ޚ͕༰қͰ͋Δ
  16. طଘ࣮૷ʹൺ΂ͨ༏Ґੑ - อकੑ • ྫ͑͹rkt(CoreOS)/Kubernetesͱൺ΂ͯ: • rkt͸ଟ͘ͷઃఆΛαϙʔτ͢Δ͕ɺίϚϯυϥΠϯΦϓγϣ ϯͰͷड͚ೖΕͱͳΔ
 Kubernetes͸ΦʔέετϨʔγϣϯπʔϧ͕ͩɺHaconiwaͷ ໨ࢦ͢ํ޲ੑʹ͍ۙ΋ͷ͕͋Δɻ


    ҰํͰɺઃఆ͸ڊେͳyamlϑΝΠϧͷΈ
  17. طଘ࣮૷ʹൺ΂ͨ༏Ґੑ - อकੑ • ʢঝલʣॊೈͰෳࡶͳίϯςφઃఆɺ͋Δ͍͸ΦʔέετϨʔ γϣϯ૚ͱͷ࿈ܞΛߟ͑ΔͱɺͦΕΒͷઃఆ΍ಈ࡞ΛRuby ͷΑ͏ͳݴޠͰهड़ͨ͘͠ͳΔ͜ͱ͕ߟ͑ΒΕΔɻ • HaconiwaͷΑ͏ʹઃܭࢥ૝ͷஈ֊ͰDSLʹΑΔ੍ޚΛα ϙʔτͨ͠ίϯςφ͸ɺͦ͏͍ͬͨཁ๬Λड͚ࢭΊΒΕΔɻ


    RubyΛ࠾༻͍ͯ͠ΔͷͰֶश͠΍͢͞/Մಡੑ΋ߴ͍
  18. ֵ৽ੑʹ͍ͭͯ • ઌड़ͨ͠Α͏ʹɺHaconiwa͸DSLΛࠜຊͱͨ͠ॊೈੑɺ ಈతੑΛ࣮ݱ͍ͯ͠Δ • ͦͷ݁ՌɺʮίϯςφʯΛݻఆతͳԾ૝؀ڥͰ͸ͳ͘ɺ
 ϓϩάϥϜͰ੍ޚ͕ՄೳͳεϨουతͳ΋ͷ΁ͱൃలͤ͞ ͏Δɺͱߟ͑Δ

  19. HaconiwaͷγεςϜίʔϧతଆ໘ • ίϯςφ࣮ߦج൫ͱͯ͠ɺOSͷू߹ମΛҰͭͷʮOSʯɺ ͋Δ͍͸ϦιʔεͷϓʔϧͱΈͳ͢ͱɺίϯςφͷάϧʔ ϓ͕ϓϩηεతɺίϯςφҰͭҰͭ͸εϨουతͳɺ͋Δ छ࢖͍ࣺͯͷαϒϧʔνϯͱ؃၏ͤΔ • ͦ͏ߟ͑ΔͱɺͦͷίϯςφΛࣗ༝ࣗࡏʹ࡞੒ɺΞΫηε Ͱ͖ΔHaconiwaͷ಺෦API͸ɺγεςϜίʔϧతͰ͋Δ

  20. • චऀൃදʮHaconiwaͷத਎ͱઃܭࢥ૝ʯp. 36

  21. “Haconiwa API”ͷҰ࣮૷͕Haconiwa • c.f. specinfra/Serverspec • ʮHaconiwaͷ಺෦APIʯΛΑΓ൚༻తʹൈ͖ग़͢ͱɺ Haconiwaࣗ਎ͷଞʹɺίϯςφΛར༻༷ͨ͠ʑͳϛυϧ ΢ΣΞΛ࡞Δ͜ͱ͕Ͱ͖ΔͷͰ͸ͳ͍͔

  22. ࣮੷ͱࠓޙͷల๬

  23. ٕज़ൃදଞɺ࣮੷ʹ͍ͭͯ • RubyKaigi 2016ɺ໊ݹ԰Rubyձٞ03Λ࢝ΊɺRubyίϛϡ χςΟத৺ʹHaconiwaʹؔ͢ΔτʔΫΛॏͶ͍ͯΔஈ֊ • ଞɺ஫໨౓ͱͯ͠͸ɺGitHubͷϓϩδΣΫτͷ
 ελʔ਺͕97 (2017೥2݄22೔ݱࡏ)

  24. ࠓޙʹ͍ͭͯ 1 • ઌड़ͨ͠ίϯςφ࣮ߦج൫ͱͯ͠ͷOSΫϥελͷൃ૝Λ͞Βʹਐ Ίͨɺদຊ྄հࢯͷFastContainerߏ૝(*)Λ౿·͑ɺॴଐձࣾͰ
 ϗεςΟϯάܥWebαʔϏεͷ։ൃΛਐΊ͍ͯΔஈ֊Ͱ͋Δ • FastContainerͷΑ͏ͳੜଘظؒͷίϯτϩʔϧ͞Εͨίϯςφ ͸Haconiwaͱ૬ੑ͕͍͍ •

    ྫ͑͹ɺʮαʔόϨεΞʔΩςΫνϟʯͷ࣮ݱʹ޲͍͍ͯΔ
  25. • ʮFactContainerΞʔΩςΫνϟ֓࿦ʯΑΓ

  26. ࠓޙʹ͍ͭͯ 2 • ίϯςφϥϯλΠϜͱͯ͠ͷ׬੒౓ͷ޲্Λ໨ࢦ͢ • ۩ମతʹ͸ɺseccomp/apparmorͱ͍ͬͨηΩϡϦςΟؔ ܎ͷAPIͷαϙʔτ΍ɺCRIUͱ͍ͬͨίϯςφىಈͷߴ଎ Խʹ໾ཱٕͭज़ͱͷ࿈ܞΛߟ͍͑ͯΔ • ಉ࣌ʹυΩϡϝϯτͷॆ࣮΋......͍ͨ͠

  27. ૯ׅ

  28. Haconiwaͷ·ͱΊ • Haconiwa͸ɺྨࣅͷ࣮૷ͱൺ΂ͯඇৗʹಈతͰॊೈͳίϯςφΛ࡞੒ Ͱ͖ΔϥϯλΠϜͰ͋Γɺͦͷ࣮ݱͷͨΊʹRuby/mrubyͷੑ࣭Λ׆༻ ͍ͯ͠Δɻ • Haconiwa͸ɺίϯςφ࣮૷ج൫ͷOSͷΫϥελΛͻͱ·ͱ·ΓͷOS ͱΈͳ͢ͱɺҰछͷγεςϜίʔϧͱߟ͑Δ͜ͱ΋Ͱ͖Δ • ্ड़ͨ͠Α͏ͳHaconiwaͷಛ௃Λ׆༻͠ɺ࣍ੈ୅తͳϗεςΟϯάܥ

    ͷαʔϏεΛߟҊɾ։ൃ͍ͯ͠Δ
  29. ࢀߟࢿྉ

  30. ࢿྉҰཡ 1. Haconiwaʹؔ͢Δࢿྉ
 The introduction of mRuby on Container https://speakerdeck.com/udzura/mruby-on-container


    Haconiwaͷ͜Ε·Ͱͱ͜Ε͔Β https://speakerdeck.com/udzura/haconiwa-on-the-pavement
 Haconiwa ͷத਎ͱઃܭࢥ૝ https://speakerdeck.com/udzura/the-haconiwa-internals 2. FastContainer/DAOSߏ૝ʹ͍ͭͯ
 FastContainerΞʔΩςΫνϟ֓࿦ https://speakerdeck.com/matsumoto_r/reactive-stateless-and-mortal- architecture-for-web-applications
 ະདྷͷαʔόج൫΁ͷHaconiwa/mrubyͷؔΘΓ https://speakerdeck.com/udzura/haconiwa-and-future-os 3. Serverspecͱspecinfraʹ͍ͭͯ
 ࠷ॳͷݴٴ https://github.com/mizzy/serverspec-thesis/pull/13#issuecomment-32700180 4. αʔόϨεΞʔΩςΫνϟʹ͍ͭͯ
 http://www.publickey1.jp/blog/16/qcon_tokyo_2016.html