文档菜单
文档首页
/
MongoDB 企业版 Kubernetes Operator
/ /

使用 LDAP 安全客户端身份验证

在本页

  • 注意事项
  • 先决条件
  • 为多 Kubernetes-Cluster 副本集配置 LDAP 客户端身份验证
  • 更新你的MongoDBMultiCluster 资源以启用LDAP 身份验证。
  • 请验证 MongoDBMultiCluster 资源正在运行。

MongoDB 企业版 支持

  • 将身份验证请求代理到轻量级目录访问协议(LDAP)服务。

  • 简单的 SASL 绑定到 LDAP 服务器。MongoDB 企业版可以通过saslauthd 或操作系统库与 LDAP 服务器绑定。

要了解更多信息,请参阅 MongoDB 服务器文档中的 LDAP 代理身份验证LDAP 授权 部分。

您可以使用Kubernetes Operator来配置 LDAP 以身份验证连接到您的多Kubernetes集群MongoDB部署。本指南描述了如何从客户端应用程序配置LDAP身份验证到您的多Kubernetes集群MongoDB部署.

  • 要在CustomResourceDefinitions中配置LDAP,请使用以下参数:spec.security.authentication.ldap以及其他针对MongoDB Agent的特定安全LDAP设置,从Kubernetes OperatorMongoDB资源规范。本节中的过程描述了所需设置并提供了LDAP配置的示例。

  • 为了提高安全性,考虑部署一个TLS加密的多集群。使用TLS进行加密是可选的。默认情况下,LDAP流量以纯文本形式发送。这意味着用户名和密码会暴露给网络威胁。许多现代目录服务,如Microsoft Active Directory,需要加密连接。考虑在您的MongoDB部署中使用LDAP通过TLS/SSL来加密身份验证请求。Kubernetes Operator

在您使用TLS加密确保多Kubernetes集群MongoDB部署之前完成以下任务

1

使用MongoDBMultiCluster资源规范中的安全设置更新您的MongoDBMultiCluster自定义资源Kubernetes Operator 以启用您的部署中的LDAP.

要启用您的部署中的LDAP,在您的Kubernetes对象中配置以下设置

类型和必要性
描述
示例
布尔值,
必需

将设置true以启用LDAP身份验证。

true

字符串,
必需

指定MongoDB连接LDAP服务器时绑定的LDAP区分名称。

cn=admin,dc=example,dc=org

字符串,
必需

指定包含LDAP绑定唯一名称密码的secret名称,该密码是MongoDB连接到LDAP服务器时使用的。

<secret-name>

字符串,
可选

添加包含您用于签署部署TLS证书的自定义CAConfigMap的名称。

<configmap-name>

字符串,
可选

添加存储验证LDAP服务器TLS证书的CA的字段名称。

<configmap-key>

字符串数组,
必需

指定一个或多个LDAP服务器的hostname:port组合列表。对于每个服务器,使用单独的一行。

<example.com:636>

字符串,
可选

设置为tls以使用LDAPS(TLS上的LDAP)。如果LDAP服务器不接受TLS,请留空。您必须在部署数据库资源时启用TLS才能使用此设置。

tls

字符串,
必需

指定映射,将提供给mongodmongos进行身份验证的用户名映射到LDAP唯一名称(DN)。

有关更多信息,请参阅MongoDB服务器文档中的security.ldap.userToDNMappingLDAP查询模板

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

spec.security
字符串,
必需

设置为 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 multi-cluster 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 Operator MongoDBMultiCluster 资源规范。也请参阅在您的启用了 LDAP 的 spec.security.authentication.agents.automationUserName 设置中的 MongoDB Agent 用户Kubernetes Operator部署。

2
  1. 对于成员集群,运行以下命令以验证 MongoDB Pods 是否处于运行状态

    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
  2. 在中央集群中,运行以下命令以验证 MongoDBMultiCluster 资源是否处于运行状态

    kubectl --context=$MDB_CENTRAL_CLUSTER_FULL_NAME \
    --namespace mongodb \
    get mdbmc multi-replica-set -o yaml -w
© . All rights reserved.