第 19 章 同步 LDAP 组


将 LDAP 组与 OpenShift Container Platform 同步,以便您可以使用存储在 LDAP 目录中的组来管理用户成员资格和权限。

作为管理员,您可以使用组来管理用户、更改其权限,并加强协作。您的组织可能已创建了用户组,并将其存储在 LDAP 服务器中。OpenShift Container Platform 可以将这些 LDAP 记录与 OpenShift Container Platform 内部记录同步,让您能够集中在一个位置管理您的组。OpenShift Container Platform 目前支持与使用以下三种通用模式定义组成员资格的 LDAP 服务器进行组同步:RFC 2307、Active Directory 和增强 Active Directory。

有关配置 LDAP 的更多信息,请参阅"配置 LDAP 身份提供程序"。

注意

您必须具有 cluster-admin 特权才能同步组。

19.1. 关于配置 LDAP 同步

查看 LDAP 组同步如何工作,以及同步配置文件包含的内容,以便您可以为 LDAP 模式配置组同步。

在运行 LDAP 同步之前,您需要有一个同步配置文件。此文件包含以下 LDAP 客户端配置详情:

  • 用于连接 LDAP 服务器的配置。
  • 依赖于您的 LDAP 服务器中所用模式的同步配置选项。
  • 管理员定义的名称映射列表,用于将 OpenShift Container Platform 组名称映射到 LDAP 服务器中的组。

配置文件的格式取决于您使用的模式:

  • RFC 2307
  • Active Directory
  • 增强 Active Directory.

19.1.1. LDAP 客户端配置

配置中的 LDAP 客户端配置部分定义与 LDAP 服务器的连接。以下示例显示了 LDAP 客户端配置字段:

url: ldap://10.0.0.0:389
bindDN: cn=admin,dc=example,dc=com
bindPassword: <password>
insecure: false
ca: my-ldap-ca-bundle.crt
  • url 字段显示连接协议、托管数据库的 LDAP 服务器的 IP 地址以及要连接的端口,格式为 scheme://host:port
  • bindDN 字段显示一个可选的可分辨名称(DN),用作绑定 DN。如果需要升级特权才能检索同步操作的条目,OpenShift Container Platform 会使用此项。
  • bindPassword 字段显示用来绑定的可选密码。如果需要升级特权才能检索同步操作的条目,OpenShift Container Platform 会使用此项。此值也可在环境变量、外部文件或加密文件中提供。
  • insecure 字段控制 LDAP 连接是否使用 TLS。当设置为 false 时,ldaps:// URL 使用 TLS 连接到服务器,并且 ldap:// URL 升级到 TLS。当设置为 true 时,不会对服务器进行 TLS 连接,您不能使用 ldaps:// URL。
  • ca 字段显示用于验证所配置 URL 的服务器证书的证书捆绑包。如果为空,OpenShift Container Platform 将使用系统信任的根证书。只有 insecure 设为 false 时才会应用此项。

19.1.2. LDAP 查询定义

同步配置由用于同步所需条目的 LDAP 查询定义组成。LDAP 查询的具体定义取决于用来在 LDAP 服务器中存储成员资格信息的模式。以下示例显示了 LDAP 查询定义字段:

baseDN: ou=users,dc=example,dc=com
scope: sub
derefAliases: never
timeout: 0
filter: (objectClass=person)
pageSize: 0
  • baseDN 字段包含所有搜索都从中开始的目录分支的可分辨名称(DN)。您需要指定目录树的顶端,但也可以指定目录中的子树。
  • scope 字段显示搜索范围。有效值为 baseonesub。如果省略此字段,则默认为 sub。有关每个值的描述,请参阅表 1,LDAP 搜索范围选项
  • derefAliases 字段显示与 LDAP 树中别名相关的搜索行为。有效值是 neversearchbasealways。如果未定义,则默认为 always 解引用别名。解引用行为的描述包括在表 2 中,LDAP 解引用行为
  • timeout 字段显示客户端进行搜索的时间限值(以秒为单位)。0 代表不实施客户端限制。
  • filter 字段包含有效的 LDAP 搜索过滤器。如果未定义,则默认为 (objectClass=*)
  • pageSize 字段显示服务器每个页面返回的最大 LDAP 条目数。如果设置为 0, 则不会应用页面大小限制。当查询返回超过客户端或服务器允许的条目数时,设置此字段。
