경우에 따라 저장소의 Anthos Config Management의 구성이 동기화되는 것을 빠르게 중지해야 할 수 있습니다. 이러한 시나리오 중 하나는 구문은 유효하지만 잘못된 구성이 저장소에 커밋되고, 구성이 삭제되거나 수정되는 동안 실행 중인 클러스터에 미치는 영향을 제한하려는 경우입니다.
이 주제는 단일 저장소용이며 빠르게 동기화를 중지하는 방법과 문제가 해결되었을 때 동기화를 재개하는 방법을 보여줍니다. 여러 저장소의 동기화를 중지하는 방법은 여러 저장소에서 동기화를 참조하세요.
기본 요건
이 주제에서 설명한 명령어를 실행하는 사용자는 동기화를 중지하려는 모든 클러스터의 kube-system
및 config-management-system
네임스페이스에 다음 Kubernetes RBAC 권한이 필요합니다.
- apiGroups: ["extensions"]
resources: ["deployments", "deployments/scale"]
verbs: ["get", "update"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["list", "watch"]
동기화 중지
동기화를 중지하려면 사용자의 편의를 위해 단일 명령어로 제공되지만 별도로 실행할 수 있는 다음 명령어를 실행합니다.
kubectl -n kube-system scale deployment config-management-operator --replicas=0 \ && kubectl wait -n kube-system --for=delete pods -l k8s-app=config-management-operator \ && kubectl -n config-management-system scale deployment syncer --replicas=0 \ && kubectl wait -n config-management-system --for=delete pods -l app=syncer \ && kubectl -n config-management-system scale deployment git-importer --replicas=0 \ && kubectl wait -n config-management-system --for=delete pods -l app=git-importer
명령어는 다음을 순서대로 수행합니다. 명령어가 실패하면 나머지 명령어는 실행되지 않습니다.
- Config Management Operator 배포의
replicas
수를 0으로 줄입니다. - syncer 배포의
replicas
수를 0으로 줄입니다. - git-importer 배포의
replicas
수를 0으로 줄입니다.
모든 배포는 클러스터에 계속 유지되지만 Operator, git-importer 또는 syncer의 복제본이 없으므로 저장소에서 구성이 동기화되지 않습니다.
등록된 모든 클러스터에서 동기화 중지
단일 클러스터가 아닌 단일 Google Cloud 프로젝트의 등록된 모든 클러스터에서 한 번에 동기화를 중지해야 하는 경우 nomos status
명령어를 사용하여 등록된 모든 클러스터의 목록을 가져오는 스크립트를 만들 수 있습니다. 그러면 스크립트는 gcloud container clusters get-credentials
명령어를 사용하여 각 클러스터에 kubectl
컨텍스트를 만들고 각 컨텍스트에 위의 명령어를 실행합니다. 다음은 이러한 스크립트의 간단한 예시입니다.
#!/bin/bash
nomos status |grep SYNCED | awk {'print $1'} |while read i; do
gcloud container clusters get-credentials "$i"
kubectl -n kube-system scale deployment config-management-operator --replicas=0 \
&& kubectl wait -n kube-system --for=delete pods -l k8s-app=config-management-operator \
&& kubectl -n config-management-system scale deployment syncer --replicas=0 \
&& kubectl wait -n config-management-system --for=delete pods -l app=syncer \
&& kubectl -n config-management-system scale deployment git-importer --replicas=0 \
&& kubectl wait -n config-management-system --for=delete pods -l app=git-importer
done
동기화 재개
동기화를 재개하려면 다음 명령어를 실행합니다.
kubectl -n kube-system scale deployment config-management-operator --replicas=1
이 명령어는 Operator 배포를 복제본 1개로 확장합니다. 그러면 Operator는 syncer 및 git-importer 배포가 잘못 확장되었음을 인식하고 복제본 1개로 확장합니다.
등록된 모든 클러스터에서 동기화 재개
단일 클러스터가 아닌 Google Cloud 프로젝트에 등록된 모든 클러스터에서 한 번에 동기화를 재개해야 하는 경우 nomos status
를 사용하여 등록된 모든 클러스터 목록을 가져오는 스크립트를 만들 수 있습니다. 그러면 스크립트는 gcloud container clusters get-credentials
명령어를 사용하여 각 클러스터에 kubectl
컨텍스트를 만들고 각 컨텍스트에 위의 명령어를 실행합니다. 다음은 이러한 스크립트의 간단한 예시입니다.
#!/bin/bash
nomos status |grep SYNCED | awk {'print $1'} |while read i; do
gcloud container clusters get-credentials "$i"
kubectl -n kube-system scale deployment config-management-operator --replicas=1
done