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

쿠버네티스를 이용한 기능 브랜치별 테스트 서버 만들기 (GitOps CI/CD)

쿠버네티스를 이용한 기능 브랜치별 테스트 서버 만들기 (GitOps CI/CD)

어떻게 하면 배포 프로세스를 빠르게 개선할 수 있을까요?
git branch를 푸시하고 개별 테스트 서버를 만드려면 어떻게 해야 할까요?
쿠버네티스와 GitOps, Argo CD를 이용한 배포 방법을 소개 합니다.

Open Infrastructure & Cloud Native Days Korea 2019 발표자료

Avatar for Chungsub Kim

Chungsub Kim

July 19, 2019

Other Decks in Technology

Transcript

  1. ௢ߡ֎౭झܳ੉ਊೠ ӝמ ࠳ے஖߹ పझ౟ ࢲߡ ٜ݅ӝ (GitOps CI/CD) KIM CHUNGSUB

    subicura Open Infrastructure & Cloud Native Days Korea 2019
  2. Open Infrastructure & Cloud Native Days Korea 2019 ӣ୽ࢼ ಌ೒ਖझ

    ѐߊ੗ Container / Serverless / DevOps / ReactJS E-Commerce ѐߊ http://subicura.com subicura
  3. Open Infrastructure & Cloud Native Days Korea 2019 ߓನ೐۽ࣁझѐࢶೞӝ ୭ୡߓನ೐۽ࣁझ

    ର೐۽ࣁझѐࢶ ର೐۽ࣁझѐࢶ ,VCFSOFUFT (JU0QT "SHP$% ,VCFSOFUFT (JU0QT "SHP$% ௢ߡ֎౭झܳ੉ਊೠ࠳ے஖߹పझ౟ࢲߡߓನ $*$%౵੉೐ۄੋ ؘݽ ࢸ੿ ؀উ (JU-BC +FOLJOT "SHP$%
  4. Open Infrastructure & Cloud Native Days Korea 2019 য়ט ߊ಴

    ੉ঠӝ CI(Continuous integration) / CD(Continuous Delivery) Kubernetes / GitOps / ArgoCD
  5. Open Infrastructure & Cloud Native Days Korea 2019 য়ט ߊ಴

    ੉ঠӝ CI(Continuous integration) / CD(Continuous Delivery) Kubernetes / GitOps / ArgoCD → commit ௏٘ܳ Ҋёীѱ ୭؀ೠ ࡈܻ ੹׳ೞӝ ਤೠ ֢۱
  6. Open Infrastructure & Cloud Native Days Korea 2019 ୭ୡߓನ೐۽ࣁझ SVN੄

    ױ੼ svn SVN - ࠳ے஖ ӝמ ࢎਊ উೣ - ѐߊ ࣗझо ҍ ߓನ ࣗझ - ܀ߔ ؀न ࡅܲ ࣻ੿? - ௏ܻ٘࠭ য۰਑ → ੸੺ೠ بҳ੄ ࠗ੤
  7. Open Infrastructure & Cloud Native Days Korea 2019 ୭ୡߓನ೐۽ࣁझ ࢲߡ

    ߓನ੄ ױ੼ - ۄ੉࠳۞ܻ ߡ੹ਸ ߄ԲѢա ࢜۽ ࢸ஖ೞח ҃਋ ੗ز ߓನ पಁ → ੄ઓࢿ ҙܻ য۰਑ - ࢲߡܳ ৈ۞؀۽ ഛ੢ೞѢա ߸҃ೞח ҃਋ ࣇ౴੉ য۰਑ → chef? ansible? - పझ౟ ࢲߡ৬ ਍৔ ࢲߡо ޷ޑೞѱ ੌ஖ೞ૑ ঋח ޙઁ Deploy
  8. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ Code

    1ର ѐࢶ - Gitҗ Docker بੑ git Build Docker Deploy ♥ ♥
  9. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ git੄

    ੢੼ git - gitਸ بੑೞҊ ӝמ ױਤ ࠳ے஖ܳ ੸ӓ੸ਵ۽ ࢎਊ - Merge Request + Code Reviewܳ ੉ਊೠ ѐߊ ೐۽ࣁझ ѐࢶ - GitLab بੑ → UIо ੉ࢄ ♥
  10. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ بழ੄

    ੢੼ = ஶప੉ց੄ ੢੼ - যו ࢲߡٚ Ѣ੄ ޙઁহ੉ ز੘ೞח Ѫਸ ࠁ੢ - ߓನ ߂ ഛ੢੉ ए਑ - పझ౟৬ ਍৔ ࢲߡ੄ ର੉о Ѣ੄ হ਺ - ౠ੿ ߡ੹ਵ۽ ܀ߔೞӝ ए਑ ♥ Docker
  11. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ թ਷

    ޙઁ੼ - ৈ۞ѐ੄ ৮ࢿػ ӝמਸ ݽই పझ౟ ࢲߡী ߓನೞח ߑध - ৈ۞ѐ੄ ӝמ ઺ ೞա੄ ӝמী ޙઁо ੓ਵݶ ੹୓ ߓನо ޷ܞ૗ - ࡅܲ ѐࢶҗ ؀਽੉ য۵Ҋ ੹߈੸ੋ ߓನ ઱ӝо ӡয૗ - ࠗ઒ೠ పझ౟ ࢲߡ → ߓನ؀ӝ - ѐߊ੗ח טযաҊ ੓঻૑݅ QA ߓನо ߽ݾਵ۽ ੘ਊೞৈ ࢤ࢑ࢿ ੷ೞ
  12. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ Ӓ۟੷۟

    ߓನ ೐۽ࣁझܳ উ੿ച ೞ؍ ઺ Google Cloud Next 2019 ೯ࢎܳ ׮֗২פ׮.
  13. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ ਋ܻ

    ࠁ׮ ࣻߔߓ ؊ ௾ ഥࢎীࢲ ࣻभߓ ؊ ੗઱ ߓನೞҊ ੓׮!
  14. Open Infrastructure & Cloud Native Days Korea 2019 ߓನ ೐۽ࣁझ

    Ҋ޹ - ߓನܳ ؊ ੗઱ ೡ ࣻ ੓ਸө? - ߓನܳ ؊ ࡅܰѱ ೡ ࣻ ੓ਸө? - ߓನܳ ؊ ݆੉ ೡ ࣻ ੓ਸө? - ߓನܳ ؊ ੗ਬ܂ѱ ೡ ࣻ ੓ਸө? ର೐۽ࣁझѐࢶ
  15. Open Infrastructure & Cloud Native Days Korea 2019 ߓನ ೐۽ࣁझ

    Ҋ޹ - ߓನܳ ؊ ੗઱ ೡ ࣻ ੓ਸө? → ؊ ੘਷ ױਤ۽ ੗઱ ߓನೞ੗ - ߓನܳ ؊ ࡅܰѱ ೡ ࣻ ੓ਸө? → ࣗझܳ ಹदೞݶ ੗زਵ۽ ࠽٘ೞ੗ - ߓನܳ ؊ ݆੉ ೡ ࣻ ੓ਸө? → పझ౟ ࢲߡ ࣻܳ טܻ੗ - ߓನܳ ؊ ੗ਬ܂ѱ ೡ ࣻ ੓ਸө? → ߓನӂೠਸ ഛ؀ೞ੗ ର೐۽ࣁझѐࢶ
  16. Open Infrastructure & Cloud Native Days Korea 2019 ߓನ ೐۽ࣁझ

    Ҋ޹ - ߓನܳ ؊ ੗઱ ೡ ࣻ ੓ਸө? → ؊ ੘਷ ױਤ۽ ੗઱ ߓನೞ੗ - ߓನܳ ؊ ࡅܰѱ ೡ ࣻ ੓ਸө? → ࣗझܳ ಹदೞݶ ੗زਵ۽ ࠽٘ೞ੗ - ߓನܳ ؊ ݆੉ ೡ ࣻ ੓ਸө? → పझ౟ ࢲߡ ࣻܳ טܻ੗ - ߓನܳ ؊ ੗ਬ܂ѱ ೡ ࣻ ੓ਸө? → ߓನӂೠਸ ഛ؀ೞ੗ ର೐۽ࣁझѐࢶ ѐߊ੗ ࣻ 10࠙ ੺ড 1֙ = ???
  17. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ Code

    2ର ѐࢶ - GitLab webhook + CI৬ CD ܻ࠙ git Build Docker Deploy
  18. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ Code

    2ର ѐࢶ - GitLab webhook + CI৬ CD ܻ࠙ git Build Job (branch) Docker Deploy Job Deploy
 (test01~05) CI CD event ♥ ♥ ♥
  19. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ Build

    - ࠳ے஖݃׮ بழ ੉޷૑ ٜ݅ӝ branch - 1 image:branch-1 branch - 2 image:branch-2 branch - 3 image:branch-3
  20. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ Deploy

    - Parameterized Build 1~5ߣ ઺ী ࢲߡ ࢶఖ git branch = docker image tag ࢶఖ
  21. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ 2ର

    ѐࢶ੄ ੢੼ - ݽٚ ࠳ے஖ח ੗زਵ۽ ࠽٘غয بழ ੉޷૑۽ ٜ݅য૗ - ߄۽ ߓನ оמೠ بழ ੉޷૑о ೦द ؀ӝ઺ - పझ౟, QAܳ ೞӝ ਤ೧ࢲ ৈ۞ѐ੄ ࢲߡ ઺ ਗೞח ࢲߡܳ ࢎਊೞҊ ৮ܐغݶ ઙܐ - ־о ݻߣ ࢲߡীࢲ যڃ ࠳ے஖ܳ పझ౟ ઺ੋ૑ Jenkinsীࢲ ഛੋ - ૓೯઺ੋ పझ౟ܳ ӝ׮ܻ૑ ঋҊ ৈ۞ѐ੄ పझ౟ܳ زदী ૓೯ೞҊ ߓನ - పझ౟ ࢲߡ 2؀ > 5؀
  22. Open Infrastructure & Cloud Native Days Korea 2019 ର೐۽ࣁझѐࢶ ࢜۽਍

    ޙઁ੼ - పझ౟ ࢲߡܳ ҙܻ೧ঠ ೞח ࠛಞೣ (1ߣ ࢲߡ ۽Ӓੋ పझ౟, 2ߣ ࢲߡ Ѿઁ పझ౟..) - ࢎਊೞ૑ ঋח పझ౟ ࢲߡ੄ ੗ਗ խ࠺ (0द~8द ઙܐ) - పझ౟о ށܾ ҃਋ ৈ੹൤ ӝ׮۰ঠ ೞח ޙઁ - оՔ੗઱ ߓನ ചݶ ੑ۱ पࣻ - పझ౟ ৮ܐೠ ࢲߡ ഥࣻо ןয૗ - Jenkinsח ࢤпࠁ׮ ҡଳও૑݅ ദӝ੸ੋ ѐࢶ਷ য۰਑
  23. Open Infrastructure & Cloud Native Days Korea 2019 ,VCFSOFUFT Kubernetes

    - Cluster Autoscaler → ࠗೞী ٮۄ పझ౟ ࢲߡ ز੸ ࢤࢿ - Ingress Controller → ࢸ੿ਵ۽ بݫੋ োѾ - Cert Manager → SSL ੋૐࢲ ҙܻ - Helm ಁః૑ ݒפ੷ → ࠂ੟ೠ ௢ߡ֎౭झ manifest ౵ੌਸ ױࣽೞѱ ҙܻ - Amazon EKS → ৮੹ ҙܻഋ ࢲ࠺झ - Spot Instance → Autoscaling Group۽ ࢸ੿ೞৈ ࠺ਊ ੺ড
  24. Open Infrastructure & Cloud Native Days Korea 2019 ,VCFSOFUFT Cluster

    Autoscaler - Pod੉ ࢤࢿؼ ֢٘о ࠗ઒ೞݶ ੗زਵ۽ ੋझఢझܳ ࢤࢿ - ࢜۽ ࢤࢿغח ੋझఢझח ࣃझ ੓ѱ Spot ੋझఢझ ఋੑਵ۽ ࢤࢿ
  25. Open Infrastructure & Cloud Native Days Korea 2019 ,VCFSOFUFT Ingress

    Controller + Cert Manager - ࠳ے஖੉ܴਵ۽ بݫੋ োѾ
  26. Open Infrastructure & Cloud Native Days Korea 2019 ,VCFSOFUFT Helm

    package manager apiVersion: v1 kind: Pod metadata: name: mypod spec: container: - name: mypod-container image: {{ .Values.image }} image: busybox apiVersion: v1 kind: Pod metadata: name: mypod spec: container: - name: mypod-container image: busybox pod.yaml values.yaml output.yaml + - ߸ೞח ч݅ ߹ب੄ yaml۽ ҙܻ (Image tag, domain)
  27. Open Infrastructure & Cloud Native Days Korea 2019 (JU0QT ݺ۸೯

    بҳܳ ࢎਊೠ সؘ੉౟੄ ޙઁ੼ ੿ഛࢿ → ݺ۸যܳ ੜޅ ੑ۱ೞѢա ੜޅػ contextীࢲ प೯ೡ ࣻ ੓਺ ࠁউࢿ → Jenkins, ѐߊ੗١ ׮নೠ Ҕীࢲ ௿۞झఠ ੽Ӕ (҅੿ҙܻ) بҳ → kubectl, helm بҳ ࢎਊߨਸ ੊ഃঠ ೣ थੋ → ߓನܳ ਃ୒ೞҊ थੋೞח ೐۽ࣁझܳ ٜ݅ӝ য۰਑ ۽Ӓ → ߓನ৬ ҙ۲ػ ߡ੹ҙܻо য۵Ҋ ߓನ ੉ਬܳ ੿ഛ൤ ঌ ࣻ হ਺ ࠙࢑ҙܻ → ୭ઙ ࢸ੿ਸ ੿ഛ൤ ঌ ࣻ হ਺
  28. Open Infrastructure & Cloud Native Days Korea 2019 (JU0QT Kubernetes

    ߓನח যڌѱ? $ helm sync ߓನਊ ࢸ੿ ੷੢ࣗ
 (no code) Agent
  29. Open Infrastructure & Cloud Native Days Korea 2019 (JU0QT Developer

    % GitOps workflow ௏٘੘ࢿ Git (code) CI Unit Test Build
 Container
 Image Push
 Container
 Image Git (env) Merge Request or Push Sync Agent kubectl apply helm / ... Kubernetes Deploy docker registry Update k8s manifest Merge Request or Push
  30. Open Infrastructure & Cloud Native Days Korea 2019 (JU0QT ௏٘৬

    ࢸ੿ਸ ܻ࠙೮ਸ ٸ ੢੼ 1. গ೒ܻா੉࣌ ௏٘৬ ࢸ੿ਸ ݺഛೞѱ ܻ࠙ - ࢸ੿݅ ࣻ੿ೡ ٸ CI ࠽٘ܳ ೞ૑ ঋҊ ױࣽ൤ ੉޷૑ ߡ੹੉ա ࠂઁ ࢸ੿݅ ߸҃ೞҊ र ਸٸ ਬਊ 2. ӭՔೞѱ ੿ܻغח ۽Ӓ - ௏٘৬ ࢸ੿ ҙ۲ ۽Ӓо ࢴ੉૑ ঋ਺ 3. MSA ژח ৈ۞ѐ੄ গ೒ܻா੉࣌ਸ ೞա੄ ߓನ ױਤ۽ ҙܻೡ ࣻ ੓਺ 4. গ೒ܻா੉࣌ ࠽٘৬ ߓನ ӂೠਸ ܻ࠙ 5. CIীࢲ ߓನ ࢸ੿ਸ ਤ೧ gitਸ ࢎਊೞݶ git > ci > git > ci ޖೠ ܖ೐о ߊࢤೡ ࣻ ੓਺
  31. Open Infrastructure & Cloud Native Days Korea 2019 (JU0QT GitOps੄

    ੢੼ - gitী ੷੢ػ ࢸ੿੉ ௢ߡ֎౭झ ௿۞झఠ৬ زӝച ؽ - gitҗ ௢ߡ֎౭झܳ زӝച ೧઱ח ী੉੹౟о ઓ੤ - ݺ۸য ؀न ࢸ੿ ੿੄ - بҳܳ ށۄب ࢎਊೞӝ ए਑ (kubectl, helm, skaffold...) - ׮নೠ ੑ۱, ജ҃ पࣻ ߑ૑ - ௢ߡ֎౭झ ௿۞झఠ ੽Ӕӂೠ ܻ࠙ - Merge Requestܳ ੉ਊೞৈ ߓನܳ ਃ୒ೡ ࣻ ੓਺ - ݽٚ ࢸ੿ ੿ࠁо ߡ੹ҙܻ ؽ
  32. Open Infrastructure & Cloud Native Days Korea 2019 "SHP$% Argo

    CD - Declarative GitOps CD for Kubernetes - git ੷੢ࣗ੄ ࢸ੿౵ੌҗ ௢ߡ֎౭झ ௿۞झఠ زӝച - kustomize, helm, ksonnet, jsonnet, plain yaml manifest ૑ਗ - SSO ૑ਗ (OIDC, OAuth2, LDAP, SAML 2.0, GitHub, GitLab, ...) - WEB UI ઁҕ → ܻࣗझ ݽפఠ݂ ߂ ۽Ӓ ୹۱ - Webhook integration (GitHub, BitBucket, GitLab) - PreSync, Sync, PostSync hooks - য়೑ࣗझ
  33. Open Infrastructure & Cloud Native Days Korea 2019 ௢ߡ֎౭झܳ੉ਊೠ࠳ے஖߹పझ౟ࢲߡߓನ CI

    - Continuous Integration feature-1 branch git (app) image:feature-1 Jenkins build job env:feature-1 git (env)
  34. Open Infrastructure & Cloud Native Days Korea 2019 ௢ߡ֎౭झܳ੉ਊೠ࠳ے஖߹పझ౟ࢲߡߓನ CD

    - Continuous Deploy env:feature-1 git (env) ArgoCD feature-1.test.com feature-2.test.com {branch}.test.com kubernetes
  35. Open Infrastructure & Cloud Native Days Korea 2019 ௢ߡ֎౭झܳ੉ਊೠ࠳ے஖߹పझ౟ࢲߡߓನ ࢜۽਍

    ߓನ ೐۽ࣁझ੄ ੢੼ - ݽٚ ࠳ے஖ח ੗زਵ۽ ࠽٘غয بழ ੉޷૑ܳ ٜ݅Ҋ పझ౟ ࢲߡ ࢤࢿ - పझ౟ࢲߡח ز੸ਵ۽ ࢤࢿغҊ ࠗೞী ٮ۽ ੗زਵ۽ ഛ੢ - ࠳ے஖ݺਸ ੉ਊೞৈ بݫੋ ੗ز ࢤࢿ ({branch_name}.test.com) - kubectl, helm ݺ۸যܳ ށۄب ௢ߡ֎౭झী ߓನ оמ - WEB UIܳ ా೧ పझ౟ ઺ੋ ࠳ے஖ܳ ೠ׀ী ഛੋೞҊ ҙܻ - Spot ੋझఢझܳ ੉ਊೞৈ ؊ ੷۴ೠ ࠺ਊਵ۽ పझ౟ ࢲߡܳ ࢤࢿ
  36. Open Infrastructure & Cloud Native Days Korea 2019 ࢸ੿ Kubernetes

    - Amazon EKS - terraform (terraform-aws-eks module) - autoscaling_enabled: true - spot_price: xx - Helm package - cluster-autoscaler, k8s-spot-termination-handler - nginx-ingress, cert-manager
  37. Open Infrastructure & Cloud Native Days Korea 2019 ࢸ੿ Jenkins

    - Build job (open merge request from app repository webhook) - build - create & push container image - update helm chart value - Deploy job (push from env repository webhook) - create argo application - Close job (accept merge request from app repository webhook) - delete argo application
  38. Open Infrastructure & Cloud Native Days Korea 2019 ؀উ Continuous

    Integration - Jenkins X - Circle CI - GitLab CI - Travis CI - Tekton - Azure Devops
  39. Open Infrastructure & Cloud Native Days Korea 2019 ؀উ Continuous

    Deploy - kustomize - ksonnet - skaffold - spinnaker
  40. Open Infrastructure & Cloud Native Days Korea 2019 ؀উ Kubernetes

    Cluster - GoogleCloud - Azure - kops (AWS) - kubeadm, kubespray - k3s
  41. Open Infrastructure & Cloud Native Days Korea 2019 Ӓېࢲ "௢ߡ֎౭झח

    ࢜۽਍ ೒ۖಬਸ ٜ݅ӝ જ਷ ೒ۖಬ੉׮"
  42. Open Infrastructure & Cloud Native Days Korea 2019 Ӓېࢲ Kubernetes,

    Jenkins, ArgoCDח بҳੌ ࡺ GitOpsח ਍৔ ߑߨੌ ࡺ
  43. Open Infrastructure & Cloud Native Days Korea 2019 Ӓېࢲ ؊

    ա਷ ߑߨ, ؊ ա਷ ޙച ⁉ ߓನ যڌѱ ೞदաਃ? ҾӘ೤פ׮! ݆੉ ੉ঠӝ೧ਃ
  44. Open Infrastructure & Cloud Native Days Korea 2019 Ӓېࢲ ؊

    ੉ঠӝೞӝ - http://slack.opencontainer.co.kr/ - https://www.facebook.com/subicura - https://twitter.com/subicura - subicura(at)subicura(dot)com - ೣԋ दझమਸ ٜ݅Ҋ ѐࢶೞҊ र਷ ࠙ب োۅ઱ࣁਃ!