Expand
LDAP 搜索范围描述

base

仅考虑通过为查询给定的基本 DN 指定的对象。

one

考虑作为查询的基本 DN 的树中同一级上的所有对象。

sub

考虑根部是为查询给定的基本 DN 的整个子树。

Expand
解引用行为描述

never

从不解引用 LDAP 树中找到的任何别名。

search

仅解引用搜索时找到的别名。

base

仅在查找基本对象时解引用别名。

always

始终解引用 LDAP 树中找到的所有别名。

19.1.3. 用户定义的名称映射

用户定义的名称映射明确将 OpenShift Container Platform 组的名称映射到可在 LDAP 服务器上找到组的唯一标识符。映射使用普通 YAML 语法。用户定义的映射可为 LDAP 服务器中每个组包含一个条目,或者仅包含这些组的一个子集。如果 LDAP 服务器上有没有用户定义的名称映射的组,同步期间的默认行为是使用指定为 OpenShift Container Platform 组名称的属性。

以下示例显示了用户定义的名称映射:

groupUIDNameMapping:
  "cn=group1,ou=groups,dc=example,dc=com": firstgroup
  "cn=group2,ou=groups,dc=example,dc=com": secondgroup
  "cn=group3,ou=groups,dc=example,dc=com": thirdgroup

19.1.4. 关于 RFC 2307 配置文件

查看 RFC 2307 LDAP 同步配置文件,以便您可以定义用户和组查询以及 OpenShift Container Platform 组记录中使用的属性。

RFC 2307 模式要求您提供用户和组条目的 LDAP 查询定义,以及在 OpenShift Container Platform 内部记录中代表它们的属性。

为了清晰起见,您在 OpenShift Container Platform 中创建的组应尽可能使用与可分辨名称以外的属性,用于面向用户或管理员的字段。例如,通过电子邮件标识 OpenShift Container Platform 组的用户,并将该组的名称用作通用名称。以下配置文件创建了这些关系:

注意

如果使用用户定义的名称映射,您的配置文件会有所不同。

kind: LDAPSyncConfig
apiVersion: v1
url: ldap://LDAP_SERVICE_IP:389
insecure: false
bindDN: cn=admin,dc=example,dc=com
bindPassword:
  file: "/etc/secrets/bindPassword"
rfc2307:
    groupsQuery:
        baseDN: "ou=groups,dc=example,dc=com"
        scope: sub
        derefAliases: never
        pageSize: 0
    groupUIDAttribute: dn
    groupNameAttributes: [ cn ]
    groupMembershipAttributes: [ member ]
    usersQuery:
        baseDN: "ou=users,dc=example,dc=com"
        scope: sub
        derefAliases: never
        pageSize: 0
    userUIDAttribute: dn
    userNameAttributes: [ mail ]
    tolerateMemberNotFoundErrors: false
    tolerateMemberOutOfScopeErrors: false

其中:

url
指定存储组记录的 LDAP 服务器的 IP 地址和主机。
insecure
指定 LDAP 连接是否使用 TLS。当设置为 false 时,ldaps:// URL 使用 TLS 连接到服务器,并且 ldap:// URL 升级到 TLS。当设置为 true 时,不会对服务器进行 TLS 连接,您不能使用 ldaps:// URL。
rfc2307.groupUIDAttribute
指定唯一标识 LDAP 服务器上的组的属性。将 DN 用于 groupUIDAttribute 时,您无法指定 groupsQuery 过滤器。若要进行精细过滤,请使用允许列表文件、拒绝列表文件或两者。
rfc2307.groupNameAttributes
指定要用作组名称的属性。
rfc2307.groupMembershipAttributes
指定存储成员资格信息的组的属性。
rfc2307.userUIDAttribute
指定在 LDAP 服务器上唯一标识用户的属性。将 DN 用于 userUIDAttribute 时,您无法指定usersQuery 过滤器。若要进行精细过滤,请使用允许列表文件、拒绝列表文件或两者。
rfc2307.userNameAttributes
指定在 OpenShift Container Platform 组记录中用作用户名称的属性。

19.1.5. 关于 Active Directory 配置文件

查看 Active Directory LDAP 同步配置文件,以便您可以定义用户查询和 OpenShift Container Platform 组记录中使用的属性。

Active Directory 模式要求您提供用户条目的 LDAP 查询定义,以及在内部 OpenShift Container Platform 组记录中代表它们的属性。

为了清晰起见,您在 OpenShift Container Platform 中创建的组应尽可能使用与可分辨名称以外的属性,用于面向用户或管理员的字段。例如,通过电子邮件标识 OpenShift Container Platform 组的用户,但通过 LDAP 服务器上的组名称来定义组名称。以下配置文件创建了这些关系:

kind: LDAPSyncConfig
apiVersion: v1
url: ldap://LDAP_SERVICE_IP:389
activeDirectory:
    usersQuery:
        baseDN: "ou=users,dc=example,dc=com"
        scope: sub
        derefAliases: never
        filter: (objectclass=person)
        pageSize: 0
    userNameAttributes: [ mail ]
    groupMembershipAttributes: [ memberOf ]

其中:

Active Directory.userNameAttributes
指定在 OpenShift Container Platform 组记录中用作用户名称的属性。
Active Directory.groupMembershiptAttributes
指定存储成员资格信息的用户的属性。

19.1.6. 关于增强 Active Directory 配置文件

检查增强 Active Directory LDAP 同步配置文件,以便您可以定义用户和组查询以及 OpenShift Container Platform 组记录中使用的属性。

增强 Active Directory(augmented Active Directory) 模式要求您提供用户条目和组条目的 LDAP 查询定义,以及在内部 OpenShift Container Platform 组记录中代表它们的属性。

为了清晰起见,您在 OpenShift Container Platform 中创建的组应尽可能使用与可分辨名称以外的属性,用于面向用户或管理员的字段。例如,通过电子邮件标识 OpenShift Container Platform 组的用户,并将该组的名称用作通用名称。以下配置文件创建了这些关系。

kind: LDAPSyncConfig
apiVersion: v1
url: ldap://LDAP_SERVICE_IP:389
augmentedActiveDirectory:
    groupsQuery:
        baseDN: "ou=groups,dc=example,dc=com"
        scope: sub
        derefAliases: never
        pageSize: 0
    groupUIDAttribute: dn
    groupNameAttributes: [ cn ]
    usersQuery:
        baseDN: "ou=users,dc=example,dc=com"
        scope: sub
        derefAliases: never
        filter: (objectclass=person)
        pageSize: 0
    userNameAttributes: [ mail ]
    groupMembershipAttributes: [ memberOf ]

其中:

augmentedActiveDirectory.groupUIDAttribute
指定唯一标识 LDAP 服务器上的组的属性。将 DN 用于 groupUIDAttribute 时,您无法指定 groupsQuery 过滤器。若要进行精细过滤,请使用允许列表文件、拒绝列表文件或两者。
augmentedActiveDirectory.groupNameAttributes
指定要用作组名称的属性。
augmentedActiveDirectory.userNameAttributes
指定在 OpenShift Container Platform 组记录中用作用户名称的属性。
augmentedActiveDirectory.groupMembershipAttributes
指定存储成员资格信息的用户的属性。
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部