나이는 지구가 태양을 도는 횟수일 뿐이다.
ArgoCD 설치 본문
시작하기 앞서..
- 플랫폼 : GKE
- Helm차트를 이용하여 ArgoCD 배포 [차트 버전 5.13.8]
- 깃랩 저장소 연결하기ArgoCD설치
GKE클러스터 준비를 한다.
- mgmt 노드풀의 2개의 노드에 노드 셀렉터를 활용하여 사용
Helm차트 받기
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
helm pull argo/argocd --version 5.13.8
tar zxvf .\argo-cd-5.13.8.tgz
- 이렇게 하면 argo-cd 차트 폴더가 생긴다.
argo-cd
├─charts
│ └─redis-ha
└─templates
│ ├─argocd-application-controller
│ ├─argocd-applicationset
│ ├─argocd-configs
│ ├─argocd-notifications
│ ├─argocd-repo-server
│ ├─argocd-server
│ ├─crds
│ ├─dex
│ └─redis
└─values.yaml
Values 값넣기
- 내가 필요한 값은 ingress,nodeselector,GKE용 value, dex.config정도 인것같다.[ingress 안쓸시에 GKE용은 안하여도된다.]
- vscode를 켜고 values.yaml 파일에서 nodeSelector를 검색해서 그 밑에 원하는 노드 레이블을 넣어주었다.
nodeSelector:
cloud.google.com/gke-nodepool: mgmt
- GKE를 검색해서 frontendconfig와 googlemanagedcertificate를 추가하였다.
GKEmanagedCertificate:
# -- Enable ManagedCertificate custom resource for Google Kubernetes Engine.
enabled: true
# -- Domains for the Google Managed Certificate
domains:
- example.mydoamin.com
GKEfrontendConfig:
# -- Enable FrontConfig custom resource for Google Kubernetes Engine
enabled: true
# -- [FrontendConfigSpec]
# spec: {}
spec:
redirectToHttps:
enabled: true
- 하지만 여기서 함정이있는데 차트에는 밸류가 있지만 ingress annotations까지 흐름제어가 없어서 추가해주었다. [최신 차트에는 되어있을지도?]
- https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features?hl=ko GKE ingress 문서참조.
apiVersion: {{ include "argo-cd.apiVersion.ingress" . }}
kind: Ingress
metadata:
{{- if .Values.server.ingress.annotations }}
annotations:
{{- range $key, $value := .Values.server.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
===========추가한 부분===============
{{- if .Values.server.GKEmanagedCertificate.enabled }}
networking.gke.io/managed-certificates: {{ template "argo-cd.server.fullname" . }}
{{- end }}
{{- if .Values.server.GKEfrontendConfig.enabled }}
networking.gke.io/v1beta1.FrontendConfig: {{ template "argo-cd.server.fullname" . }}
{{- end }}
=====================================
{{- if and .Values.server.ingressGrpc.isAWSALB .Values.server.ingressGrpc.enabled }}
alb.ingress.kubernetes.io/conditions.{{ template "argo-cd.server.fullname" . }}-grpc: |
[{"field":"http-header","httpHeaderConfig":{"httpHeaderName": "Content-Type", "values":["application/grpc"]}}]
{{- end }}
{{- end }}
- dex.config를 추가하여 Google 로그인을 활성화 해보기로하였다.
https://argo-cd.readthedocs.io/en/stable/operator-manual/user-management/google/
configs:
# General Argo CD configuration
## Ref: https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/argocd-cm.yaml
cm:
# -- Create the argocd-cm configmap for [Declarative setup]
create: true
# -- Enable local admin user
## Ref: https://argo-cd.readthedocs.io/en/latest/faq/#how-to-disable-admin-user
admin.enabled: true
# -- Timeout to discover if a new manifests version got published to the repository
timeout.reconciliation: 180s
# -- Timeout to refresh application data as well as target manifests cache
timeout.hard.reconciliation: 0
statusbadge.enabled: "true"
dex.config: |
connectors:
- config:
issuer: https://accounts.google.com
clientID: myClientID
clientSecret: mySecret
hostedDomains:
- whitelistDomain
type: oidc
id: google
name: Google
rbac:
# -- Create the argocd-rbac-cm configmap with ([Argo CD RBAC policy]) definitions.
# If false, it is expected the configmap will be created by something else.
# Argo CD will not work if there is no configmap created with the name above.
create: true
# -- Annotations to be added to argocd-rbac-cm configmap
annotations: {}
# -- The name of the default role which Argo CD will falls back to, when authorizing API requests (optional).
# If omitted or empty, users may be still be able to login, but will see no apps, projects, etc...
policy.default: 'role:readonly'
- insecure,ingress,slack 알람등등 필요에 따라 사용하면된다.
- slack알람 참고문서 https://argocd-notifications.readthedocs.io/en/stable/services/slack/
배포하기
- values.yaml을 저장하고 배포하고 ingress 공인ip를 route53에 등록만 해주면된다.
helm install argo -f .\values.yaml . -n argo
kubectl get ingress -n argo
NAME CLASS HOSTS ADDRESS PORTS AGE
argo-argocd-server <none> mydomain 11.111.111.111 80 62d
- 프로비저닝된 공인ip를 route53에서 A레코드로 등록해주었다. [물론 ingress host에맞춰서...]
- 굳! 도메인으로 접속하니 귀여운 문어가 반겨주고있다.
- initialadmin암호를 넣어주고 접속하면된다. [본인은 vscode 확장프로그램 cloud-code로 secret을 확인하였다.]
gitlab repository 연결하기
- 먼저 연결할 저장소에서 deploy token을 생성해준다.
- 로그인한 argo-cd에서 좌측 패널의 settings > connect repo누르면 다음과같은 화면이 나온다.
- 저장소 URL과 username,password에 토큰에서 알려준 값을 그대로 넣고 Connect!
저장소 연결되었으니 오픈소스 배포해봐야겟다.
끝
'IT' 카테고리의 다른 글
[Helm]Subchart에 오픈소스 chart 추가하기 (0) | 2023.03.22 |
---|---|
GKE에서 ECR 이미지 사용하기 (0) | 2023.02.16 |
AWX로 앤서블 사용하기 (0) | 2023.01.30 |
K8s 모니터링 하기 [prometheus,grafana] (0) | 2023.01.16 |
AWX 설치하기 (0) | 2022.12.14 |