Taeyoung Kim

Cloud & Platform

Kubernetes 기반 GitOps 환경 구성

Kubernetes 기반 GitOps 환경 구성 학습 내용을 정리한 백필 노트입니다.

이 글은 2025년 학습 기록을 블로그 형식으로 정리한 백필 노트입니다.


💡 실습 핵심 사항

  1. GitOps 개념 이해
  2. Argo CD 기반 GitOps 환경 구성
  3. GitOps 기반 Cloud Native Application 배포 및 구성

GitOps 환경 개요

  • AKS(Azure Kubernetes Service) 클러스터를 활용하여 Argo CD 기반 GitOps 환경을 구축.
  • kubectl 명령으로 Argo CD 설치 → Helm Chart 기반 Cloud Native Application 구성.

참고 URL


실습 진행 순서

  1. kubectl 다운로드
  2. Argo CD 설치
  3. Argo CD CLI 다운로드 및 설치
  4. Argo CD API Server 외부 접근 설정
  5. Argo CD CLI 로그인
  6. Argo CD GUI 로그인
  7. Guestbook Application 배포 및 동기화

1. Argo CD 설치

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
  • 기본 설치 시 HTTPS 통신용 self-signed 인증서 자동 생성.

2. Argo CD CLI 설치

VERSION=$(curl -L -s https://raw.githubusercontent.com/argoproj/argo-cd/stable/VERSION)
curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/download/v$VERSION/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
rm argocd-linux-amd64
  • Windows PowerShell 예시
$version = (Invoke-RestMethod https://api.github.com/repos/argoproj/argo-cd/releases/latest).tag_name
$url = "https://github.com/argoproj/argo-cd/releases/download/" + $version + "/argocd-windows-amd64.exe"
$output = "argocd.exe"
Invoke-WebRequest -Uri $url -OutFile $output

3. Argo CD API Server 접근 설정

  • 기본적으로 external IP 미할당 → LoadBalancer 타입으로 변경 필요.
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
  • Port-forwarding으로도 접근 가능:
kubectl port-forward svc/argocd-server -n argocd 8080:443

4. Argo CD CLI 로그인

  • 초기 비밀번호 확인:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

또는

argocd admin initial-password -n argocd
  • 로그인:
argocd login <ARGOCD_SERVER>
  • 비밀번호 변경:
argocd account update-password

5. Argo CD GUI 로그인

  • 접속 후 admin / &lt;패스워드>로 로그인.

6. Guestbook Application 생성

  • CLI를 통한 생성:
kubectl config set-context --current --namespace=argocd
argocd app create guestbook \
  --repo https://github.com/argoproj/argocd-example-apps.git \
  --path guestbook \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace default
  • GUI를 통한 생성:
    • App name: guestbook
    • Project: default
    • Sync policy: Manual
    • Repo URL: https://github.com/argoproj/argocd-example-apps.git
    • Revision: HEAD
    • Path: guestbook
    • Cluster: https://kubernetes.default.svc
    • Namespace: default

7. Application 동기화 (Sync)

  • Application 상태 확인:
argocd app get guestbook
  • 동기화 실행:
argocd app sync guestbook
  • GUI에서 Synchronize 버튼 클릭 → Git 저장소와 실제 배포 상태를 동기화.