6

Argo CD 설치 및 설정

 2 years ago
source link: https://dev.to/airoasis/argo-cd-seolci-mic-seoljeong-45bd
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

Enter fullscreen mode

Exit fullscreen mode

운영에서는 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

Enter fullscreen mode

Exit fullscreen mode


Argo CD 서비스 노출

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

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

Enter fullscreen mode

Exit fullscreen mode


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

Enter fullscreen mode

Exit fullscreen mode

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

kubectl get svc argocd-server -n argocd

Enter fullscreen mode

Exit fullscreen mode

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

argocd login <ARGOCD_SERVER_DOMAIN>

Enter fullscreen mode

Exit fullscreen mode

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

$ argocd account update-password

Enter fullscreen mode

Exit fullscreen mode


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 Set 이다.

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK