๐น Argo CD ๋ฉํฐ ํด๋ฌ์คํฐ ๊ด๋ฆฌ๋?
Argo CD๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํ๋์ Kubernetes ํด๋ฌ์คํฐ์์ ์ ํ๋ฆฌ์ผ์ด์
์ ๋ฐฐํฌ ๋ฐ ๊ด๋ฆฌํ ์ ์์ต๋๋ค.
ํ์ง๋ง ๋ฉํฐ ํด๋ฌ์คํฐ ํ๊ฒฝ์์๋ ํ๋์ Argo CD ์ธ์คํด์ค๋ก ์ฌ๋ฌ ํด๋ฌ์คํฐ๋ฅผ ๊ด๋ฆฌํ ์ ์์ต๋๋ค.
โ ๋ฉํฐ ํด๋ฌ์คํฐ ๊ด๋ฆฌ๊ฐ ํ์ํ ์ด์
โ ํ๊ฒฝ ๋ถ๋ฆฌ → Dev, Staging, Prod ๋ฑ ์๋ก ๋ค๋ฅธ ํด๋ฌ์คํฐ์ ์ ํ๋ฆฌ์ผ์ด์
์ ๋ฐฐํฌ
โ ํ๋์ Argo CD์์ ์ค์ ์ง์ค์์ผ๋ก ์ฌ๋ฌ ํด๋ฌ์คํฐ ๊ด๋ฆฌ
โ GitOps ๊ธฐ๋ฐ์ผ๋ก ๋ชจ๋ ํด๋ฌ์คํฐ์ ๋๊ธฐํ ์ํ ์ ์ง
โ ์ด์ ํจ์จ์ฑ ํฅ์ ๋ฐ ๋ฐฐํฌ ์๋ํ ๊ฐํ
โ Argo CD ๋ฉํฐ ํด๋ฌ์คํฐ ๊ด๋ฆฌ ๋ฐฉ์
๋ฐฉ์ | ์ค๋ช |
Direct Cluster Mode | Argo CD๊ฐ ์ฌ๋ฌ ํด๋ฌ์คํฐ์ ์ง์ ์ฐ๊ฒฐํ์ฌ ๊ด๋ฆฌ |
App of Apps Pattern | ์ค์ ๊ด๋ฆฌ์ฉ Argo CD์์ ์ฌ๋ฌ ํด๋ฌ์คํฐ์ Application์ ๋ฐฐํฌ |
ApplicationSet | ์๋์ผ๋ก ์ฌ๋ฌ ํด๋ฌ์คํฐ์ ๋์ ์ผ๋ก ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐฐํฌ |
๐น 1. Argo CD์์ ๋ฉํฐ ํด๋ฌ์คํฐ๋ฅผ ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ
Argo CD๊ฐ ๋ค๋ฅธ ํด๋ฌ์คํฐ๋ฅผ ๊ด๋ฆฌํ๋ ค๋ฉด, ์ถ๊ฐํ ํด๋ฌ์คํฐ์ Kubeconfig ์ ๋ณด๋ฅผ ๋ฑ๋กํด์ผ ํฉ๋๋ค.
โ 1๏ธโฃ Argo CD CLI๋ฅผ ์ฌ์ฉํ ํด๋ฌ์คํฐ ์ถ๊ฐ ๋ฐฉ๋ฒ
argocd cluster add <context-name>
โ ์์ : staging-cluster๋ฅผ ์ถ๊ฐํ๋ ๋ช ๋ น์ด
argocd cluster add staging-cluster
โ
์ค๋ช
:
โ <context-name> → kubectl config get-contexts ๋ช
๋ น์ด๋ก ํ์ธ ๊ฐ๋ฅ
โ ์ถ๊ฐํ ํด๋ฌ์คํฐ๋ argocd cluster list ๋ช
๋ น์ด๋ก ํ์ธ ๊ฐ๋ฅ
โ ํ์ฌ ๋ฑ๋ก๋ ํด๋ฌ์คํฐ ๋ชฉ๋ก ํ์ธ
argocd cluster list
โ ์ถ๋ ฅ ์์:
SERVER NAME STATUS VERSION
https://34.120.0.1 staging-cluster Connected v1.24
https://35.200.1.2 prod-cluster Connected v1.24
๐น 2. ๋ฉํฐ ํด๋ฌ์คํฐ ๋ฐฐํฌ๋ฅผ ์ํ Application ์์
๊ฐ ํด๋ฌ์คํฐ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐฐํฌํ๋ ค๋ฉด, destination.server ๊ฐ์ ๋ณ๊ฒฝํ์ฌ ํด๋ฌ์คํฐ๋ฅผ ์ง์ ํด์ผ ํฉ๋๋ค.
โ ์ฌ๋ฌ ํด๋ฌ์คํฐ์ ๋ฐฐํฌํ๋ Argo CD Application ์์
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: frontend-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/example/repo.git
targetRevision: main
path: k8s/frontend
destination:
server: https://34.120.0.1 # ๋ฐฐํฌํ ํด๋ฌ์คํฐ (staging-cluster)
namespace: frontend
syncPolicy:
automated:
prune: true
selfHeal: true
โ
์ค๋ช
:
โ destination.server → argocd cluster list์์ ํ์ธํ ํด๋ฌ์คํฐ ์ฃผ์ ์
๋ ฅ
โ namespace: frontend → ์ ํ๋ฆฌ์ผ์ด์
์ด ๋ฐฐํฌ๋ ๋ค์์คํ์ด์ค
โ syncPolicy.automated → Git ๋ณ๊ฒฝ ์ฌํญ์ด ์๋์ผ๋ก ๋ฐ์๋๋๋ก ์ค์
โ ๋ค๋ฅธ ํด๋ฌ์คํฐ์๋ ๋์ผํ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐฐํฌํ๋ ค๋ฉด destination.server๋ง ๋ณ๊ฒฝ
destination:
server: https://35.200.1.2 # prod-cluster๋ก ๋ณ๊ฒฝ
๐น 3. App of Apps ํจํด์ ํ์ฉํ ๋ฉํฐ ํด๋ฌ์คํฐ ๋ฐฐํฌ
App of Apps ํจํด์ ์ค์์ Argo CD๊ฐ ์ฌ๋ฌ ํด๋ฌ์คํฐ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ด๋ฆฌํ ์ ์๋๋ก ํฉ๋๋ค.
โ 1๏ธโฃ App of Apps๋ฅผ ์ํ Application ์์
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: multi-cluster-apps
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/example/repo.git
targetRevision: main
path: apps
destination:
server: https://kubernetes.default.svc
namespace: argocd
syncPolicy:
automated:
prune: true
selfHeal: true
โ
์ค๋ช
:
โ multi-cluster-apps → ์ฌ๋ฌ ํด๋ฌ์คํฐ์ ์ ํ๋ฆฌ์ผ์ด์
์ ๊ด๋ฆฌํ๋ Argo CD Application
โ repoURL, path → Git์์ ๊ด๋ฆฌํ๋ ์ ํ๋ฆฌ์ผ์ด์
๋ชฉ๋ก์ด ์ ์ฅ๋ ๊ฒฝ๋ก
โ destination.server: https://kubernetes.default.svc → Argo CD๊ฐ ์คํ ์ค์ธ ํด๋ฌ์คํฐ์์ ๊ด๋ฆฌ
โ ๊ฐ ํด๋ฌ์คํฐ๋ณ Application์ ์ ์ํ YAML ์์ (apps/ ๋๋ ํฐ๋ฆฌ ๋ด)
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: frontend-app-staging
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/example/repo.git
targetRevision: main
path: k8s/frontend
destination:
server: https://34.120.0.1 # Staging ํด๋ฌ์คํฐ
namespace: frontend
syncPolicy:
automated:
prune: true
selfHeal: true
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: frontend-app-prod
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/example/repo.git
targetRevision: main
path: k8s/frontend
destination:
server: https://35.200.1.2 # Production ํด๋ฌ์คํฐ
namespace: frontend
syncPolicy:
automated:
prune: true
selfHeal: true
โ
์ค๋ช
:
โ multi-cluster-apps์์ ๊ฐ๋ณ ํด๋ฌ์คํฐ๋ณ Application์ ๊ด๋ฆฌ
โ ๊ฐ ์ ํ๋ฆฌ์ผ์ด์
์ ์๋ก ๋ค๋ฅธ destination.server๋ฅผ ๊ฐ์ง
โ App of Apps ์ ์ฉ ๋ฐฉ๋ฒ
argocd app sync multi-cluster-apps
โ ๋ฐฐํฌ๋ ์ ํ๋ฆฌ์ผ์ด์ ํ์ธ
argocd app list
๐น 4. Argo CD ๋ฉํฐ ํด๋ฌ์คํฐ ์ด์ ์ ๊ณ ๋ คํ ์
โ
1๏ธโฃ RBAC์ ํ์ฉํ ํด๋ฌ์คํฐ๋ณ ์ ๊ทผ ๊ถํ ์ค์
โ ๊ฐ๋ฐํ/์ด์ํ ๋ณ๋ก ํน์ ํด๋ฌ์คํฐ๋ง ๊ด๋ฆฌํ ์ ์๋๋ก RBAC ์ ์ฉ ํ์
โ argocd-rbac-cm.yaml ์ค์ ์์ p, role:dev, applications, get, staging/*, allow ๋ฐฉ์์ผ๋ก ํด๋ฌ์คํฐ ์ ๊ทผ ์ ํ ๊ฐ๋ฅ
โ
2๏ธโฃ ํด๋ฌ์คํฐ ๊ฐ ๋คํธ์ํฌ ์ฐ๊ฒฐ ์ค์
โ Argo CD ์๋ฒ๊ฐ ์ฌ๋ฌ ํด๋ฌ์คํฐ์ ์ ๊ทผํ๋ ค๋ฉด ํด๋ฌ์คํฐ ๊ฐ VPN ์ค์ ๋๋ Kubernetes API ์ ๊ทผ ๊ฐ๋ฅํด์ผ ํจ
โ
3๏ธโฃ App of Apps ํจํด ์ฌ์ฉ ์ ๋ฆฌํฌ์งํ ๋ฆฌ ๊ตฌ์กฐ ์ ๋ฆฌ
โ ์ฌ๋ฌ ํด๋ฌ์คํฐ๋ฅผ ๊ด๋ฆฌํ ๊ฒฝ์ฐ, Git ์ ์ฅ์๋ฅผ ํด๋ฌ์คํฐ ๋ณ๋ก ๊ตฌ๋ถํ๊ฑฐ๋ apps/ ๋๋ ํฐ๋ฆฌ ๊ตฌ์กฐ๋ฅผ ์ผ๊ด์ฑ ์๊ฒ ์ ์งํ๋ ๊ฒ์ด ์ค์
๐น ๊ฒฐ๋ก : ์ด๋ฒ ๊ธ์์ ๋ฐฐ์ด ํต์ฌ ๋ด์ฉ ์ ๋ฆฌ
๐ข Argo CD๋ ์ฌ๋ฌ Kubernetes ํด๋ฌ์คํฐ๋ฅผ ๊ด๋ฆฌํ ์ ์์ผ๋ฉฐ, ๋ฉํฐ ํด๋ฌ์คํฐ ํ๊ฒฝ์ ์ง์
๐ข App of Apps ํจํด์ ํ์ฉํ๋ฉด ์ค์ Argo CD์์ ๋ชจ๋ ํด๋ฌ์คํฐ์ ์ ํ๋ฆฌ์ผ์ด์
์ ์ผ๊ด ๊ด๋ฆฌ ๊ฐ๋ฅ
๐ข RBAC์ ํ์ฉํ์ฌ ํ๋ณ๋ก ํน์ ํด๋ฌ์คํฐ ์ ๊ทผ ๊ถํ์ ์ ํ ๊ฐ๋ฅ
๐ข ํด๋ฌ์คํฐ ๊ฐ ๋คํธ์ํฌ ์ฐ๊ฒฐ ๋ฐ GitOps ๋ฐฉ์์ผ๋ก ์ค์ ์ ์ ์งํ์ฌ ์ด์์ ์ผ๊ด์ฑ์ ๋ณด์ฅํ ์ ์์