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

僕とHaconiwa /haconiwa-intro

僕とHaconiwa /haconiwa-intro

KIXS #0 LT 大会にて
https://kixs.doorkeeper.jp/events/49820

2cf373725ded741824c50fd571eda6e1?s=128

KONDO Uchio

August 29, 2016
Tweet

Transcript

  1. ͋Δ͍͸Լ๺ܥΠϯσΟʔόϯυγʔϯʹ͍ͭͯ 6DIJP,POEP ,*94 ๻ͱ)BDPOJXB GSPNIUUQTIPXDBTFDJUZGVLVPLBMHKQBMMSJHIUTSFTFSWFE

  2. ΤϯδχΞ݉ਓؒ 6DIJP,POEP!VE[VSB (.0ϖύϘٕज़ج൫νʔϜ

  3. !VE[VSBͷਓؒྺ ೥΄Ͳ3VCZਥͱͯ͠ΞοϓϦέʔγϣ ϯΤϯδχΞΛܦݧ͠ɺۀ຿γεςϜɺ &$αΠτɺΦϯϥΠϯήʔϜͳͲΛ ܦͯϖύϘ΁ɻͦΕͱҰॹʹౚژ͔Β ෱ԬʹҠॅ͢Δɻ ϖύϘͰ͸ྲྀΕͰ1VQQFUΛओʹ৮Δ ۀ຿ʹैࣄ͍͕ͯͨ͠ɺ࠷ۙ͸$ݴޠ ͱNSVCZͰγεςϜϓϩάϥϛϯάॳ ৺ऀͱͯ͠ؤு͍ͬͯΔɻ

    ޷͖ͳϙέϞϯൃੜ஍Ҭ͸ඦಓ඿ɻ
  4. ΞϨ͸Ͱ͢CZ=

  5. )BDPOJXBͱ͸

  6. )BDPOJXBͱ͸ wίϯςφΤϯδϯ w࠷େͷಛ௃͸ɺ3VCZ NSVCZ Ͱίϯςφͷઃఆ͕ࣗ༝ࣗࡏʹॻ͚Δ͜ͱ w%PDLFSΛଧ౗͠ͳ͍͚Ͳɺ%PDLFSͰ͸ϠϦͮΒͦ͏ͳ͜ͱ͸Ͱ͖Δ͔΋ʁ

  7. ίϯςφΤϯδϯͱ͸ wίϯςφ͸૊Έ߹Θͤɻ w۩ମతʹ͸ɺ-JOVYOBNFTQBDFɺDHSPVQɺ-JOVYDBQBCJMJUJFTɺ DISPPUɺCJOENPVOUɺͳΜ΍͔΍Λ૊Έ߹ΘͤͯɺϓϩηεʢͷҰ܈ʣΛ ͔͋ͨ΋Ծ૝؀ڥͷΑ͏ʹݟͤͯ׆༻͢Δٕज़ w)BDPOJXB͸ɺ͜ͷؔ࿈ٕज़Λૢ࡞͢ΔNSVCZHFNΛͻͨ͢Β࡞Γ·͘Γɺ ૊Έ߹Θͤͯɺίϯςφ؀ڥΛ࣮ݱ͍ͯ͠·͢ɻ

  8. ໊લͷ༝དྷ w·Μ·ʮശఉʯͳΜ͚ͩͲɺ௕͘ͳΓ·ͯ͠ w΋ͱ΋ͱɺ೔ຊͰҰ൪༗໊ͳKBJMͰ͋Δʮ"CBTIJSJʯͱ͍͏໊લΛ͚ͭΑ͏ͱ wࢥ͚ͬͨͲɺઑΓ͔͗͢ͳͬͯࢥ͍௚͠

  9. ໊લͷ w࣍ʹࢥ͍͍ͭͨͷ͕ɺԼ๺୔ͰΠϯσΟʔόϯυͱͯ͠׆༂͍ͯͨ͠ʢࠓ΋ͨ ·ʹϥΠϒΛ͍ͯ͠Δʣʮശఉͷࣨ಺ָʯͱ͍͏ɺۂ͕جຊతʹมഥࢠͷɺι ϑτϚγʔϯͱϖΠϰϝϯτΛ଍ͯ͠ແཧ਺ͰׂͬͨΑ͏ͳόϯυ͕͋Γɺ wʢҎԼ෼͙Β͍ɺθϩ೥୅ͷԼ๺୔ΠϯσΟʔζϩοΫͷ࿩Λ͢Δʣ

  10. ͱ͜ΖͰɺ๻ʹ͸ɺϓϩάϥϚͱͯ͠ເ͕͋ͬͨ wҰ౓Ͱ͍͍͔Βɺࣗ෼ͷ޷͖ͳόϯυ͋Δ͍͸ۂͷ໊લͷ෇͍ͨ w044ϓϩμΫτΛ wੈʹग़͔ͨͬͨ͠ wग़͔ͨͬͨ͠Μͩʂ

  11. ׎ͬͨ

  12. ࠓ೔ͷ·ͱΊເ͸׎͏

  13. ؓ࿩ ٳ୊ GSPNIUUQTIPXDBTFDJUZGVLVPLBMHKQBMMSJHIUTSFTFSWFE

  14. )BDPOJXBΛ෼Ͱࢼ͢

  15. ͜ͷઌɺ3VCZ,BJHJ޲͚ͷࢿྉΛ ྲྀ༻͍ͤͯͩ͘͞͞ɻɻɻɻɻɻ

  16. ͔ͩΒϑΥϯτ΋มΘΓ·͢ʂʂ̍

  17. Πϯετʔϧ w QBDLBHFDMPVE͔Βམͱͤ·͢ɻ؆୯Ͱ͢Ͷʂ
 IUUQTQBDLBHFDMPVEJPVE[VSBIBDPOJXBJOTUBMM # example for deb-ish distro curl

    -s https://packagecloud.io/install/repositories/udzura/ haconiwa/script.deb.sh | sudo bash apt-get update apt-get install haconiwa apt-get install lxc # It’s required to bootstrap fs
  18. ࠷ॳʹઃఆϑΝΠϧΛੜ੒͠·͢ $ haconiwa new test.haco assign new haconiwa name =

    haconiwa-0491a405 assign rootfs location = /var/lib/haconiwa/0491a405 create test.haco
  19. ͜ͷઃఆϑΝΠϧ͸࣮ࡍͨͩͷ3VCZεΫϦϓτͰ͢

  20. lIBDPOJXBDSFBUFzͰϑΝΠϧγεςϜΛ࡞Γ·͢ w ੜ੒͞Εͨ··ͩͱBMQJOFMJOVY͕MYDDSFBUFͰ࡞ΒΕ·͢

  21. TTIEΛΠϯετʔϧͯ͠ةݥͳઃఆΛ͠·͢ Haconiwa.define do |config|
 #...
 config.provision do |p| p.run_shell <<-SHELL

    apk add --update openssh sed -i 's/#Port.*/Port 2222/' /etc/ssh/sshd_config # NOTE: αϯϓϧ͔ͩΒͶʂ sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config sed -i 's/#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config echo root:r00t | chpasswd ssh-keygen -t rsa -P "" -f /etc/ssh/ssh_host_rsa_key SHELL end #... end
  22. lIBDPOJXBQSPWJTJPOzͰ΋͏Ұ౓ϓϩϏδϣχϯά

  23. lJOJUzίϚϯυΛTTIEʹม͑ͯɺσʔϞϯԽ͠·͢ Haconiwa.define do |config| # The container name and container's

    hostname: config.name = "haconiwa-0491a405" # The first process when invoking haconiwa run: # config.init_command = "/bin/bash" # To: config.init_command = %w(/usr/sbin/sshd -D) # And uncomment: config.daemonize!
 #...
 end $ haconiwa run test.haco
  24. None
  25. ຬ଍ͨ͠ΒɺlIBDPOJXBLJMMzͰ΍͚ͬͭ·͢ $ haconiwa kill test.haco Kill success

  26. Ҏ্ʂ

  27. ׂͱͪΌΜͱίϯςφͰ͖ͯͳ͍ʁ

  28. ͍͚Δͬͯʂ

  29. ྫ͑͹͜͏͍͏࣌ʢ༧ఆʣ wϗετͱ৭ʑͳOBNFTQBDFΛڞ༗ͨ͠؀ڥΛ࡞Γ͍ͨ wੜ੒࣌ʹɺಈతʹDHSPVQͷύϥϝʔλΛม͍͑ͨ wͳΜ͔ෳࡶͳCJOENPVOUΛܦͯSPPUGTΛ࡞Γ͍ͨ w%̋DLFSΑΓܰΊʹϚΠΫϩαʔϏοε͍ͨ͠ͳʙʙʙ͋ʙʙʙʙ wͳͲͳͲ wকདྷతʹɺΦʔέετϨʔγϣϯ૚΋αϙʔτ͍ͨ͠ɺͰ͖Δͱ͍͍Ͱ͢Ͷ

  30. ͪͳΈʹ wFUDE qBOOFMͱ૊Έ߹ΘͤͯΦʔόϨΠωοτϫʔΫͳΜ͔΋ wOFUOT͸ࣗ࡞͍ͯͩ͘͠͞ʢͦΕΛIBDPOJXB͸࠶ར༻Ͱ͖·͢ʣ

  31. ˞ࠓճ͸ಈ͖·ͤΜ

  32. ৬ਓͷ࡞ΔOFUOT͔Β QJOHΛଧͭͱɺ ύέοτʹஆ͔Έ͕͋Δ

  33. ӕͰ͍ۙ͢͏ͪʹ )BDPOJXBʹ૊ΈࠐΈ·͢ ͳΜ͔ܰͯ͘ૄ݁߹ͳ΍ΓํΛߟ͍͑ͨͰ͢Ͷ

  34. ·ͱΊ·͢

  35. ࠓ೔ͷ·ͱΊ w)BDPOJXB͸Լ๺୔ܥมഥࢠίϯςφͰ͢ w)BDPOJXBͷৄࡉΛ஌Γ͍ͨํ͸ɺͥͻ࠶དྷिͷ3VCZ,BJHJ΁ʂ wژ౎ͰѲखʂ

  36. None
  37. 

  38. )BDPOJXBJTVOEFSEFWFMPQNFOU  Ͱ͕͢ɺ༡ΜͰΈͯͶ