AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

X.509 클라이언트 인증서 생성

The MongoDB Controllers for Kubernetes Operator can deploy MongoDB instances with X.509 authentication enabled. If X.509 authentication has been enabled for the deployment, you must generate and use an X.509 certificate to connect to the deployment. This new client certificate must be signed by the same CA that signs the server certificates for the MongoDB deployment to accept it.

이 문서에 설명된 절차에 따라 X.509 인증서를 사용하여 X.509 지원 MongoDB 배포에 연결합니다.

HashiCorp Vault 를 사용하는 경우 대신 볼트 시크릿을 생성 할 수 있습니다.

참고

Ops Manager 배포에 대한 인증서 갱신을 자동화하려면 인증서-관리자 통합을 설정하는 것이 좋습니다.

참고

A full description of Transport Layer Security (TLS), Public Key Infrastructure (PKI) certificates, and Certificate Authorities is beyond the scope of this document. This page assumes prior knowledge of TLS and X.509 authentication.

먼저 클라이언트 인증서를 만듭니다. 그런 다음 MongoDB 사용자를 생성하고 X.509 지원 배포서버에 연결합니다.

1

프로덕션용의 경우 MongoDB deployment에서 생성하고 서명한 유효한 인증서를 CA 사용해야 합니다. 귀하 또는 귀하의 조직 cert-manager와같은 Kubernetes 네이티브 도구를 사용하여 독립적인 CA를 생성하고 유지 관리할 수 있습니다.

인증서를 얻고 관리하는 것은 이 문서의 범위를 벗어납니다.

중요

You must concatenate your client's TLS certificate and the certificate's key in a .pem file. You must present this .pem file when you connect to your X.509-enabled MongoDB deployment.

클라이언트 인증서에 반드시 있어야 하는 속성에 학습 보려면 MongoDB 매뉴얼의 클라이언트 인증서 요구 사항 을 참조하세요.

2

아직 실행하지 않았다면 다음 명령을 실행하여 생성한 네임스페이스에서 kubectl 명령을 모두 실행합니다.

참고

다중 Kubernetes 클러스터 MongoDB deployment에서 MongoDB Ops Manager 리소스를 배포하는 경우:

  • context 를 연산자 클러스터 의 이름으로 설정합니다(예: kubectl config set context "$MDB_CENTRAL_CLUSTER_FULL_NAME").

  • --namespace 를 다중 Kubernetes 클러스터 MongoDB 배포에 사용한 것과 동일한 범위 (예: kubectl config --namespace "mongodb" 로 설정합니다.

kubectl config set-context $(kubectl config current-context) --namespace=<metadata.namespace>
3

다음 ConfigMap을 x509-mongodb-user.yaml 으로 저장합니다.

1---
2apiVersion: mongodb.com/v1
3kind: MongoDBUser
4metadata:
5 name: new-x509-user
6spec:
7 username: "CN=my-x509-authenticated-user,OU=organizationalunit,O=organization"
8 db: "$external"
9 mongodbResourceRef:
10 name: '<name of the MongoDB resource>'
11 roles:
12 - db: "admin"
13 name: "readWriteAnyDatabase"

이 ConfigMap .yaml 파일은 MongoDBUser 사용자 지정 객체를 설명합니다. 이러한 사용자 지정 객체를 사용하여 MongoDB 사용자를 만들 수 있습니다. 자세한 내용은 MongoDB 사용자 리소스 사양을 참조하세요.

이 예에서 ConfigMap은 사용자를 클라이언트가 해당 X.509 인증서로 MongoDB에 연결하는 데 사용할 수 있는 X.509 사용자로 설명합니다.

4

다음 명령을 실행하여 ConfigMap을 적용하고 X.509 MongoDB 사용자를 생성합니다.

kubectl apply -f x509-mongodb-user.yaml

다음과 유사한 출력이 표시됩니다.

mongodbuser.mongodb.com/new-x509-user created
5

다음 명령을 실행하여 new-x509-user 의 상태를 확인합니다.

kubectl get mdbu/new-x509-user -o yaml

다음과 유사한 출력이 표시됩니다.

NAME CREATED AT
new-x509-user 8m
6

다음 명령을 실행하여 각 포드에서 Kubernetes 연산자가 CA 시크릿을 마운트한 위치를 찾습니다.

kubectl get statefulset <metadata.name> -o yaml

출력에서 secret-ca 마운트를 찾습니다.

volumeMounts:
- mountPath: /opt/scripts
name: database-scripts
readOnly: true
- mountPath: /var/lib/mongodb-automation/secrets/ca
name: secret-ca
readOnly: true
- mountPath: /var/lib/mongodb-automation/secrets/certs
name: secret-certs
readOnly: true

데이터베이스 배포에 연결할 때 다음 단계에서 mountPathsecret-ca 을 추가하여 전체 경로를 형성합니다.

/var/lib/mongodb-automation/secrets/ca/secret-ca
7

X.509 사용자를 생성한 후에는 MongoDB Shell(mongosh)을 사용하여 배포서버에 연결을 시도합니다.

mongosh --host {host} --port {port} --tls \
--tlsCAFile </path/to/secret-ca> \
--tlsCertificateKeyFile <your-cert>.pem \
--authenticationMechanism MONGODB-X509 \
--authenticationDatabase '$external'
mongosh --host {host} --port {port} --ssl \
--sslCAFile </path/to/secret-ca> \
--sslPEMKeyFile <your-cert>.pem \
--authenticationMechanism MONGODB-X509 \
--authenticationDatabase '$external'