개요
ArgoCD는 Kubernetes 리소스를 코드화하여 GitOps 방식으로 관리할 수 있는 도구이다. 그러나 정작 ArgoCD 자체를 프로비저닝 하거나 GitOps 환경을 구성하는 과정은 여전히 수작업이 필요하다.
이러한 불편함을 해소하기 위해 등장한 도구가 바로 ArgoCD Autopilot이다. 이를 통해 ArgoCD를 자동 프로비저닝하고 GitOps 환경까지 표준화된 구조로 구성할 수 있다.
이번 포스팅에서는 ArgoCD Autopilot의 주요 기능과 사용법을 알아보자.
ArgoCD Autopilot 소개
ArgoCD Autopilot은 GitOps 기반 배포 도구인 ArgoCD를 간편하게 설치하고 관리할 수 있도록 설계된 도구로 Argo 프로젝트에 포함되어 있다.
단순히 ArgoCD 설치를 자동화하는 것에 그치지 않고, GitOps 환경 초기화와 애플리케이션 및 클러스터 선언적 관리까지 가능하다.
주요 기능은 다음과 같다.
- ArgoCD 설치 자동화
- 간단한 명령어로 ArgoCD를 설치하고 GitOps 환경 구성
- GitOps 디렉토리 구조 표준화
- Git 저장소에 디렉토리 구조를 자동으로 생성하고 관리 편의성을 제공
ArgoCD Autopilot 설치
Autopilot CLI를 설치하자.
MacOS
brew
# install
brew install argocd-autopilot
# check the installation
argocd-autopilot version
curl로 설치
# get the latest version or change to a specific version
VERSION=$(curl --silent "https://api.github.com/repos/argoproj-labs/argocd-autopilot/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
# download and extract the binary
curl -L --output - https://github.com/argoproj-labs/argocd-autopilot/releases/download/"$VERSION"/argocd-autopilot-darwin-amd64.tar.gz | tar zx
# move the binary to your $PATH
mv ./argocd-autopilot-* /usr/local/bin/argocd-autopilot
# check the installation
argocd-autopilot version
Linux
curl로 설치
# get the latest version or change to a specific version
VERSION=$(curl --silent "https://api.github.com/repos/argoproj-labs/argocd-autopilot/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
# download and extract the binary
curl -L --output - https://github.com/argoproj-labs/argocd-autopilot/releases/download/"$VERSION"/argocd-autopilot-linux-amd64.tar.gz | tar zx
# move the binary to your $PATH
sudo mv ./argocd-autopilot-* /usr/local/bin/argocd-autopilot
# check the installation
argocd-autopilot version
Docker
Docker를 사용해서 autopilot을 사용할 수 있다.
docker run \
-v ~/.kube:/home/autopilot/.kube \
-v ~/.gitconfig:/home/autopilot/.gitconfig \
-it quay.io/argoprojlabs/argocd-autopilot <cmd> <flags>
ArgoCD Autopilot 기본 사용법
사전 준비
- 쿠버네티스 클러스터
- Git 레포지토리(GitOps 환경으로 사용할 레포지토리)
- 지원되는 Git 플랫폼 : GitHub, GitLab, Bitbucket, Gitea 등.
GitOps 레포지토리로 사용할 Github 레포지토리를 생성한다.
ArgoCD 설치
Autopilot을 사용하기 위해 레포지토리 정보에 맞게 환경변수를 지정한다.
# 형식
export GIT_TOKEN=<레포지토리 토큰>
export GIT_REPO=<레포지토리 주소>
# 사용 예시
export GIT_TOKEN=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
export GIT_REPO=https://github.com/hackjap/autopilotdemo.git
# 확인
echo GIT_TOKEN
echo GIT_REPO
ArgoCD를 설치하고 등록한 레포지토리에 GitOpt 환경을 설정한다.
# 설치
argocd-autopilot repo bootstrap
# 설치 후 파드 확인
kubectl get pod -n argocd
NAME READY STATUS RESTARTS AGE
argocd-application-controller-0 1/1 Running 0 85m
argocd-applicationset-controller-684cd5f5cc-4c47m 1/1 Running 0 85m
argocd-dex-server-77c55fb54f-c4l6x 1/1 Running 0 85m
argocd-notifications-controller-69cd888b56-8zz46 1/1 Running 0 85m
argocd-redis-55c76cb574-llf4c 1/1 Running 0 85m
argocd-repo-server-584d45d88f-sxkr4 1/1 Running 0 85m
argocd-server-8667f8577-s2lsl 1/1 Running 0 85m
아래 옵션을 추가하면 ArgoCD를 HA로 구성할 수도 있다.
# ha 모드도 지원
argocd-autopilot repo bootstrap --app https://github.com/argoproj-labs/argocd-autopilot/manifests/ha
설치 확인
- 설치가 완료되면 출력되는 ArgoCD 초기 비밀번호와 포트포워딩 명령어를 통해 Web UI에 접속한다.
ArgoCD BootStrap에 필요한 기본적인 애플리케이션이 구성되어 있는 것을 확인할 수 있다.
GitOps환경 구성에 맞게 레포지토리의 파일 구성또한 적용된 것을 확인해볼 수 있다.
프로젝트 및 애플리케이션 생성
이제 프로젝트와 기본 애플리케이션을 생성하고 확인해 보자.
프로젝트 생성
스테이지 환경별로 프로젝트를 만들어서 관리해 보자.
# 예시
argocd-autopilot project create <PROJECT_NAME>
# 프로젝트 생성
argocd-autopilot project create deployment
argocd-autopilot project create staging
argocd-autopilot project create production
INFO cloning git repository: https://github.com/hackjap/autopilotdemo.git
Enumerating objects: 18, done.
Counting objects: 100% (18/18), done.
Compressing objects: 100% (13/13), done.
Total 18 (delta 1), reused 17 (delta 1), pack-reused 0 (from 0)
INFO using revision: "", installation path: "/"
INFO pushing new project manifest to repo
INFO project created: 'development
ArgoCD에서도 프로젝트가 잘 생성된 것을 확인할 수 있다.
ArgoCD의 적용사항이 깃 레포지토리에 자동 커밋되어 반영되는 것이 큰 특징이다.
애플리케이션 생성
deployment 프로젝트에 데모 애플리케이션을 생성하고 배포해보자.
# 예시
argocd-autopilot app create dir-example --app github.com/argoproj-labs/argocd-autopilot/examples/demo-dir/ -p <PROJECT_NAME> --type kustomize
# 애플리케이션 생성
argocd-autopilot app create hello-world --app github.com/argoproj-labs/argocd-autopilot/examples/demo-app/ -p development --type kustomize
INFO cloning git repository: https://github.com/hackjap/autopilotdemo.git
Enumerating objects: 19, done.
Counting objects: 100% (19/19), done.
Compressing objects: 100% (15/15), done.
Total 19 (delta 2), reused 17 (delta 1), pack-reused 0 (from 0)
INFO using revision: "", installation path: "/"
INFO committing changes to gitops repo...
INFO installed application: hello-world
Kustomize 파일이 잘 생성됨을 확인할 수 있다.
ArgoCD에서도 애플리케이션도 잘 배포된 것을 확인할 수 있다.
GitOps 디렉터리 구조
autopilot을 사용하면 아래와 같은 표준 된 GitOps 디렉터리 구조로 구성되는 것을 확인할 수 있다.
• apps/:
애플리케이션 디렉터리.
• projects/:
환경별 프로젝트 정의.
• bootstrap/:
ArgoCD 초기 설정 및 클러스터 리소스.
tree autopilotdemo
autopilotdemo
├── README.md
├── apps
│ ├── README.md
│ └── hello-world
│ ├── base
│ │ └── kustomization.yaml
│ └── overlays
│ └── development
│ ├── config.json
│ └── kustomization.yaml
├── bootstrap
│ ├── argo-cd
│ │ └── kustomization.yaml
│ ├── argo-cd.yaml
│ ├── cluster-resources
│ │ ├── in-cluster
│ │ │ ├── README.md
│ │ │ └── argocd-ns.yaml
│ │ └── in-cluster.json
│ ├── cluster-resources.yaml
│ └── root.yaml
└── projects
├── README.md
└── development.yaml
리소스 삭제
실습 후에는 아래 명령어를 통해 실습 리소스를 삭제한다.
argocd-autopilot repo uninstall
결론
ArgoCD Autopilot은 ArgoCD 설치와 GitOps 환경 구성을 자동화하여 GitOps 도입을 빠르고 간편하게 할 수 있도록 돕는 도구이다. 표준화된 GitOps 파일 구조를 제공하니, GitOps를 처음 도입하는 팀이나 교육 및 테스트 목적으로 활용하기에 유용할 것 같다.
또한, kustomize 이외에 향후 Helm Chart 지원이 로드맵에 포함되어 있어 다양하게 활용할 수 있을 것 같아 기대해 볼만하다. GitOps를 도입하려는 팀이라면 ArgoCD Autopilot을 도입하여 빠르게 작업 환경을 구축하고 GitOps를 학습해보는 것을 추천한다.
참고 문서
'CICD' 카테고리의 다른 글
GitLab CI/CD 기본 사용 방법 및 CI/CD 워크플로우 구성 (0) | 2024.12.21 |
---|---|
Github Actions 기본 사용 방법 및 CI/CD 워크플로우 구성하기 (2) | 2024.12.14 |
jib를 활용하여 젠킨스 파이프라인 구성하기(GitOps + SpringBoot + Gradle ) (2) | 2024.12.08 |
docker build 시, 빌드 명령어 결과 출력하기(--progress=plain) (0) | 2024.03.18 |
ArgoCD Image Updater를 활용한 Harbor RegistryOps 구축 가이드 (0) | 2023.12.12 |