본문 바로가기
IT&Tech

Argo CD설치 istio를 이용한 https 구축

by walter 2022. 1. 22.

안녕하세요 Walter 입니다. 

 

오늘은 gitops를 구현하기 위한 argo cd를 설치 하고자합니다. 

아래와 같은 개발 github+argo cd+kubenetes 구성이 될듯합니다.  자세한 내용은 다음에 다루도록 하겠습니다. 

우선 아래와 같은 구성을 위해서 Argo CD를 구축해봅시다. 

 

준비물 

Istio 설치 - 서비스 메쉬 게이트웨어 

Cert-manager 설치 - 인증처리 

Kubernetes 환경 

 

Istio Sidecar 적용 

자동화 istio sidecar적용을 합니다.

# 네임스페이스는 argocd로 합니다. 
kubectl create namespace argocd

# argocd를 istio sidecar로 등록합니다. kubenetes master의 컨트럴러 등록
kubectl label namespace argocd istio-injection=enabled

 

Argo CD 설치 

최신 안정화 버전으로 아래와 같이 설치합니다. 

argocd-server를 설치후 insecure로 바꾸서도 됩니다.

이번에는 우선 insecure로 수정해서  설치하겠습니다.  

# 다운로드 
curl -L -o argocd.yaml https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

# argocd-server deployment에서 Disable TLS로 수정합니다. 
vi argocd.yaml  3383라인쪽을 확인하세요.

...
      containers:
      - command:
        - argocd-server
      - args:
        - --insecure
        :ㅂ
위와 같이 argocd-server부분의 deployment에서 args설정에 insecure를 넣어주세요.

# 설치 
kubectl apply -n argocd -f argocd.yaml

 

Certification 설정

 

저희 블로그에서 cert-manager를 참고하시면 아래 내용을 이해 할 수 있습니다.

적절한 도메인 이름과 isserRef의 이름을 넣어주세요.   

 

secretName : argocd-server-tls (certificate 설치시 해당 secret으로 생성요청되어 추가됩니다 secrets에서 확인 가능합니다. )

letsencrypt-prod:  이미  해당이름으로 clusterissuer로 등록한 상태입니다.  중요

commonName, dnsName은 동일하게 적용할 도메인 넣어주세요

 

kubectl apply -f certification.yaml (대략 certificate 상태가 TRUE 완료까지 1~2분가량 소요됩니다.)

# certification.yaml

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: argocd-server
  namespace: istio-system # istio 설치경로
spec:
  secretName: argocd-server-tls <- gateway에서 사용할 secret이름을 설정 원하는 이름 넣어주세요.
  isCA: true
  issuerRef:
    name: letsencrypt-prod <- 이전에 생성한 letsencrypt-prod 값 이전 cert-manager세션을 참고
    kind: ClusterIssuer
  commonName: argo.walter.com <- 적용할 도메인 
  dnsNames: 
  - argo.walter.com <- 적용할 도메인

 

Istio Gateway 설정 

 

tls부분에서 credentailName을 certification에서 설정한 이름 넣어주세요.

kubectl apply -f gateway.yaml 

# gateway.yaml 

kind: Gateway
apiVersion: networking.istio.io/v1alpha3
metadata:
  name: argocd-server
  namespace: istio-system
spec:
  servers:
    - hosts:
        - '*'
      port:
        name: http
        number: 80
        protocol: HTTP
      tls:
        httpsRedirect: true 
    - hosts:
        - 'argo.walter.com'
      port:
        name: https
        number: 443
        protocol: HTTPS
      tls:
        credentialName: argocd-server-tls
        mode: SIMPLE
  selector:
    app: istio-ingressgateway

 

Istio VirtualService 설정

http destination에서 host설정을 argocd 네임스페이스에 있는 argocd-server 서비스 주소를 넣어주셔야 됩니다.

dns : argocd-server.argocd.svc.cluster.local

 

 

kubectl apply -f virtualservice.yaml 

# virtualservice.yaml 
---
#VirtualService
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
  name: argocd-server
  namespace: istio-system
spec:
  gateways:
    - argocd-server
  hosts:
    - 'argo.walter.com'
  http:
  - route:
    - destination:
        host: argocd-server.argocd.svc.cluster.local
        port:
          number: 80

 

Route53 도메인 세팅

istio ingressgateway의 서비스에서 Loadbalance ELB주소를 세팅합니다. 

 

argo.walter.com CNAME istio ingressgateway ELB주소 

 

 

이슈

처음 설치시 certification의 issuer등록이 제대로 이루어졋다면 큰 문제없이 진행될듯합니다.

certification의 상태를 체크하면서 문제 없는지 확인합니다. 

 

kubectl get certificate 
NAME                          READY    SECRET                                    AGE
argocd                        True    argocd-server-tls                        16h

# certificate 요청 체크 아래와 같이 하나씩 체크해본다. 
kubectl get certificate
kubectl get certificaterequest
kubectl get order
kubectl get challenge