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

カラーミーショップのクラウドネイティブに向けた取り組み

87cc3b4ffeb28446da380c5acdcf443e?s=47 takapi86
December 24, 2020

 カラーミーショップのクラウドネイティブに向けた取り組み

Pepabo Tech Conference #13
https://pepabo.connpass.com/event/197089/

87cc3b4ffeb28446da380c5acdcf443e?s=128

takapi86

December 24, 2020
Tweet

Transcript

  1. 1 Χϥʔϛʔγϣοϓͷ Ϋϥ΢υωΠςΟϒʹ޲͚ͨ औΓ૊Έ ECࣄۀ෦ Χϥʔϛʔγϣοϓ αʔϏεج൫νʔϜɹ∁ڮ༤ل

  2. 2 2 ࣗݾ঺հ • ໊લ: ∁ڮ༤ل • Twitter: @takapi86 •

    ॴଐ: GMOϖύϘ ECࣄۀ෦ Χϥʔϛʔγϣοϓάϧʔϓ αʔϏεج൫νʔϜ • WebΞϓϦέʔγϣϯΤϯδχΞ • ۀ຿Ͱ΍͍ͬͯΔ͜ͱ ◦ ϨΨγʔ؀ڥͷվળ ◦ ηΩϡϦςΟڧԽ
  3. 3 3 ࠓ೔͓࿩͢Δ͜ͱ ΧϥʔϛʔγϣοϓͷΫϥ΢υωΠςΟϒʹ޲͚ͨऔΓ૊Έ • લ൒ύʔτ ◦ Մ༻ੑΛ޲্ͤ͞ΔͨΊͷऔΓ૊ΈɺShopSetΞʔΩς Ϋνϟʹ͍ͭͯ •

    ޙ൒ύʔτ ◦ Kubernetesಋೖࣄྫ ϝʔϧϚΨδϯ഑৴Φϓγϣϯ
  4. 4 4 Χϥʔϛʔγϣοϓͷ঺հ ຊؾͰωοτϏδωεΛ࢝Ί͍ͨํ޲͚ͷ ωοτγϣοϓ࡞੒αʔϏε

  5. 5 Մ༻ੑΛ޲্ͤ͞ΔͨΊͷऔΓ૊ΈɺShopSetΞʔΩς Ϋνϟʹ͍ͭͯ 5

  6. 6 6 boost2020 ϓϩδΣΫτ͕ൃ଍ʂʂ • ৽ܕίϩφՒʹ͓͍ͯɺωοτγϣοϐϯάͷར༻ऀ͕ٸ૿ ◦ ECͷαʔϏεʹର͢Δظ଴ײ͸ߴ·͍ͬͯΔ⬆⬆ • ೔ຊதͷ঎͍Λ͢Δࣄۀऀ͕ͳΊΒ͔ʹΧϥʔϛʔγϣοϓ

    Λ׆༻ͨ͠ΦϯϥΠϯࣄۀܗଶ(EC)ʹDX͢Δ͜ͱΛՃ଎ͤ͞ ΔͨΊͷऔΓ૊Έ ◦ ϓϩϞʔγϣϯϨϕϧͷ޲্ ◦ γεςϜϨϕϧͷ޲্ ࣛࣇౡݶఆͰTVCM΋์ө͞Ε·ͨ͠ʂ
  7. 7 7 γεςϜϦΞʔΩςΫνϟ • boost2020ͷऔΓ૊ΈͷҰͭ • ओʹՄ༻ੑ޲্΁ͷνϟϨϯδ • νʔϜମ੍ ◦

    ΠϯϑϥΤϯδχΞ2໊ ◦ ΞϓϦέʔγϣϯΤϯδχΞ1໊
  8. 8 8 ͳͥՄ༻ੑ޲্͍͔ͤͨ͞ʁ ৽ܕίϩφՒʹ͓͍ͯɺΧϥʔϛʔγϣοϓͷళฮͰങ͍෺Λ ͢ΔϢʔβ͕ٸ૿ ◦ τϥϑΟοΫ૿େ ◦ ηʔϧͳͲͷΞΫηεूத =>

    ΞΫηε஗ԆɺγϣοϓӾཡෆՄͳͲͷӨڹ͕ൃੜ
  9. 9 ୈ1ஈରԠʢݱࡏͷߏ੒ʣ NyahʢϓϥΠϕʔτOpenStack؀ڥʣ্ͷΠϯελϯεʹɺ ֤ϩʔϧͷΞϓϦέʔγϣϯ͕σϓϩΠ͞Ε͍ͯΔ ฼؋A ฼؋B γϣοϓϖʔδ Χʔτϖʔδ API ϩʔυόϥϯα

    ϩʔυόϥϯα ฼؋A ฼؋B γϣοϓϖʔδ Χʔτϖʔδ API ϩʔυόϥϯα ϩʔυόϥϯα ຊ൪؀ڥ ຊ൪෼཭؀ڥ ʢख࡞ۀͰߏஙʣ 9
  10. 10 ShopSet Χʔτϖʔδ γϣοϓϖʔδ API Ϧόʔε ϓϩΩγ LB https://hoge.shop-pro.jp 10

    ShopSetΞʔΩςΫνϟ k8s Cluster k8s Cluster ShopSet ShopSet ShopSet ShopSet
  11. 11 11 ShopSetΞʔΩςΫνϟ ଞʹ΋ɾɾɾ • Ϧιʔε੍ݶ • ΫϥελؒεέδϡʔϦϯά • σϓϩΠ

    • ΧφϦΞϦϦʔε ͳͲͷ࢓૊Έʹ͍ͭͯઃܭΛਐΊ͍ͯ·͢ɻ
  12. 12 ShopSetҎ֎ͷϩʔϧͷKubernetes΁Ҡߦ ShopSetҎ֎ͷϩʔϧ΋ঃʑʹKubernetes΁ҠߦΛਐΊ͍ͯ· ͢ɻ ޙ൒͸ͪ͜Βͷಋೖࣄྫʹ͍͓ͭͯ࿩͠·͢ɻ 12

  13. 13 Kubernetes΁ͷಋೖࣄྫ ϝʔϧϚΨδϯ഑৴Φϓγϣϯʹ͍ͭͯ 13

  14. 14 ϝʔϧϚΨδϯ഑৴ΦϓγϣϯͷKubernetesಋೖ • ߏங४උ ◦ 2020೥9݄ʙ11݄ʢଞPJ΋ฒߦͰߦ͍ͭͭ࡞ۀʣ • ϦϦʔε ◦ ஈ֊తͳϦϦʔε12/14׬શʹҠߦ͕׬ྃʂʂ

    14
  15. 15 ͳͥKubernetesʹҠઃͨ͠ͷ͔ ͖͔͚ͬ • CentOS6ͷηΩϡϦςΟαϙʔτ͕2020೥11݄ʹऴྃ • ϝʔϧϚΨδϯ഑৴ΦϓγϣϯΛઃఆ͢ΔͨΊͷ؅ཧϖʔ δαʔόOS͕ɺCentOS6ͰՔಇ͍ͯͨͨ͠Ίόʔδϣϯ Ξοϓ͕ඞཁͩͬͨ 15

  16. 16 ͳʹҠઃͨ͠ͷ͔ ͦͷଞͷཧ༝ • ٕज़తʹνϟϨϯδ͠΍͍͢؀ڥͩͬͨ ◦ ػೳ਺͕ϝʔϧςϯϓϨʔτͷ࡞੒ɺΞυϨεாͷ࡞੒ɺ഑৴༧ ໿ͱগͳ͍ ◦ ΞΫηεՄೳͳϢʔβ΋ଞͷϩʔϧʹൺ΂ݶΒΕ͍ͯΔ

    • PuppetϚχϑΣετ͕ϝϯςφϯε͞Εͳ͘ͳͬͯ͠·͍ɺखಈͰ ϥΠϒϥϦͷΞοϓσʔτͳͲΛߦ͍ͬͯͨ ◦ ʢଞͷϩʔϧ͸ͪΌΜͱϝϯςφϯε͞Εͯ·͢ʣ • ։ൃ؀ڥ͸͢ͰʹDockerͰಈ͘Α͏ʹͳ͍ͬͯͨ 16
  17. 17 ͜Ε͸KubernetesνϟϯεͰ͸ʁ ϊ΢ϋ΢Λ஝ੵ͢Δʹ͸ྑ͍ػձʂ Ϣʔβ͕௚઀৮ΔϩʔϧͷKubernetesԽୈ1ஈͱͯ͠νϟϨϯδ͠·ͨ͠ʂ ʢ˞Ұ෦ͷAPI͸ಋೖࡁΈͰͨ͠ʣ ϦΞʔΩςΫνϟνʔϜ • ΠϯϑϥΤϯδχΞ 2໊ •

    ΞϓϦέʔγϣϯΤϯδχΞ 1໊ ↑ ͜͜ʹࠞͥͯ΋Βͬͨ 17
  18. 18 ߏ੒ • OS: CentOS6 ◦ => CentOS7 • ݴޠ:

    PHP ◦ => มߋͳ͠ • Webαʔό: ApacheʢPHPϞδϡʔϧʣ ◦ => Nginx + PHP-FPM • Nyahʢࣾ಺ͷϓϥΠϕʔτΫϥ΢υʣͷΠϯελϯε ◦ =>ɹShopSetΫϥελ(Kubernetes) 18
  19. 19 ͍Ζ͍Ζ՝୊͕ग़͖ͯͨ • ϩάͲ͏͢Δʁ • ΤϥʔͷτϥοΩϯά͸ʁ • ίϯςφͷ؂ࢹ͸ʁ • ηΩϡϦςΟେৎ෉ʁʁ

    • ύϑΥʔϚϯεେৎ෉ʁʁ • ͳ͔ͥPod੾Γସ͑࣌ʹμ΢ϯλΠϜ͕ൃੜ͢Δʂ • σϓϩΠ͸ʁ ɾɾɾͳͲͳͲ 19
  20. 20 Կ͔՝୊΍ؾ͍ͮͨ͜ͱ͕ग़ͨΒ͙͢ϦΞʔΩςΫνϟνʔϜʹ૬ஊ • ຖ೔༦ํࡶஊ෦԰ʢGoogle Meetʣʹू·Δ࣌ؒΛऔ͍ͬͯ ΔͷͰɺͦ͜Ͱࠔ͍ͬͯΔ͜ͱΛ૬ஊ ◦ ૬ஊ->શһͰҰؾʹղܾͱ͍͏ྑ͍αΠΫϧ͕ճͤͨ ◦ ShopSetͷߏஙʹ΋ྑ͍ӨڹΛ༩͑ΒΕͨ

    20
  21. 21 ൃੜͨ͠՝୊Λڠྗͯ͠ย෇͚͍ͯͬͨ 21 • ϩά ◦ => Fluentdܦ༝ͰBigQueryʹอଘʢStdOutͷ಺༰͸Cloud Logging΁ʣ •

    ΤϥʔτϥοΩϯά ◦ => Sentryͷಋೖ • ίϯςφ؂ࢹ ◦ => Mackerel Agentͷಋೖ • ίϯςφηΩϡϦςΟ ◦ => ΞϓϦέʔγϣϯίϯςφηΩϡϦςΟΨΠυʢNIST࡞੒ɺ຋༁؂मIPAʣΛνΣοΫ • Pod੾Γସ͑࣌ͷμ΢ϯλΠϜ ◦ => ReadinessProbeɺpreStopͷௐ੔ • ύϑΥʔϚϯε ◦ => ଟΊʹϦιʔεΛऔͬͯϦϦʔεޙௐ੔
  22. 22 σϓϩΠʢShopSet͸ผͷํࣜʣ 22 ։ൃऀ ϝϧϚΨ AppϦϙδτϦ K8sϚχϑΣετ ϦϙδτϦ ࣾ಺ Docker

    Resisty K8s Argo CDʹͯϚχϑΣετΛద༻ CI/CDʹͯɺϚʔδɾΠϝʔδͷϓογϡ ΞϓϦέʔγϣϯ Nginx, PHP-FPM K8sΫϥελ Merge Push Pull ߋ৽ͨ͠ΠϝʔδΛ࢖͏Α͏ʹɺ ϚχϑΣετ಺ͷΠϝʔδλάΛߋ৽
  23. 23 ͦͯ͠ϦϦʔε 23 ͜ͷΑ͏ͳऔΓ૊ΈΛߦ͏͜ͱͰɺ1݅΋ো֐Λൃੜͤͣ͞ແ ࣄϦϦʔε͢Δ͜ͱ͕Ͱ͖·ͨ͠

  24. 24 ·ͱΊ • ΧϥʔϛʔγϣοϓͰ͸ɺՄ༻ੑ޲্ͷͨΊͷࢪࡦͱ͠ ͯɺShopSetΞʔΩςΫνϟͷಋೖΛਐΊ͍ͯ·͢ɻ • Kubernetesಋೖͷࡍ͸ɺεϞʔϧελʔτͯ͠ಋೖࣄྫΛ ࡞͍ͬͯ͘ͱɺϦεΫΛ࠷খݶʹ཈͑ϊ΢ϋ΢ΛཷΊΒΕ Δ •

    ͜͏͍ͬͨऔΓ૊ΈΛҰॹʹਐΊͯߦ͚Δ஥ؒΛืूͯ͠ ͍·͢ʂ 24