Save 37% off PRO during our Black Friday Sale! »

dynamic-environment-setup-and-teardown-with-gitlab-and-k8s

Ee4cc84c4dedde009c013c6d5f1a2e84?s=47 Tatch
May 13, 2021

 dynamic-environment-setup-and-teardown-with-gitlab-and-k8s

「JX Press Tech Talk #backend 速報サービスを支えるバックエンドの技術」で発表した『GitLabとKubernetesで作る自動で起動・停止できるブランチ別環境』の資料です

https://jxpress.connpass.com/event/210867/

Ee4cc84c4dedde009c013c6d5f1a2e84?s=128

Tatch

May 13, 2021
Tweet

Transcript

  1. GitLabͱKubernetesͰ࡞Δ ࣗಈͰىಈɾఀࢭͰ͖Δϒϥϯνผ؀ڥ SRE ฏ੉ୡ໵

  2. Who am I? ฏ੉ ୡ໵(Tatsuya Hirase ) ◦ @TatchNicola s

    ◦ SR E ◦ Ϊλʔ/ࣗసं/֎ࠃޠ(ӳޠͱதࠃޠ͕ͪΐͬͱͰ͖Δ)
  3. 0, ͸͡Ίʹ • GitLab/KubernetesΛ૊Έ߹ΘͤͨσϓϩΠઓུͷ͸ͳ͠ • ߏ੒ਤΛݩʹղઆ͠·͢ ◦ ࣌ؒͷ౎߹্σϞ͸͋Γ·ͤΜ ◦ αϯϓϧίʔυ͸ޙ೔ϒϩάͰʂ

    • AWSɺKubernetesͷ༻ޠɾΤίγεςϜͷ஌͕ࣝલఏ
  4. Agenda ࠔ͍ͬͯͨ͜ͱ Ͳ͏΍ͬͯղܾ͔ͨ͠ ·ͱΊ 1, 2, 3,

  5. 1,ࠔ͍ͬͯͨ͜ͱ ෳ਺ͷϓϩμΫτͱͨ͘͞ΜͷECSαʔϏε • : SNSͳͲ͔Βࡂ֐౳ͷ৘ใΛऩू/෼ੳ/഑৴ • : ѹ౗తͳ଎ใੑ͕ಛ௃ͷχϡʔεΞϓϦ • ϓϩμΫτؒͰσʔλ΍APIΛ༥௨͋͠͏

    • ALB + ECS + (ΞϓϦʹ߹ͬͨӬଓԽ૚)͕ఆ൪ͷߏ੒
  6. 1,ࠔ͍ͬͯͨ͜ͱ ʮ։ൃ؀ڥ͍·࢖ͬͯ΋ྑ͍Ͱ͔͢ʁʯ

  7. 1,ࠔ͍ͬͯͨ͜ͱ ͋Δ͋Δʁ։ൃ؀ڥͷॱ൪଴ͪ • ϩʔΧϧͰ֬ೝ͠ʹ͍͘΋ͷ ◦ Ϋϥ΢υݻ༗ͷػೳ(e.g. Amazon SQS, Firestore )

    ◦ ݖݶͷ֬ೝ(ඞཁͳIAM࣋ͬͯΔ͔ʁ ) ◦ ґଘ͢Δɾ͞ΕͯΔϚΠΫϩαʔϏε(docker-composeͰ...? ) • ʮͪΐͬͱݟͯ΄͍͠ʯʮͪΐͬͱAPIୟ͍ͯཉ͍͠ʯ ◦ ։ൃऀ <-> σβΠφʔɺPd M ◦ ϑϩϯτ <-> όοΫΤϯυ ◦ GraphQL BFF <-> REST API
  8. 1,ࠔ͍ͬͯͨ͜ͱ • Merge Request(GitHubͰ͍͏Pull Request)͝ͱʹ
 ࣗಈͰ؀ڥͱURL͕෷͍ग़͞ΕΔ
 • Merge Request͕ด͡ΒΕͨΒɺͦͷ؀ڥ΋ด͡ΒΕΔ
 Ͳ͏͢Ε͹଴ͪΛͳͤ͘Δʁ

  9. 1,ࠔ͍ͬͯͨ͜ͱ • Merge Request(GitHubͰ͍͏Pull Request)͝ͱʹ
 ࣗಈͰ؀ڥͱURL͕෷͍ग़͞ΕΔ
 -> Istio • Merge

    Request͕ด͡ΒΕͨΒɺͦͷ؀ڥ΋ด͡ΒΕΔ
 -> Helm & GitLab CI Ͳ͏͢Ε͹଴ͪΛͳͤ͘Δʁ
  10. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠

  11. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠ ϦϙδτϦઓུ • ΞϓϦέʔγϣϯϦϙδτϦ : ◦ CIͰ͸lintɺςετɺίϯςφΠϝʔδͷ࡞੒·ͰΛ୲౰͢Δ • ϚχϑΣετϦϙδτϦ :

    ◦ k8sϚχϑΣετ(=HelmςϯϓϨʔτ)Λ؅ཧ ◦ ։ൃ൛ΫϥελͷτϐοΫϒϥϯνผ؀ڥ΁ͷσϓϩΠ ◦ ArgoCD͕͜ͷϦϙδτϦͷmainϒϥϯνΛΫϥελʹಉظ͢Δ CIఆ͕ٛγϯϓϧʹͳΓɺςϯϓϨʔτͱͯ͠ڞ௨ԽͰ͖ͨ
  12. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠ • Isti o ◦ τϥϑΟοΫ੍ޚΛݸผͷϦϙδτϦ΁ҕৡ͠΍͍͢ ◦ ʮALB+ECSʯorʮEKS+IngressʯͩͱதԝूݖʹͳΓ͕ͪ • Hel

    m ◦ ຊ൪؀ڥɾ։ൃ؀ڥɾτϐοΫϒϥϯνผ؀ڥͷࠩ෼Λٵऩ ◦ 2छྨͷσϓϩΠઓུͷ઀ணࡎ(ޙड़ ) • GitLab C I ◦ “Environments” ʹ؀ڥΛରԠͤͯ͞ಠཱσϓϩΠΛ࣮ݱ ◦ ؀ڥͷ࡞੒ɾഁغͷͨΊͷτϦΨʔఆ͕͍͍ٛײ͡ʹͰ͖Δ
  13. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠

  14. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠

  15. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠

  16. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠

  17. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠

  18. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠ CIOps͔GitOps͔ʁ྆ํͩʂ

  19. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠ CIOps͔GitOps͔ʁ྆ํͩʂ

  20. 2,Ͳ͏΍ͬͯղܾ͔ͨ͠ CIOps͔GitOps͔ʁ྆ํͩʂ • ݕূ޲͚؀ڥʹ͸ɺΨγΨγॻ͍ͯσϓϩΠɾಈ࡞֬ೝ͍ͨ͠ ◦ ֤τϐοΫϒϥϯνʹରԠ͢Δ؀ڥʹ GitLab CIͰσϓϩΠ(=CIOps) • ຊ൪؀ڥ͸όʔδϣϯ؅ཧ΋ηΩϡϦςΟ΋͔ͬ͠Γ͍ͨ͠

    ◦ ։ൃ؀ڥΫϥελ͓Αͼຊ൪Ϋϥελͷmainϒϥϯν؀ڥ͸ɺ ArgoCDͰσϓϩΠ(=GitOps) ໨త͕ҧ͏؀ڥʹ͸ɺҧ͏ख๏ΛͱΔ΂͠ʂ
  21. 3, ·ͱΊ • ෳ਺ͷ؀ڥΛಈతʹੜ੒ɾഁغͰ͖Δ࢓૊ΈΛͭͬͨ͘ ◦ ؀ڥͷॱ൪଴͕ͪͳ͘ͳͬͯ։ൃ଎౓U P ◦ ϦϞʔτϫʔΫͰ΋ʮͪΐͬͱίϨݟͯ/ୟ͍ͯʯ͕༰қʹ •

    ϦϙδτϦΛࡉ͔͘෼͚ɺCIͱCDΛ෼཭͢Δ͜ͱͰؔ৺͝ͱΛখ͘͞อͭ • GitOpsͱCIOps͸ೋऀ୒Ұ͡Όͳ͍ ◦ ໨తʹ͋Θͤͯ྆ํ࢖͏͜ͱ΋Ͱ͖Δ ◦ ઀ணࡎͱͯ͠ͷHelm
  22. 3, Appendix IstioΛ࢖ͬͯʮFast, Dependency-Agnostic, Isolatedʯͳ։ൃମݧΛ࣮ݱͨ͠࿩ https://en-jp.wantedly.com/companies/wantedly/post_articles/241506 KubernetesΛ࠷େݶʹ׆͔ͨ͢ΊͷGitOpsೖ໳ https://speakerdeck.com/amaya382/kuberneteswozui-da-xian-nihuo-kasutamefalsegitopsru-men Guide to

    GitOp s https://www.weave.works/technologies/gitops/ GitLab ެࣜDo c https://docs.gitlab.com/ee/ci/environments/ https://docs.gitlab.com/ee/user/project/clusters/add_remove_clusters.html
  23. ThankYou!