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

Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide

d-kuro
July 25, 2019

Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide

Kubernetes Meetup Tokyo #21 - Cloud Native CI/CD で発表した資料です
https://k8sjp.connpass.com/event/138375/

d-kuro

July 25, 2019
Tweet

More Decks by d-kuro

Other Decks in Technology

Transcript

  1. ࠓ೔࿩͢͜ͱ • Argo CD ͷ CRD ʹ͍ͭͯ • Argo CD

    ͷ RBAC ʹ͍ͭͯ • Argo CD ͷ Sync ઓུʹ͍ͭͯ
  2. ࠓ೔࿩͢͜ͱ • Argo CD ͷ CRD ʹ͍ͭͯ • Argo CD

    ͷ RBAC ʹ͍ͭͯ • Argo CD ͷ Sync ઓུʹ͍ͭͯ ͕࣌ؒ଍Γͳ͔ͬͨͷͰ
 εΩοϓ͠·͢ (ࢿྉ͸ͦͷ··Ξοϓ͠·͢)
  3. Tools • αϙʔτ͍ͯ͠Δ apply ํ๏ • kustomize • Helm charts

    • Ksonnet • YAML/JSON/Jsonnet manifest ͷσΟϨΫτϦ • ϓϥάΠϯ (ࣗ࡞όΠφϦ΋࢖͑Δ)
  4. Application of Applications • kustomize ͷྫ: root.yaml ͜͜ͷ path ࢦఆͰ

    application-of-applications σΟϨΫτϦͷ kustomization.yaml ͕ࢀর͞ΕΔ
  5. Application of Applications • kustomize ͷྫ: root ʹͳΔ Application Λ

    apply ͚ͨͩ͠Ͱ 
 root ʹඥͮ͘ Application ΋উखʹద༻͞ΕΔ
  6. Application of Applications • kustomize ͷྫ: ͜ΕΒͷ Application ͸ GitOps

    Ͱࣗಈతʹ Sync ͞ΕΔ (feature ϒϥϯνͷ manifest Λ
 ద༻͍ͨ͠Έ͍ͨͳঢ়گͷ࣌ʹָ)
  7. Argo CD ͷೝূ • ϩάΠϯը໘: User ͱ Password Λ
 ೖྗ͢Δεϖʔε͕͋Δ͕


    Argo CD Ͱ͸૊ΈࠐΈͷ
 admin Ҏ֎ͷϢʔβ͸ଘࡏ͠ͳ͍
  8. Argo CD ͷೝূ • Argo CD Ͱ SSO Λߦ͏ํ๏͸ 2

    छྨ • όϯυϧ͞ΕͯΔ Dex Λ࢖༻͢Δ • طଘͷ OIDC provider Λ࢖༻͢Δ
  9. Argo CD ͷೝূ • Argo CD Ͱ SSO Λߦ͏ํ๏͸ 2

    छྨ • όϯυϧ͞ΕͯΔ Dex Λ࢖༻͢Δ • طଘͷ OIDC provider Λ࢖༻͢Δ ࠓճ͸ Dex Λ࢖ͬͯ
 GitHub Ͱೝূ͢Δ࿩Λ͠·͢
  10. Dex Λ༻͍ͯ GitHub Ͱೝূ͢Δ • Argo CD Ͱ͸ Dex ͱ͍͏


    OIDC provider ͕όϯυϧ͞Ε͍ͯΔ • https://github.com/dexidp/dex
  11. Dex Λ༻͍ͯ GitHub Ͱೝূ͢Δ • GitHub Ͱ OAuth application Λ࡞ͬͯ


    `argocd-cm` ͱ͍͏ ConfigMap ʹ
 ઃఆΛهࡌ͢Δ
  12. Dex Λ༻͍ͯ GitHub Ͱೝূ͢Δ • ConfigMap ͷྫ: ൃߦͨ͠ clientID ͱ

    clientSecret $dex.github.clientSecret Έ͍ͨʹॻ͘͜ͱͰ
 Kubernetes ͷ Secret ͔Β
 ஋ΛಡΈࠐΜͰ͘ΕΔ
  13. Dex Λ༻͍ͯ GitHub Ͱೝূ͢Δ • ConfigMap ͷྫ: ϩάΠϯͰ͖Δ GitHub org

    ͱ Team ͷઃఆ ͜ͷ৔߹͸ `classmethod` ͱ͍͏ GitHub org ͷ `sre-team` ͔͠ ϩάΠϯͰ͖ͳ͍
  14. Role • Argo CD ͷ Web UI ͔Β
 Delete, Edit

    ͱ͔͕Ͱ͖ͨΓ͢Δ໰୊΋ 
 Role Λ࢖੍ͬͯޚ͢Δ͜ͱ͕Ͱ͖Δ
  15. Sync Phases • Argo CD ͷ Sync ʹ͸େ͖͘෼͚ͯ 3 ͭͷϑΣʔζ͕͋Δɹ

    PreSync Sync PostSync manifest ͷద༻લʹ࣮ߦ͞ΕΔ
  16. Sync Phases • Argo CD ͷ Sync ʹ͸େ͖͘෼͚ͯ 3 ͭͷϑΣʔζ͕͋Δɹ

    PreSync Sync PostSync manifest ͷద༻ʹ
 ؔ࿈࣮ͯ͠ߦ͞ΕΔ
  17. Sync Phases • Argo CD ͷ Sync ʹ͸େ͖͘෼͚ͯ 3 ͭͷϑΣʔζ͕͋Δɹ

    PreSync Sync PostSync manifest ͷద༻ޙʹ࣮ߦ͞ΕΔ
  18. • Argo CD ͷ Sync ʹ͸େ͖͘෼͚ͯ 3 ͭͷϑΣʔζ͕͋Δɹ PreSync Sync

    ΞϓϦέʔγϣϯ ͷσϓϩΠ DB ͷ
 ϚΠάϨʔγϣϯ PostSync Sync Phases ΞϓϦέʔγϣϯͷσϓϩΠલʹ
 Kubernetes ͷ Job Ͱ
 DB ͷϚΠάϨʔγϣϯΛ࣮ߦ
  19. Sync Phases and Waves • Argo CD ͷ Sync ʹ͸େ͖͘෼͚ͯ

    3 ͭͷϑΣʔζ͕͋Δɹ PreSync ΞϓϦέʔγϣϯͷσϓϩΠલʹ
 Kubernetes ͷ Job Ͱ
 DB ͷϚΠάϨʔγϣϯΛ࣮ߦ DB ͷ
 ϚΠάϨʔγϣϯ
  20. Sync Phases • Argo CD ͷ Sync ʹ͸େ͖͘෼͚ͯ 3 ͭͷϑΣʔζ͕͋Δɹ

    PreSync DB ͷ
 ϚΠάϨʔγϣϯ annotation ʹهࡌΛ͢Δͱ
 Argo CD ͕هࡌͨ͠ϑΣʔζͰ
 ࣮ߦͯ͘͠ΕΔ
  21. • Argo CD ͷ Sync ʹ͸େ͖͘෼͚ͯ 3 ͭͷϑΣʔζ͕͋Δɹ PreSync DB

    ͷ
 ϚΠάϨʔγϣϯ PreSync ͷϑΣʔζ͕
 ऴΘͬͨΒ Job Λ࡟আ Sync Phases
  22. Sync Waves Sync Job Pod Job 1 2 3 •

    ֤ϑΣʔζ಺Ͱͷ manifest ͷద༻ॱΛ੍ޚͰ͖Δ
  23. Sync Waves Sync Job Pod Job 1 2 3 •

    ֤ϑΣʔζ಺Ͱͷ manifest ͷద༻ॱΛ੍ޚͰ͖Δ `argocd.argoproj.io/sync-wave` ͱ͍͏ annotaion ʹ
 ੔਺஋Λࢦఆ͢Δ
  24. ·ͱΊ • Argo CD ͸Ϧονͳ Web UI Ͱ GitOps Ͱ͖Δπʔϧ

    • ৭ʑͱࡉ͔͍ػೳͱ͔΋ॆ࣮ͯ͠Δ • ެࣜͷυΩϡϝϯτ΋ॆ࣮ͯ͠ΔͷͰΈΑ͏! • https://argoproj.github.io/argo-cd/