4장. Argo CD Application Controller 복제본에 클러스터 분할
컨트롤러가 너무 많은 클러스터를 관리하고 너무 많은 메모리를 사용하는 경우 여러 Argo CD Application Controller 복제본에 클러스터를 분할할 수 있습니다.
4.1. 라운드 로빈 분할 알고리즘 활성화
라운드 로빈
분할 알고리즘은 기술 프리뷰 기능 전용입니다. 기술 프리뷰 기능은 Red Hat 프로덕션 서비스 수준 계약(SLA)에서 지원되지 않으며 기능적으로 완전하지 않을 수 있습니다. 따라서 프로덕션 환경에서 사용하는 것은 권장하지 않습니다. 이러한 기능을 사용하면 향후 제품 기능을 조기에 이용할 수 있어 개발 과정에서 고객이 기능을 테스트하고 피드백을 제공할 수 있습니다.
Red Hat 기술 프리뷰 기능의 지원 범위에 대한 자세한 내용은 기술 프리뷰 기능 지원 범위를 참조하십시오.
기본적으로 Argo CD 애플리케이션 컨트롤러는 비균일 레거시
해시 기반 샤딩 알고리즘을 사용하여 클러스터를 shard에 할당합니다. 이로 인해 클러스터 배포가 해제될 수 있습니다. 라운드 로빈
샤딩 알고리즘을 활성화하여 모든 shard에서 동일한 클러스터 배포를 수행할 수 있습니다.
Red Hat OpenShift GitOps에서 라운드 로빈
샤딩 알고리즘을 사용하면 다음과 같은 이점이 있습니다.
- 보다 균형 있는 워크로드 분배를 보장합니다.
- shard가 과부하되거나 활용도가 낮은 것을 방지
- 컴퓨팅 리소스의 효율성 최적화
- 병목 현상의 위험 감소
- Argo CD 시스템의 전반적인 성능 및 안정성 개선
대체 샤딩 알고리즘을 도입하면 특정 사용 사례에 따라 추가 사용자 정의가 가능합니다. 배포 요구 사항에 가장 적합한 알고리즘을 선택할 수 있으므로 다양한 운영 시나리오에서 유연성 및 조정 가능성이 향상됩니다.
GitOps의 대체 샤딩 알고리즘의 이점을 활용하려면 배포 중에 샤딩을 활성화하는 것이 중요합니다.
4.1.1. 웹 콘솔에서 라운드 로빈 분할 알고리즘 활성화
OpenShift Container Platform 웹 콘솔을 사용하여 라운드 로빈
분할 알고리즘을 활성화할 수 있습니다.
사전 요구 사항
- OpenShift Container Platform 클러스터에 Red Hat OpenShift GitOps Operator를 설치했습니다.
- OpenShift Container Platform 웹 콘솔에 액세스할 수 있습니다.
-
cluster-admin
권한이 있는 클러스터에 액세스할 수 있습니다.
프로세스
-
웹 콘솔의 관리자 화면에서 Operator
설치된 Operator 로 이동합니다. - 설치된 Operator에서 Red Hat OpenShift GitOps 를 클릭하고 Argo CD 탭으로 이동합니다.
-
라운드 로빈
샤딩 알고리즘을 활성화하려는 Argo CD 인스턴스를 클릭합니다(예:openshift-gitops
). YAML 탭을 클릭하고 다음 예와 같이 YAML 파일을 편집합니다.
라운드 로빈 분할 알고리즘이 활성화된 Argo CD 인스턴스의 예
apiVersion: argoproj.io/v1beta1 kind: ArgoCD metadata: name: openshift-gitops namespace: openshift-gitops spec: controller: sharding: enabled: true 1 replicas: 3 2 env: 3 - name: ARGOCD_CONTROLLER_SHARDING_ALGORITHM value: round-robin logLevel: debug 4
저장을 클릭합니다.
성공 알림 경고
openshift-gitops가 <version> 버전으로 업데이트되었습니다
.참고기본
openshift-gitops
인스턴스를 편집하면 Managed 리소스 대화 상자가 표시됩니다. 저장을 다시 클릭하여 변경 사항을 확인합니다.다음 단계를 수행하여 shard링 알고리즘으로
라운드 로빈
을 사용하여 shard링이 활성화되었는지 확인합니다.-
워크로드
StatefulSets 로 이동합니다. - 프로젝트 드롭다운 목록에서 Argo CD 인스턴스를 설치한 네임스페이스를 선택합니다.
- < instance_name>-application-controller (예: openshift-gitops-application-controller )를 클릭하고 Pod 탭으로 이동합니다.
- 생성된 애플리케이션 컨트롤러 Pod 수를 확인합니다. 세트 복제본 수에 해당해야 합니다.
검사할 컨트롤러 Pod를 클릭하고 로그 탭으로 이동하여 Pod 로그를 확인합니다.
컨트롤러 Pod 로그 조각의 예
time="2023-12-13T09:05:34Z" level=info msg="ArgoCD Application Controller is starting" built="2023-12-01T19:21:49Z" commit=a3vd5c3df52943a6fff6c0rg181fth3248976299 namespace=openshift-gitops version=v2.9.2+c5ea5c4 time="2023-12-13T09:05:34Z" level=info msg="Processing clusters from shard 1" time="2023-12-13T09:05:34Z" level=info msg="Using filter function: round-robin" 1 time="2023-12-13T09:05:34Z" level=info msg="Using filter function: round-robin" time="2023-12-13T09:05:34Z" level=info msg="appResyncPeriod=3m0s, appHardResyncPeriod=0s"
- 1
" filter function: round-robin"
메시지를 찾습니다.
로그 검색 필드에서
shard로 처리된
프로세스를 검색하여 다음 예와 같이 shard 간 클러스터 배포가 짝인지 확인합니다.중요이러한 로그를 관찰하도록
디버그
하도록 로그 수준을 설정해야 합니다.컨트롤러 Pod 로그 조각의 예
time="2023-12-13T09:05:34Z" level=debug msg="ClustersList has 3 items" time="2023-12-13T09:05:34Z" level=debug msg="Adding cluster with id= and name=in-cluster to cluster's map" time="2023-12-13T09:05:34Z" level=debug msg="Adding cluster with id=068d8b26-6rhi-4w23-jrf6-wjjfyw833n23 and name=in-cluster2 to cluster's map" time="2023-12-13T09:05:34Z" level=debug msg="Adding cluster with id=836d8b53-96k4-f68r-8wq0-sh72j22kl90w and name=in-cluster3 to cluster's map" time="2023-12-13T09:05:34Z" level=debug msg="Cluster with id= will be processed by shard 0" 1 time="2023-12-13T09:05:34Z" level=debug msg="Cluster with id=068d8b26-6rhi-4w23-jrf6-wjjfyw833n23 will be processed by shard 1" 2 time="2023-12-13T09:05:34Z" level=debug msg="Cluster with id=836d8b53-96k4-f68r-8wq0-sh72j22kl90w will be processed by shard 2" 3
참고"C" 클러스터 수가 shard 복제본 "R"의 배수인 경우 각 shard에 할당된 클러스터 "N"이 동일한 "C"가 "R"으로 나누어야 합니다. 이전 예제에서는 3개의 클러스터와 3개의 복제본을 표시하므로 각 shard에는 클러스터가 1개씩 할당됩니다.
-
워크로드
4.1.2. CLI를 사용하여 라운드 로빈 분할 알고리즘 활성화
명령줄 인터페이스를 사용하여 라운드 로빈
샤딩 알고리즘을 활성화할 수 있습니다.
사전 요구 사항
- OpenShift Container Platform 클러스터에 Red Hat OpenShift GitOps Operator를 설치했습니다.
-
cluster-admin
권한이 있는 클러스터에 액세스할 수 있습니다.
프로세스
다음 명령을 실행하여 분할을 활성화하고 원하는 값으로 복제본 수를 설정합니다.
$ oc patch argocd <argocd_instance> -n <namespace> --patch='{"spec":{"controller":{"sharding":{"enabled":true,"replicas":<value>}}}}' --type=merge
출력 예
argocd.argoproj.io/<argocd_instance> patched
다음 명령을 실행하여
라운드 로빈
으로 분할 알고리즘을 구성합니다.$ oc patch argocd <argocd_instance> -n <namespace> --patch='{"spec":{"controller":{"env":[{"name":"ARGOCD_CONTROLLER_SHARDING_ALGORITHM","value":"round-robin"}]}}}' --type=merge
출력 예
argocd.argoproj.io/<argocd_instance> patched
다음 명령을 실행하여 Argo CD Application Controller Pod의 수가 세트 복제본 수에 해당하는지 확인합니다.
$ oc get pods -l app.kubernetes.io/name=<argocd_instance>-application-controller -n <namespace>
출력 예
NAME READY STATUS RESTARTS AGE <argocd_instance>-application-controller-0 1/1 Running 0 11s <argocd_instance>-application-controller-1 1/1 Running 0 32s <argocd_instance>-application-controller-2 1/1 Running 0 22s
다음 명령을 실행하여 분할 알고리즘으로
라운드 로빈
알고리즘을 사용하여 샤딩이 활성화되었는지 확인합니다.$ oc logs <argocd_application_controller_pod> -n <namespace>
출력 조각의 예
time="2023-12-13T09:05:34Z" level=info msg="ArgoCD Application Controller is starting" built="2023-12-01T19:21:49Z" commit=a3vd5c3df52943a6fff6c0rg181fth3248976299 namespace=<namespace> version=v2.9.2+c5ea5c4 time="2023-12-13T09:05:34Z" level=info msg="Processing clusters from shard 1" time="2023-12-13T09:05:34Z" level=info msg="Using filter function: round-robin" 1 time="2023-12-13T09:05:34Z" level=info msg="Using filter function: round-robin" time="2023-12-13T09:05:34Z" level=info msg="appResyncPeriod=3m0s, appHardResyncPeriod=0s"
- 1
" filter function: round-robin"
메시지를 찾습니다.
다음 단계를 수행하여 shard 간 클러스터 배포가 있는지 확인합니다.
다음 명령을 실행하여 로그 수준을
debug
로 설정합니다.$ oc patch argocd <argocd_instance> -n <namespace> --patch='{"spec":{"controller":{"logLevel":"debug"}}}' --type=merge
출력 예
argocd.argoproj.io/<argocd_instance> patched
로그를 보고
shard에서 처리된
를 검색하여 다음 명령을 실행하여 각 클러스터가 연결된 shard를 관찰합니다.$ oc logs <argocd_application_controller_pod> -n <namespace> | grep "processed by shard"
출력 조각의 예
time="2023-12-13T09:05:34Z" level=debug msg="Cluster with id= will be processed by shard 0" 1 time="2023-12-13T09:05:34Z" level=debug msg="Cluster with id=068d8b26-6rhi-4w23-jrf6-wjjfyw833n23 will be processed by shard 1" 2 time="2023-12-13T09:05:34Z" level=debug msg="Cluster with id=836d8b53-96k4-f68r-8wq0-sh72j22kl90w will be processed by shard 2" 3
참고"C" 클러스터 수가 shard 복제본 "R"의 배수인 경우 각 shard에 할당된 클러스터 "N"이 동일한 "C"가 "R"으로 나누어야 합니다. 이전 예제에서는 3개의 클러스터와 3개의 복제본을 표시하므로 각 shard에는 클러스터가 1개씩 할당됩니다.