CICD 배포/CICD 배포
[ ArgoCD ] 구성
김붕어87
2023. 2. 8. 14:58
반응형
개요
ArgoCD은 kubernetes 배포 툴입니다.
kubernetes에 리소스는 kubectl apply 명령어 배포와, helm install 명령어으로 배포가 가능합니다.
점점 늘어나는 여러개의 pod들을 명령어로 배포하고 관리하기 쉽지 않기 때문에, 배포툴을 사용해야합니다.
ArgoCD는 helm 배포와 GitHub(yaml) 배포 방식 2가지를 지원합니다.
ArgoCD Flow Architecture

ArgoCD 구성
1. ArgoCD 서버 install
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.0.4/manifests/install.yaml
2. ArgoCD ELB 연결
- 선택1) ELB 연결 방법
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
-- 추가 옵션 --
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb or clb
- 선택2) ALB 연결 방법
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:ap-southeast-1:xxxxx:certificate/xxxxxxx
alb.ingress.kubernetes.io/group.name: xxxx-argocd
alb.ingress.kubernetes.io/load-balancer-name: xxxx-argocd
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]'
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/ssl-redirect: "443"
alb.ingress.kubernetes.io/backend-protocol: HTTPS
alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig":
{ "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_303"}}'
alb.ingress.kubernetes.io/target-type: ip
kubernetes.io/ingress.class: alb
name: argocd
namespace: argocd
spec:
rules:
- host: argocd.xxx.com
http:
paths:
- backend:
service:
name: argocd-server
port:
name: https
path: /
pathType: Prefix
tls:
- hosts:
- argocd.xxx.com
3. ArgoCD 로그인
- ALB 설정된 DNS 접속
- ID : Admin
- PW : secret/argocd-initial-admin-secret 정보에서 패스워드를 추출해서 로그인 (명령어 참조)
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
4. ArgoCD Password 변경
- ArgoCD tool 설치
brew install argocd # argocd tool 설치
- ArgoCD 로그인
argocd login argocd.dev.xxx.com # 로그인
- ArgoCD password 변경
argocd account update-password --account admin
EKS Cluster 추가
- ArgoCD에서 EKS Cluster 추가하려면 ArgoCD CLI 명령어로 해야한다.
- ArgoCD CLI Login
argocd login argocd.dev
ArgoCD 명령어를 수행하려면 Login해서 인증해야한다.
- ArgoCD에 EKS Cluster 추가
EKS_CLUSTER=`kubectl config get-contexts -o name`
argocd cluster add $EKS_CLUSTER --name < EKS 이름 >
argocd cluster list
- ArgoCD EKS Cluster 등록 확인
ArgoCD web 페이지에서 확인 가능 : https://xxxxxx.com/settings/clusters
CONNECTION STATUS가 Unknow 상태로 뜨는 이유는 Application 배포를 아직 하지 않아서 입니다.

ArgoCD Release-Name 변수 지정
- ArgoCD Application의 이름이 Release-Name이 되어서 pod 생성하면 이름이 길게 나오는 문제가 발생한다.
- ArgoCD 명령어로 Application를 생성할 때 --release-name 옵션으로 이름을 바꿀 수 있다.
argocd app create xxxx-airflow --repo git@github.com:xxxxxx/xxxxxxx.git --path airflow --dest-namespace infra --dest-server https://xxxxxxxxx.gr7.ap-southeast-1.eks.amazonaws.com --release-name airflow
argocd app create xxxx-keycloak-test --repo http://10.223.85.32:9090 --helm-chart keycloak --revision 15.1.0 --dest-namespace infra --dest-server https://3xxxxxxxx8.yl4.ap-southeast-1.eks.amazonaws.com --release-name keycloak
반응형