Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/
Kubernetes Operator용 MongoDB 컨트롤러
/ /

LDAP를 사용한 보안 클라이언트 인증

MongoDB Enterprise 는 다음을 지원합니다.

  • 인증 요청을 LDAP(Lightweight Directory Access Protocol) 서비스로 프록시합니다.

  • LDAP 서버에 대한 단순 및 SASL 바인딩. MongoDB Enterprise는 saslauthd 또는 운영 체제 라이브러리를 통해 LDAP 서버에 바인딩할 수 있습니다.

자세한 내용은 MongoDB Server 설명서의 LDAP 프록시 인증LDAP 권한 부여 섹션을 참조하세요.

Kubernetes 연산자를 사용하여 MongoDB 배포에 연결하는 클라이언트 애플리케이션을 인증하도록 LDAP를 구성할 수 있습니다. 이 가이드에서는 클라이언트 애플리케이션에서 MongoDB 배포로 LDAP 인증을 구성하는 방법을 설명합니다.

참고

Kubernetes cluster에서 MongoDB의 독립형 인스턴스를 보호할 수 없습니다.

  • CustomResourceDefinitions 에서 LDAP 를구성하려면 ,Kubernetes Operator MongoDB 리소스 사양의spec.security.authentication.ldap 및 MongoDB Agent 와 관련된 기타 보안 LDAP 설정 의 매개 변수를 사용합니다. 이 섹션의 절차에서는 필요한 설정을 설명하고 LDAP 구성의 예를 제공합니다.

  • 보안을 강화하려면 TLS로 암호화된 복제본 세트 또는 TLS로 암호화된 샤딩된 클러스터 배포하는 것이 좋습니다. TLS 를 사용한 암호화는 선택 사항입니다. 기본값으로 LDAP 트래픽은 일반 텍스트로 전송됩니다. 이는 사용자 이름 과 비밀번호가 네트워크 위협에 노출되었음을 의미합니다. Microsoft Active Directory와 같은 많은 최신 디렉토리 서비스에는 암호화됨 연결이 필요합니다. Kubernetes Operator MongoDB 배포에서 인증 요청을 암호화하려면TLS/SSL을 통한 LDAP 사용하는 것이 좋습니다.

MongoDB deployment에 대한 LDAP 인증을 구성하기 전에 다음 작업을 완료하세요.

  • MongoDB Enterprise 데이터베이스 리소스를 배포해야 합니다. MongoDB Community 데이터베이스는 LDAP 인증을 지원하지 않습니다.

  • 복제본 세트 를 배포하거나 LDAP 로 보호하려는 클라이언트 인증이 속한 cluster 를 배포합니다.

1

원하는 복제본 세트 구성과 일치하도록 이 YAML파일의 설정을 변경합니다.

1---
2apiVersion: mongodb.com/v1
3kind: MongoDB
4metadata:
5 name: <my-replica-set>
6spec:
7 members: 3
8 version: "8.0.0"
9 opsManager:
10 configMapRef:
11 # Must match metadata.name in ConfigMap file
12 name: <configMap.metadata.name>
13 credentials: <mycredentials>
14 type: ReplicaSet
15 persistent: true
16 security:
17 tls:
18 ca: <custom-ca>
19 certsSecretPrefix: <prefix>
20...
2

원하는 텍스트 편집기를 열고 객체spec 붙여넣습니다. 섹션의 리소스 파일 끝에 있습니다.

3

배포에서 LDAP 를 활성화하려면 Kubernetes 객체에서 다음 설정을 구성합니다.

유형 및 필요성
설명
예시
boolean,
required

LDAP 인증을 사용하려면 true 로 설정합니다.

true

string,
required

LDAP 서버에 연결할 때 MongoDB가 바인딩할 LDAP 고유 이름을 지정합니다.

cn=admin,dc=example,dc=org

string,
required

시크릿 이름 지정 여기에는 LDAP 서버에 연결할 때 MongoDB가 바인딩하는 LDAP 바인딩 고유 이름의 비밀번호가 포함되어 있습니다.

<secret-name>

string,
optional

ConfigMap 추가 배포의 TLS 인증서에 서명하는 데 사용한 사용자 지정 CA 를 저장하는 의 이름입니다.

<configmap-name>

string,
optional

LDAP 서버의 TLS 인증서의 유효성을 검사하는 CA 를 저장하는 필드 이름을 추가합니다.

<configmap-key>

array of strings,
required

하나 이상의 LDAP 서버의 hostname:port 조합 목록을 지정합니다. 각 서버에 대해 별도의 줄을 사용합니다.

<example.com:636>

string,
optional

LDAPS( TLS 를 통한 LDAP )를 사용하려면 tls 로 설정합니다. LDAP 서버가 TLS를 허용하지 않는 경우 비워 둡니다. 이 설정을 사용하려면 데이터베이스 리소스를 배포할 때 TLS를 사용하도록 설정해야 합니다.

