데이터베이스가 Kubernetes 클러스터에서 실행되는 경우 컨테이너화된 애플리케이션에서 실행되는 활성 프로브와 시작 프로브를 중지하여 데이터베이스를 유지보수 모드로 전환해 데이터베이스 포드가 정상 상태인지 확인할 수 있습니다. 유지보수 모드를 사용하면 유지보수 업데이트를 실행하거나 포드를 복구해야 할 때 포드를 실행 상태로 설정할 수 있습니다.
유지보수 모드 사용 설정
데이터베이스 포드에 프로브가 있는지 확인합니다.
활성 프로브:
kubectl get po -n NAMESPACE DATABASE_POD_NAME -o jsonpath='{.spec.containers[?(@.name=="database")].livenessProbe}'다음을 바꿉니다.
NAMESPACE: 데이터베이스를 실행하는 데 사용되는 네임스페이스의 이름입니다(예:db).DATABASE_POD_NAME: 데이터베이스 포드의 이름입니다(예:al-4017-dbcluster-sample-0).
다음은 활성 프로브가 있는 샘플 출력을 보여줍니다.
{"failureThreshold":3,"httpGet":{"path":"/healthz?","port":8090,"scheme":"HTTP"},"periodSeconds":10,"successThreshold":1,"timeoutSeconds":3}시작 프로브:
kubectl get po -n NAMESPACE DATABASE_POD_NAME -o jsonpath='{.spec.containers[?(@.name=="database")].startupProbe}'다음은 시작 프로브가 있는 샘플 출력을 보여줍니다.
{"exec":{"command":["/usr/lib/postgresql/15/bin/psql","-hlocalhost","-Ualloydbadmin","-c","SELECT 1"]},"failureThreshold":180,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":1}
DBCluster 매니페스트의
spec섹션에서mode를maintenance로 설정합니다.apiVersion: alloydbomni.dbadmin.goog/v1 kind: DBCluster metadata: name: DB_CLUSTER_NAME namespace: NAMESPACE spec: allowExternalIncomingTraffic: false isDeleted: false mode: maintenance primarySpec: ...DB_CLUSTER_NAME을 이 데이터베이스 클러스터의 이름으로 바꿉니다(예:my-db-cluster).매니페스트를 적용합니다.
kubectl apply -f DB_CLUSTER_YAMLDB_CLUSTER_YAML을 이 데이터베이스 클러스터 매니페스트 파일의 이름으로 바꿉니다(예:alloydb-omni-db-cluster.yaml).유지보수 모드가 사용 설정되었는지 확인하려면 다음 명령어를 실행합니다.
활성 프로브:
kubectl get po -n NAMESPACE DATABASE_POD_NAME -o jsonpath='{.spec.containers[?(@.name=="database")].livenessProbe}'시작 프로브:
kubectl get po -n NAMESPACE DATABASE_POD_NAME -o jsonpath='{.spec.containers[?(@.name=="database")].startupProbe}'
출력에서
POD_NAME포드의spec섹션에Liveness및Startup필드가 포함되지 않습니다.
유지보수 모드 사용 중지
실행 중인 활성 및 시작 프로브가 있는 표준 데이터베이스 클러스터 동작으로 돌아가려면 다음 명령어를 사용하여 DBCluster 매니페스트의 spec 섹션에서 maintenance를 삭제합니다.
kubectl patch dbclusters.alloydbomni.dbadmin.goog DB_CLUSTER_NAME -p '{"spec":{"mode":""}}' --type=merge -n DB_CLUSTER_NAMESPACE --type=merge샘플 출력:
활성 프로브를 사용하는 경우:
{"failureThreshold":3,"httpGet":{"path":"/healthz?","port":8090,"scheme":"HTTP"},"periodSeconds":10,"successThreshold":1,"timeoutSeconds":3}시작 프로브를 사용하는 경우:
{"exec":{"command":["/usr/lib/postgresql/15/bin/psql","-hlocalhost","-Ualloydbadmin","-c","SELECT 1"]},"failureThreshold":180, "periodSeconds":10,"successThreshold":1,"timeoutSeconds":1}