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

アプリケーションエンジニアが既存のマルチコンテナ環境をRancher管理に移行しようとしてハマった話

machshev
October 13, 2017

 アプリケーションエンジニアが既存のマルチコンテナ環境をRancher管理に移行しようとしてハマった話

RancherJP Meetup #2 in Sapporo LT

machshev

October 13, 2017
Tweet

More Decks by machshev

Other Decks in Programming

Transcript

  1. ΞϓϦέʔγϣϯΤϯδχΞ͕
    طଘͷϚϧνίϯςφ؀ڥΛ
    Rancher؅ཧʹҠߦ͠Α͏ͱͯ͠
    ϋϚͬͨ࿩
    2017/10/12
    ϥςϥϧɾγϯΩϯάʢגʣɹ஛୩஧޾

    View full-size slide

  2. ࣗݾ঺հ
    u ໊લɿ஛୩஧޾
    u ॴଐɿϥςϥϧɾγϯΩϯάגࣜձࣾ

    ɹɹɹγεςϜ։ൃ෦
    u ଐੑɿΞϓϦέʔγϣϯɾΤϯδχΞ

    ɹɹɹʢࣗশɿࣾ಺Ҋ݅ͷ૟͖ཷΊʣ
    u झຯɿࣗసंʢϩʔυόΠΫɾMTBʣ

    ɹɹɹΨϯμϜΑΓ΋ϚΫϩε೿Ͱ͢ɻ

    ɹɹɹSNS͸΄ͱΜͲFacebook OnlyͰ͢ɻ

    View full-size slide

  3. Rancherͱࢲʢ1ʣ
    u ࣾ಺Ͱओʹडୗ։ൃΛ͍ͯͯ͠ɺҊ݅ຖʹ

    ຖճಉ͡Α͏ͳߏ੒ͰαʔόʔΛߏங͠ͳ͚Ε͹

    ͳΒͳ͍ͨΊɺن໛͕େ͖͘ͳΔͱ޻਺΋͹͔ʹ
    ͳΒͳ͍ɻ
    u ϝϯόʔ͕֤ࣗͰखಈͰΠϯετʔϧ͍ͯͨͨ͠Ίɺ
    ؀ڥࠩ෼͕ൃੜ͠ɺͬͪ͜Ͱ͸ಈ͕͋ͬͪ͘Ͱ͸
    ಈ͔ͳ͍ͱ͍͏Α͏ͳ͜ͱ͕ىͬͨ͜ɻ

    View full-size slide

  4. Rancherͱࢲʢ2ʣ
    ͍͍ͪͪ؀ڥΛ࡞Βͳͯ͘΋͍͍ํ๏͸ͳ͍͔ʁ
    ɹ㱺ChefΛࢼ͢
    ɹ㱺؀ڥߏஙஈ֊Ͱ࠳ં orz
    ɹ㱺ɹɹɹɹɹɹɹɹɹΛ࢖ͬͯΈΔ
    ɹ㱺WindowsҎ֎ͳΒԿͱ͔͍͚ͦ͏ʢޙʹղܾʣ

    View full-size slide

  5. Rancherͱࢲʢ3ʣ
    u ͱΓ͋͑ͣɺࣾ಺ͰΑ͘࢖͏LAMPߏ੒ͷϚϧν

    ίϯςφ؀ڥΛDockerΛ࢖ͬͯߏஙͯ͠Έͨɻ

    Apacheʢnginxʣ+ FuelPHP + MySQL

    View full-size slide

  6. Rancherͱࢲʢ4ʣ
    u ͱΓ͋͑ͣɺࣾ಺Ͱ։ൃʹ࢖༻Ͱ͖Δఔ౓ͷ

    ίϯςφ͕࡞੒Ͱ͖ͨͷͰɺখ͞ͳҊ͔݅Β

    ӡ༻։࢝ɻ
    u Ͱɺࠓ౓͸ʮ࡞ͬͨίϯςφͷ؅ཧΛͲ͏͠Α͏ʯ

    ໰୊͕ൃੜɻ
    u DockerfileͦͷଞͷιʔεΛGit؅ཧʁ
    u Docker ImageࣗମΛGit؅ཧʁ
    u DockerHubͳͲͷdocker registryʹอ؅ʁ

    View full-size slide

  7. Rancherͱࢲʢ5ʣ
    u Rancherͱ͔͍͏αʔϏεΛ࢖͏ͱίϯςφͷߏ੒
    ΛؚΊͯ؅ཧͰ͖ΔΒ͍͠…
    u ͱ͍͏࿩Λࣾ಺Ͱݟ͔͚ͨ࣌ʹɺࡳຈͰRancher
    Meetup #1 in Sapporo͕։࠵͞ΕΔͷΛ஌ͬͯ

    ࢀՃͨ͠ͷͰͨ͠ɻ

    View full-size slide

  8. ɹɹɹɹɹɹɹɹɹɹɹΛ࢖ͬͯΈͨ
    u DocumentΛಡΈͳ͕Βɺ؀ڥߏஙΛߦͬͯΈΔɻ

    㱺Rancherࣗମͷىಈʹ͸੒ޭʢޙड़ʣ
    u Ͱɺ͔͜͜Β͍Ζ͍Ζͱ໰୊͕…

    ʢલ΋ͬͯએݴ͓͖ͯ͠·͕͢ɺDocumentΛ

    ɹͪΌΜͱಡΊͱ͍͏ۤ৘͸ड͚෇͚·ͤΜʣ

    View full-size slide

  9. ɹɹɹɹɹɹɹɹɹɹɹͰϋϚͬͨ఺ᶃ
    u ͦ΋ͦ΋Docker-compose.yml͕Ver.1ॻࣜͰॻ͔Ε
    ͍ͯΔɻ

    㱺ͦͷ··Ͱ΋ߦ͚ͨͷ͔΋͠Ε·ͤΜ͕ɺෆ҆ͩͬ
    ͨͷͰɺVer.2ॻࣜʹमਖ਼͠·ͨ͠ɻ

    View full-size slide

  10. ɹɹɹɹɹɹɹɹɹɹɹͰϋϚͬͨ఺ᶄ
    u ͦ΋ͦ΋ImageϑΝΠϧ͕PullͰ͖Δঢ়گʹͳ͍ɻ

    㱺RancherʹAdd StackͰDocker-compose.ymlϑΝ
    ΠϧΛొ࿥͠Α͏ͱ͢ΔͱImageλά͕ͳ͍ͱౖΒ
    Εͨɻ

    ͦ΋ͦ΋DockerfileΛ࡞͔ͬͯͦ͜Β࡞ۀͯ͠΋
    Β͍ͬͯͨͷͰɺDocker ImageΛ࡞੒͍ͯ͠ͳ͍ɻ

    ࢓ํ͕ͳ͍ͷͰɺDockerHubʹΞΧ΢ϯτΛ༻ҙ͠
    ͯɺΞοϓՄೳͳ΋ͷ͸શͯDocker ImageΛ࡞੒͠
    ͯొ࿥ɻʢGitLab CEΛ࢖͑ͬͯ࿩΋…ʣ

    View full-size slide

  11. ɹɹɹɹɹɹɹɹɹɹɹͰϋϚͬͨ఺ᶅ
    u RancherʹAdd StackͰDocker-compose.ymlϑΝΠ
    ϧΛొ࿥͠Α͏ͱ͢ΔͱผͷΤϥʔ͕ൃੜͨ͠ɻ

    㱺ImageλάΛ௥Ճͨ͠Docker-compose.ymlϑΝΠ
    ϧΛ࠶౓Rancherʹొ࿥͠Α͏ͱͨ͠ͱ͜Ζɺొ࿥
    ࣌ʹcattleؔ܎ͷΤϥʔʢError (open /var/lib/
    cattle/xxxxʢ͜ͷ͋ͨΓ͕ෆ໌ʣ: no such file or
    directory) ʣ͕ൃੜͨ͠ɻ

    u 㱺࣍ϖʔδ΁

    View full-size slide

  12. ɹɹɹɹɹɹɹɹɹɹɹͰϋϚͬͨ఺ᶆ
    u RancherʹDocker-compose.ymlϑΝΠϧΛొ࿥͠Α
    ͏ͱ͢ΔͱΤϥʔ͕ൃੜͨ͠ɻ

    㱺ݱࡏͷͱ͜ΖݪҼෆ໌͕ͩɺڪΒ͘ݕূ༻͔ͩΒ
    ͱ͍ͬͯɺແਫ਼ͯ͠Mac্ͷDockerʹߏஙͨ͠ͷ͕
    ݪҼͱࢥΘΕΔʢ΋ͪΖΜඇਪ঑Ͱ͢ʣ

    㱺࢓ํ͕ͳ͍ͷͰɺVirtualBoxͰUbuntu؀ڥΛ࡞੒
    ͠ɺͦΕͰRancher؀ڥΛ࠶ߏஙத…

    View full-size slide

  13. ·ͱΊ
    u ͱ͍͏Θ͚Ͱɺ

    ·ͩಈ͔ͤΔ؀ڥ͕Ͱ͖͍ͯ·ͤΜ
    u ͨͩ։ൃऀʹͱͬͯ΋࢖͍͜ͳͤΕ͹ɺඇৗʹ༗
    ༻ͳߏ੒؅ཧπʔϧʹͳΓ͏Δͱࢥ͍·͢ͷͰɺ
    Ver2΋ग़ͦ͏Ͱ͢͠ɺ͜Ε͔Β΋औΓ૊ΜͰߦ͖ͨ
    ͍ͱࢥ͍·͢ɻ

    u ͱ͍͏Θ͚Ͱ…

    View full-size slide

  14. ·ͱΊ
    uউखʹ࣍ճͷLTʹଓ͖·͢ʂ

    ΑΖ͓͘͠ئ͍͍ͨ͠·͢ʂ



    طଘͷDocker-compose.ymlʹ߆ΒͣʹɺΠν͔Β࡞Γ௚ͨ͠ํ͕ૣ͍͔΋ͱ
    ࢥ͍ͬͯΔͷ͸φΠγϣͰ͢

    View full-size slide

  15. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ

    View full-size slide