tls

string,
required

인증을 위해 mongod 또는 mongos 에 제공된 사용자 이름을 LDAP DN(고유 이름)에 매핑하는 매핑을 지정합니다.

자세히 알아보려면 security.ldap.userToDNMapping 을 참조하세요. 및 LDAP 쿼리 템플릿 은 MongoDB Server 문서에서 확인할 수 있습니다.

<match: "(.+)",substitution: "uid={0},ou=groups,dc=example,dc=org">

string,
required

LDAP를 통해 인증을 사용하려면 LDAP 로 설정합니다.

LDAP

결과 구성은 다음 예시와 유사할 수 있습니다.

security:
authentication:
enabled: true
# Enabled LDAP Authentication Mode
modes:
- "LDAP"
- "SCRAM"
# LDAP related configuration
ldap:
# Specify the hostname:port combination of one or
# more LDAP servers
servers:
- "ldap1.example.com:636"
- "ldap2.example.com:636"
# Set to "tls" to use LDAP over TLS. Leave blank if
# the LDAP server doesn't accept TLS. You must enable TLS when you deploy the database resource to use this setting.
transportSecurity: "tls"
# If TLS is enabled, add a reference to a ConfigMap that
# contains a CA certificate that validates the LDAP server's
# TLS certificate.
caConfigMapRef:
name: "<configmap-name>"
key: "<configmap-entry-key>"
# Specify the LDAP Distinguished Name to which
# MongoDB binds when connecting to the LDAP server
bindQueryUser: "cn=admin,dc=example,dc=org"
# Specify the password with which MongoDB binds
# when connecting to an LDAP server. This is a
# reference to a Secret Kubernetes Object containing
# one "password" key.
bindQueryPasswordSecretRef:
name: "<secret-name>"

LDAP 설정의 전체 목록은 Kubernetes 연산자 MongoDB 리소스 사양의 보안 설정 을 참조하세요. LDAP 지원 Kubernetes 연산자 배포에서 MongoDB 에이전트 사용자에 대한 spec.security.authentication.agents.automationUserName 설정도 참조하세요.

4

Kubernetes 연산자 MongoDB 리소스 사양에서 Agent 관련 보안 설정 으로 MongoDB 리소스를 업데이트합니다 . 결과 구성은 다음 예시와 유사할 수 있습니다.

security:
authentication:
agents:
automationPasswordSecretRef:
key: automationConfigPassword
name: automation-config-password
automationUserName: mms-automation-agent
clientCertificateSecretRef:
name: agent-client-cert
mode: LDAP
enabled: true
ldap:
bindQueryPasswordSecretRef:
name: bind-query-password
bindQueryUser: cn=admin,dc=example,dc=org
servers:
- openldap.namespace.svc.cluster.local:389
userToDNMapping: '[{match: "(.+)",substitution: "uid={0},ou=groups,dc=example,dc=org"}]'
modes:
- LDAP
- SCRAM
requireClientTLSAuthentication: false
5
6

다음 Kubernetes 명령을 호출하여 복제본 세트를 업데이트합니다.

kubectl apply -f <replica-set-conf>.yaml
7

MongoDB 리소스의 상태를 확인하려면 다음 명령어를 사용하세요.

kubectl get mdb <resource-name> -o yaml -w

-w(watch) 플래그 설정이 적용된 경우, 구성이 변경되면 상태 단계가 Running 상태를 달성할 때까지 출력이 즉시 새로 고침 됩니다. 리소스 배포 상태에 대해 자세히 알아보려면 Kubernetes Operator 문제 해결을 참조하세요.

1

원하는 샤드 클러스터구성과 일치하도록 이 YAML 파일의 설정을 변경합니다.

1---
2apiVersion: mongodb.com/v1
3kind: MongoDB
4metadata:
5 name: <my-sharded-cluster>
6spec:
7 shardCount: 2
8 mongodsPerShardCount: 3
9 mongosCount: 2
10 configServerCount: 3
11 version: "8.0.0"
12 opsManager:
13 configMapRef:
14 name: <configMap.metadata.name>
15 # Must match metadata.name in ConfigMap file
16 credentials: <mycredentials>
17 type: ShardedCluster
18 persistent: true
19 security:
20 tls:
21 ca: <custom-ca>
22 certsSecretPrefix: <prefix>
23...
2

원하는 텍스트 편집기를 열고 객체spec 붙여넣습니다. 섹션의 리소스 파일 끝에 있습니다.

3

배포에서 LDAP 를 활성화하려면 Kubernetes 객체에서 다음 설정을 구성합니다.

유형 및 필요성
설명
예시
boolean,
required

LDAP 인증을 사용하려면 true 로 설정합니다.

true

string,
required

