Kubernetes의 GitOps: ArgoCD 및 Flux를 활용한 배포 자동화


1. GitOps란?

GitOps는 Git을 소스 코드뿐만 아니라 배포 및 인프라 관리의 단일 원본(Source of Truth)으로 사용하는 운영 방식이다.
Kubernetes에서는 GitOps를 활용하여 CI/CD(Continuous Integration/Continuous Deployment) 자동화가 가능하다.

💡 GitOps를 사용하면?

  • 모든 배포 설정을 Git에서 버전 관리하여 변경 이력 추적 가능
  • 자동 동기화(Sync) 로 실시간으로 환경을 일관되게 유지
  • 사람이 개입하지 않아 안정적인 배포 및 롤백 가능
  • DevOps 및 Kubernetes 환경에서 IaC(Infrastructure as Code) 구현

2. GitOps의 핵심 개념

개념설명
Git RepositoryKubernetes 리소스(YAML 파일)를 저장하는 중앙 저장소
Pull-based DeploymentKubernetes 클러스터가 Git을 감시하고 자동으로 배포
Declarative ConfigurationKubernetes 리소스를 코드(YAML)로 정의하여 자동 적용
Reconciliation Loop현재 상태와 원하는 상태를 비교하여 자동 조정

3. GitOps 도구: ArgoCD vs Flux

도구설명
ArgoCDKubernetes 네이티브 GitOps 도구, 강력한 UI 제공
Flux경량 GitOps 도구, Git과 Kubernetes 연동에 최적화

✅ ArgoCD와 Flux 비교

비교 항목ArgoCDFlux
설치 방식Kubernetes 컨트롤러 배포Kubernetes 컨트롤러 배포
UI 제공✅ 웹 UI 제공❌ CLI 기반 관리
자동 동기화✅ 지원✅ 지원
멀티 클러스터 지원✅ 지원✅ 지원
Helm 지원✅ 지원✅ 지원

💡 ArgoCDGUI가 제공되어 운영이 편리하고, Flux경량 GitOps 도구로 자동화에 최적화되어 있다.


4. ArgoCD 설치 및 설정

1) ArgoCD 설치

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

2) ArgoCD CLI 설치

brew install argocd  # MacOS
choco install argocd-cli  # Windows

3) ArgoCD UI 접속

kubectl port-forward svc/argocd-server -n argocd 8080:443

웹 브라우저에서 https://localhost:8080 접속 후 로그인.
초기 관리자 계정: admin
비밀번호 확인:

kubectl get secret -n argocd argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

4) ArgoCD를 활용한 GitOps 배포

(1) Git 저장소 등록

argocd repo add https://github.com/my-repo/k8s-manifests.git --username my-user --password my-password

(2) 애플리케이션 배포

argocd app create my-app \
--repo https://github.com/my-repo/k8s-manifests.git \
--path my-app \
--dest-server https://kubernetes.default.svc \
--dest-namespace default

(3) 배포 상태 확인

argocd app list
argocd app get my-app

(4) 자동 동기화 활성화

argocd app set my-app --sync-policy automated

5. Flux 설치 및 설정

✅ 1) Flux 설치

kubectl apply -f https://github.com/fluxcd/flux2/releases/latest/download/install.yaml

✅ 2) Flux Git 리포지토리 연결

flux bootstrap github \
--owner=my-user \
--repository=my-repo \
--branch=main \
--path=./clusters/my-cluster

✅ 3) 애플리케이션 배포

kubectl apply -f app.yaml

✅ 4) 배포 상태 확인

flux get sources git
flux get kustomizations

6. GitOps 활용 사례

마이크로서비스 배포 자동화

  • 여러 서비스(Nginx, Redis, MySQL 등)를 GitOps로 자동 배포

CI/CD와 연동한 지속적 배포

  • GitHub Actions, Jenkins와 결합하여 코드 변경 → 자동 배포

멀티 클러스터 운영

  • ArgoCD를 활용하여 다중 Kubernetes 클러스터를 하나의 UI에서 관리

7. 결론

GitOps를 사용하면 Kubernetes 배포를 Git 기반으로 자동화 가능
ArgoCD는 강력한 UI와 기능을 제공하며, Flux는 경량화된 솔루션
배포 상태를 실시간 모니터링하고, 이력 관리를 통해 안정적인 운영 가능


댓글 달기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다