본문 바로가기

AWS/인프라 구축

[Argo CD]EKS Cluster에 Argo CD 배포

반응형

 

1. Argo CD 설치

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

 

 

2. 외부 접속 허용

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

 

3. Argo CD password 확인

최초 로그인 시 사용할 비밀번호 확인

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

4. 접속

kubectl get svc argocd-server -n argocd

 

 

 

5. 로그인

최초 username은 admin

password는 3번에서 확인한 비밀번호

 

 

로그인 후 비밀번호 변경

 

 

CLI로 로그인 및 비밀번호 변경하는 방법

# 로그인
argocd login <EXERNAL-IP>
# 비밀번호 변경
argocd account update-password

 

 

비밀번호는 8~32자로 설정

 

 

6. Github연동을 위한 SSH Key 생성

github repository에는 argocd로 배포할 yaml 파일이 올라가있다.

 

 

SSH Key 생성 방법은 Github 공식문서를 참고했다.

 

https://docs.github.com/ko/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

 

새 SSH 키 생성 및 ssh-agent에 추가 - GitHub Docs

기존 SSH 키를 확인한 후 인증에 사용할 새 SSH 키를 생성한 다음 ssh-agent에 추가할 수 있습니다.

docs.github.com

 

 

# ssh 키 생성
ssh-keygen -t ed25519 -C "your_email@example.com"

 

 

# ssh-agent를 백그라운드에서 실행
eval "$(ssh-agent -s)"
# ssh-agent에 SSH 프라이빗 키를 추가
ssh-add ~/.ssh/id_ed25519

 

 

 

6. 생성한 public SSH Key 추가

 

# Github 계정에 추가할 SSH Public Key 확인
cat /home/ubuntu/.ssh/id_ed25519.pub

 

이 퍼블릭 키를 복사해서 Github > Settings > SSH and GPG keys > New SSH key 에 추가

 

 

 

 

7. Argo CD와 Github repository 연결

 

ArgoCD > Settings > Repositories > Connect Repo

 

 

private SSH Key는 6번에서 키를 생성 할 때 나오는 경로에서 볼 수 있다.

 

cat /home/ubuntu/.ssh/id_ed25519

 

 

 

결과

 

 

참고한 argocd 공식사이트

 

https://argo-cd.readthedocs.io/en/stable/user-guide/private-repositories/

 

Private Repositories - Argo CD - Declarative GitOps CD for Kubernetes

Private Repositories Note Some Git hosters - notably GitLab and possibly on-premise GitLab instances as well - require you to specify the .git suffix in the repository URL, otherwise they will send a HTTP 301 redirect to the repository URL suffixed with .g

argo-cd.readthedocs.io

 

 

 

8. Argo CD application 생성

 

ArgoCD > Applications > NEW APP

 

Cluster URL은 https://kubernetes.default.svc로 설정.

 

Create 버튼 누르면 생성 완료.

 

 

 

만약 OutOfSync 상태면 SYNC > SYNCHRONIZE 버튼 클릭

 

 

만약 outofsync가 뜨면 SYNC버튼 눌러보기

 

 

 

9. 결과

 

 

 

 

반응형