Argo CD 설치 및 설정

Thomas Kim·2021년 12월 17일
1

ArgoCDGitOps 로 관리되는 Kubernetes manifests의 변경사항을 Monitoring 하며 실제 Cluster 에 배포된 형태를 이와 동일하게 계속 유지시키는 역할을 한다.

Argo CD 설치

https://argo-cd.readthedocs.io/en/stable/getting_started/
Argo CD를 kubernetes cluster 에 설치

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

운영에서는 HA 버전의 Argo CD를 설치한다.


Argo CD CLI 설치

Argo CD CLI 설치

$ curl -sSL -o ~/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
$ chmod +x ~/bin/argocd

Argo CD 서비스 노출

Argo CD는 default로 서버를 외부로 노출시키지 않는다. 아래와 같이 서비스타입을 LoadBalancer로 변경하여 외부로 노출시킨다.

$ kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'

admin password 변경

Argo CD는 최초 admin account의 초기 password를 kubernetes 의 secret 으로 저장해 놓는다. 아래와 같이 password를 얻는다.

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

Argo CD CLI를 이용하여 Argo CD에 로그인한다. 우선 생성된 Load Balancer의 주소를 얻는다.

kubectl get svc argocd-server -n argocd

그리고 Login 한다. Username은 admin 이다

argocd login <ARGOCD_SERVER_DOMAIN>

admin 유저의 password를 업데이트 한다.

$ argocd account update-password

Argo CD는 Git repository를 3분에 한번씩 pollin 하면서 실제 kubernetes cluster 와 다른점을 확인한다. 따라서 배포시에 운이 없다면 최대 3분을 기다려야 Argo CD 가 변경된 image를 배포하게 된다. 이렇게 Polling 으로 인한 delay 를 없애고 싶다면 Git repository 에 Argo CD로 webhook을 만들어 놓으면 된다. 아래 link 참고
https://argo-cd.readthedocs.io/en/stable/operator-manual/webhook/

그리고 보통 Argo CD는 내부 개발자나 운영자 외에는 접근을 막기 위해 Security group 에서 특정 IP 만 inbound 로 열어 놓는 경우가 있다. 이 때 위와 같이 webhook 을 만들어 놓았다면 반드시 Argo CD의 load balancer에 Github 의 webhook 관련 API 도 inbound로 열어줘야 한다.

아래 링크에 GitHub 의 IP 주소 관련 내용이 있고,
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-githubs-ip-addresses
실제 inbound 에 넣줘야 하는 IP는 아래에서 확인할 수 있다.hooks 에 있는 리스트를 넣어주면 된다.
https://api.github.com/meta

Argo CD Notification 을 사용하여 Slack 에 notification 을 보내는 설정도 하면 개발팀에서 배포가 잘 안된 경우, 알림을 받을 수 있다.

Argo CD의 ApplicationSet 을 활용하여 프로젝트를 셋업하는 방법도 있다. 예전에는 App of Apps 를 사용했다면 여기서 좀 더 발전된 개념이 Application Sets 이다.

GitOps는 현재 1.0이 공식 버전이고 곧 업데이트 된 개념이 나올 예정이다.
https://opengitops.dev/
https://github.com/open-gitops/documents

GitOps 1.0 의 문제점은 The pains of GitOps 1.0 참고.
현재 Kubernetes 의 configuration 관리를 위해 kustomize를 사용중이고 Argo CD 에서 kustomize를 이용한 배포를 한다. 만약 kustomize나 helm에서 branching을 사용한다면 Stop Using Branches for Deploying to Different GitOps Environments 를 읽어보면 도움이 될거 같다.

실제 Argo CD를 사용하고 있는 스크린샷

profile
Software Developer at SK Telecom

0개의 댓글