LDAP 서버에 연결할 때 MongoDB가 바인딩할 LDAP 고유 이름을 지정합니다.

cn=admin,dc=example,dc=org

string,
required

시크릿 이름 지정 여기에는 LDAP 서버에 연결할 때 MongoDB가 바인딩하는 LDAP 바인딩 고유 이름의 비밀번호가 포함되어 있습니다.

<secret-name>

string,
optional

ConfigMap 추가 배포의 TLS 인증서에 서명하는 데 사용한 사용자 지정 CA 를 저장하는 의 이름입니다.

<configmap-name>

string,
optional

LDAP 서버의 TLS 인증서의 유효성을 검사하는 CA 를 저장하는 필드 이름을 추가합니다.

<configmap-key>

array of strings,
required

하나 이상의 LDAP 서버의 hostname:port 조합 목록을 지정합니다. 각 서버에 대해 별도의 줄을 사용합니다.

<example.com:636>

string,
optional

LDAPS( TLS 를 통한 LDAP )를 사용하려면 tls 로 설정합니다. LDAP 서버가 TLS를 허용하지 않는 경우 비워 둡니다. 이 설정을 사용하려면 데이터베이스 리소스를 배포할 때 TLS를 사용하도록 설정해야 합니다.

tls

string,
required

인증을 위해 mongod 또는 mongos 에 제공된 사용자 이름을 LDAP DN(고유 이름)에 매핑하는 매핑을 지정합니다.

자세히 알아보려면 security.ldap.userToDNMapping 을 참조하세요. 및 LDAP 쿼리 템플릿 은 MongoDB Server 문서에서 확인할 수 있습니다.

<match: "(.+)",substitution: "uid={0},ou=groups,dc=example,dc=org">

string,
required

LDAP를 통해 인증을 사용하려면 LDAP 로 설정합니다.

LDAP

결과 구성은 다음 예시와 유사할 수 있습니다.

security:
authentication:
enabled: true
# Enabled LDAP Authentication Mode
modes:
- "LDAP"
- "SCRAM"
# LDAP related configuration
ldap:
# Specify the hostname:port combination of one or
# more LDAP servers
servers:
- "ldap1.example.com:636"
- "ldap2.example.com:636"
# Set to "tls" to use LDAP over TLS. Leave blank if
# the LDAP server doesn't accept TLS. You must enable TLS when you deploy the database resource to use this setting.
transportSecurity: "tls"
# If TLS is enabled, add a reference to a ConfigMap that
# contains a CA certificate that validates the LDAP server's
# TLS certificate.
caConfigMapRef:
name: "<configmap-name>"
key: "<configmap-entry-key>"
# Specify the LDAP Distinguished Name to which
# MongoDB binds when connecting to the LDAP server
bindQueryUser: "cn=admin,dc=example,dc=org"
# Specify the password with which MongoDB binds
# when connecting to an LDAP server. This is a
# reference to a Secret Kubernetes Object containing
# one "password" key.
bindQueryPasswordSecretRef:
name: "<secret-name>"

LDAP 설정의 전체 목록은 Kubernetes 연산자 MongoDB 리소스 사양의 보안 설정 을 참조하세요. LDAP 지원 Kubernetes 연산자 배포에서 MongoDB 에이전트 사용자에 대한 spec.security.authentication.agents.automationUserName 설정도 참조하세요.

4

Kubernetes 연산자 MongoDB 리소스 사양에서 Agent 관련 보안 설정 으로 MongoDB 리소스를 업데이트합니다 . 결과 구성은 다음 예시와 유사할 수 있습니다.

security:
authentication:
agents:
automationPasswordSecretRef:
key: automationConfigPassword
name: automation-config-password
automationUserName: mms-automation-agent
clientCertificateSecretRef:
name: agent-client-cert
mode: LDAP
enabled: true
ldap:
bindQueryPasswordSecretRef:
name: bind-query-password
bindQueryUser: cn=admin,dc=example,dc=org
servers:
- openldap.namespace.svc.cluster.local:389
userToDNMapping: '[{match: "(.+)",substitution: "uid={0},ou=groups,dc=example,dc=org"}]'
modes:
- LDAP
- SCRAM
requireClientTLSAuthentication: false
5
6

다음 Kubernetes 명령을 호출하여 샤드 클러스터를 업데이트합니다.

kubectl apply -f <sharded-cluster-conf>.yaml
7

MongoDB 리소스의 상태를 확인하려면 다음 명령어를 사용하세요.

kubectl get mdb <resource-name> -o yaml -w

-w(watch) 플래그 설정이 적용된 경우, 구성이 변경되면 상태 단계가 Running 상태를 달성할 때까지 출력이 즉시 새로 고침 됩니다. 리소스 배포 상태에 대해 자세히 알아보려면 Kubernetes Operator 문제 해결을 참조하세요.

이 페이지의 내용