将身份验证请求代理到轻量级目录访问协议 (LDAP) 服务。
与 LDAP 服务器的简单 SASL 绑定。 MongoDB Enterprise 可以通过
saslauthd
或通过操作系统库绑定到 LDAP 服务器。
要了解更多信息,请参阅 MongoDB Server 文档中的LDAP 代理身份验证和LDAP 授权部分。
您可以使用Kubernetes Operator 配置 LDAP ,以对连接到多 Kubernetes集群MongoDB部署的客户端应用程序进行身份验证。本指南介绍如何配置从客户端应用程序到多 Kubernetes 集群 MongoDB 部署的 LDAP 身份验证。
Considerations
要在 CustomResourceDefinitions 中配置LDAP
spec.security.authentication.ldap
,请使用Kubernetes Operator MongoDB资源规范中 下的参数以及特定于MongoDB 助手的其他安全LDAP设置。本部分中的过程描述了所需的设置,并提供了LDAP配置的示例。为了提高安全性,请考虑部署TLS 加密的多集群。 使用TLS加密是可选的。 默认情况下, LDAP流量以纯文本形式发送。 这意味着用户名和密码会受到网络威胁。 许多现代目录服务(例如 Microsoft Active Directory)都需要加密连接。 考虑使用基于 TLS / SSL 的 LDAP 对 Kubernetes 操作符 MongoDB 部署中的身份验证请求进行加密。
先决条件
在使用TLS加密保护多 Kubernetes 集群 MongoDB 部署之前,请完成以下任务:
为多 Kubernetes 集群副本集配置 LDAP 客户端身份验证
更新MongoDBMultiCluster
资源以启用LDAP身份验证。
使用 Kubernetes 操作符 MongoDBMultiCluster 资源规范中 的安全设置 更新 MongoDBMultiCluster 自定义资源 。
要在部署中启用LDAP ,请在 Kubernetes 对象中配置以下设置:
键 | 类型和必要性 | 说明 | 例子 |
---|---|---|---|
spec.security | boolean, required | 设置为 |
|
spec.security | string, required | 指定连接到 LDAP 服务器时 MongoDB 绑定到的 LDAP 标识名。 |
|
spec.security | string, required |
| |
spec.security | string, optional | 添加 ConfigMap 的名称,该名称存储用于签署您部署的 TLS 证书的自定义 CA。 |
|
spec.security | string, optional | 添加用于存储验证 LDAP 服务器的 TLS 证书的 CA 的字段名称。 |
|
spec.security | array of strings, required | 指定一个或多个 LDAP 服务器的 |
|
spec.security | string, optional | 设置为 |
|
spec.security | string, required | 指定映射,将提供给 要了解更多信息,请参阅security.ldap.userToDNMapping 和LDAP LDAP MongoDB Server文档中的 查询模板 。 |
|
spec.security | string, required | 设置为 |
|
生成的配置可能类似于以下示例:
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 操作符 MongoDBMultiCluster 资源规范中的安全设置。另请参阅启用 LDAP 的 Kubernetes 操作符部署中 MongoDB Agent 用户的spec.security.authentication.agents.automationUserName
设置。
验证MongoDBMultiCluster
资源是否运行。
对于成员集群,运行以下命令验证 MongoDB Pod 是否处于运行状态:
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