X.509 인증서를 사용하여 다중 Kubernetes 클러스터 MongoDB 배포에서 클라이언트 애플리케이션을 인증하도록 Kubernetes Operator를 구성할 수 있습니다.
To secure your multi-Kubernetes cluster MongoDB deployment with X.509 certificates, you run all actions on the operator cluster. The Kubernetes Operator propagates the X.509 configuration to each member cluster and updates the Kubernetes Operator configuration on each member cluster.
전제 조건
TLS 암호화를 사용하여 다중 Kubernetes cluster MongoDB 배포를 보호하기 전에 다음 작업을 완료하세요.
Kubernetes Operator에 대한 Kubernetes Operator 자격 증명을 생성합니다 .
프로젝트 수준에서 X.509 인증을 활성화하면 모든 에이전트가 MongoDB 배포서버와 통신할 때 X.509 클라이언트 인증을 사용하도록 구성됩니다.
X.509 클라이언트 인증에는 다음 중 하나가 필요합니다.
MongoDBMultiCluster 리소스에 대해 X.509 인증 활성화
리소스 를 업데이트하여 X 인증 을 활성화 합니다.MongoDBMultiCluster
509
Kubernetes 연산자MongoDBMultiCluster 리소스 사양 의 보안 설정으로 MongoDBMultiCluster 사용자 지정 리소스를 업데이트합니다. 결과 구성은 다음 예시와 유사할 수 있습니다.
apiVersion: mongodb.com/v1 kind: MongoDBMultiCluster metadata: name: multi-replica-set spec: version: 6.0.0-ent type: ReplicaSet persistent: false duplicateServiceObjects: true credentials: my-credentials opsManager: configMapRef: name: my-project security: tls: ca: custom-ca certsSecretPrefix: <prefix> authentication: enabled: true modes: ["X509"] agents: mode: "X509" clusterSpecList: - clusterName: ${MDB_CLUSTER_1_FULL_NAME} members: 3 - clusterName: ${MDB_CLUSTER_2_FULL_NAME} members: 2 - clusterName: ${MDB_CLUSTER_3_FULL_NAME} members: 3 The |k8s-op-short| copies the ConfigMap with the |certauth| created in the operator cluster to each member cluster, generates a concatenated |pem| secret, and distributes it to the member clusters.
리소스가 실행 MongoDBMultiCluster
확인합니다.
멤버 cluster의 경우 다음 명령을 실행하여 MongoDB 파드가 실행 중 상태인지 확인합니다.
kubectl get pods \ --context=$MDB_CLUSTER_1_FULL_NAME \ --namespace mongodb kubectl get pods \ --context=$MDB_CLUSTER_2_FULL_NAME \ --namespace mongodb kubectl get pods \ --context=$MDB_CLUSTER_3_FULL_NAME \ --namespace mongodb 연산자 클러스터 에서 다음 명령을 실행
MongoDBMultiCluster
리소스 실행 상태 인지 확인합니다.kubectl --context=$MDB_CENTRAL_CLUSTER_FULL_NAME \ --namespace mongodb \ get mdbmc multi-replica-set -o yaml -w
MongoDBMultiCluster 리소스에 대한 X.509 인증서 갱신
이미 X.509 인증서를 생성한 경우 다음 절차에 따라 주기적으로 인증서를 갱신합니다.
MongoDBMultiCluster
리소스에 대한 시크릿 을 갱신합니다.
이 kubectl
명령을 실행하여 MongoDBMultiCluster
리소스 에 대한 인증서를 저장하는 기존 시크릿을 갱신합니다.
kubectl --context $MDB_CENTRAL_CLUSTER_FULL_NAME \ --namespace=<metadata.namespace> \ create secret tls <prefix>-<metadata.name>-cert \ --cert=<resource-tls-cert> \ --key=<resource-tls-key> \ --dry-run=client \ -o yaml | kubectl apply -f -
에이전트의 X.509 인증서에 대한 시크릿을 갱신합니다.
kubectl
명령을 실행하여 MongoDBMultiCluster
리소스 에이전트 인증서를 저장하는 기존 시크릿을 갱신합니다.
kubectl --context $MDB_CENTRAL_CLUSTER_FULL_NAME \ --namespace=<metadata.namespace> \ create secret tls <prefix>-<metadata.name>-agent-certs \ --cert=<agent-tls-cert> \ --key=<agent-tls-key> \ --dry-run=client \ -o yaml | kubectl apply -f -