×

作为具有 `dedicated-admin` 角色的管理员,您可以使用组来管理用户、更改其权限并增强协作。您的组织可能已经创建了用户组并将它们存储在 LDAP 服务器中。AWS 上的 Red Hat OpenShift 服务可以将这些 LDAP 记录与 AWS 上的 Red Hat OpenShift 服务内部记录同步,使您能够在一个位置管理您的组。AWS 上的 Red Hat OpenShift 服务目前支持使用三种常用的定义组成员关系的模式与 LDAP 服务器进行组同步:RFC 2307、Active Directory 和增强的 Active Directory。

有关配置 LDAP 的更多信息,请参阅 配置 LDAP 身份提供者

您必须拥有 `dedicated-admin` 权限才能同步组。

关于配置 LDAP 同步

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

  • 连接到 LDAP 服务器的配置。

  • 取决于 LDAP 服务器中使用的模式的同步配置选项。

  • 管理员定义的名称映射列表,用于将 AWS 上的 Red Hat OpenShift 服务组名称映射到 LDAP 服务器中的组。

配置文件的格式取决于您使用的模式:RFC 2307、Active Directory 或增强的 Active Directory。

LDAP 客户端配置

配置部分定义了与 LDAP 服务器的连接。

配置部分定义了与 LDAP 服务器的连接。

LDAP 客户端配置
url: ldap://10.0.0.0:389 (1)
bindDN: cn=admin,dc=example,dc=com (2)
bindPassword: <password> (3)
insecure: false (4)
ca: my-ldap-ca-bundle.crt (5)
1 连接协议、托管数据库的 LDAP 服务器的 IP 地址和连接端口,格式为 `scheme://host:port`。
2 可选的区分名称 (DN),用作绑定 DN。如果需要提升的权限来检索同步操作的条目,则 AWS 上的 Red Hat OpenShift 服务将使用此名称。
3 可选的用于绑定的密码。如果需要提升的权限来检索同步操作的条目,则 AWS 上的 Red Hat OpenShift 服务将使用此密码。此值也可以在环境变量、外部文件或加密文件中提供。
4 当为 `false` 时,安全 LDAP(`ldaps://`)URL 使用 TLS 连接,不安全 LDAP(`ldap://`)URL 将升级到 TLS。当为 `true` 时,不会建立到服务器的 TLS 连接,并且您无法使用 `ldaps://` URL 方案。
5 用于验证配置 URL 的服务器证书的证书包。如果为空,则 AWS 上的 Red Hat OpenShift 服务将使用系统信任的根证书。这仅在 `insecure` 设置为 `false` 时适用。
LDAP 查询定义

同步配置由需要同步的条目的 LDAP 查询定义组成。LDAP 查询的具体定义取决于用于在 LDAP 服务器中存储成员信息模式。

LDAP 查询定义
baseDN: ou=users,dc=example,dc=com (1)
scope: sub (2)
derefAliases: never (3)
timeout: 0 (4)
filter: (objectClass=person) (5)
pageSize: 0 (6)
1 目录分支的区分名称 (DN),所有搜索都将从此处开始。您必须指定目录树的顶部,但您也可以指定目录中的子树。
2 搜索范围。有效值为 `base`、`one` 或 `sub`。如果未定义此值,则假定范围为 `sub`。下表中提供了范围选项的描述。
3 搜索相对于 LDAP 树中别名的行为。有效值为 `never`、`search`、`base` 或 `always`。如果未定义此值,则默认为 `always` 取消引用别名。下表中提供了取消引用行为的描述。
4 客户端搜索允许的时间限制(秒)。值为0表示不施加客户端限制。
5 有效的LDAP搜索过滤器。如果未定义,则默认为(objectClass=*)
6 服务器响应页面的可选最大大小(以LDAP条目为单位)。如果设置为0,则不会对响应页面进行大小限制。当查询返回的条目数量超过客户端或服务器默认允许的数量时,需要设置分页大小。
表2. LDAP反引用行为
反引用行为 描述

never

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

search

仅反引用在搜索过程中找到的别名。

base

仅反引用在查找基本对象时找到的别名。

always

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

用户定义的名称映射

用户定义的名称映射明确地将AWS上的Red Hat OpenShift Service组的名称映射到在您的LDAP服务器上查找组的唯一标识符。映射使用标准YAML语法。用户定义的映射可以包含LDAP服务器中每个组的条目,也可以只包含这些组的子集。如果LDAP服务器上存在没有用户定义名称映射的组,则同步期间的默认行为是使用指定为AWS上Red Hat OpenShift Service组名称的属性。

用户定义的名称映射
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

关于RFC 2307配置文件

RFC 2307模式要求您为用户和组条目提供LDAP查询定义,以及在内部AWS上Red Hat OpenShift Service记录中表示它们的属性。

为清晰起见,您在AWS上创建的Red Hat OpenShift Service组应尽可能使用与可区分名称不同的属性作为用户或管理员界面字段。例如,通过电子邮件识别AWS上Red Hat OpenShift Service组的用户,并使用组的名称作为通用名称。以下配置文件创建这些关系

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

使用RFC 2307模式的LDAP同步配置:rfc2307_config.yaml
kind: LDAPSyncConfig
apiVersion: v1
url: ldap://LDAP_SERVICE_IP:389 (1)
insecure: false (2)
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 (3)
    groupNameAttributes: [ cn ] (4)
    groupMembershipAttributes: [ member ] (5)
    usersQuery:
        baseDN: "ou=users,dc=example,dc=com"
        scope: sub
        derefAliases: never
        pageSize: 0
    userUIDAttribute: dn (6)
    userNameAttributes: [ mail ] (7)
    tolerateMemberNotFoundErrors: false
    tolerateMemberOutOfScopeErrors: false
1 存储此组记录的LDAP服务器的IP地址和主机。
2 当为 `false` 时,安全 LDAP(`ldaps://`)URL 使用 TLS 连接,不安全 LDAP(`ldap://`)URL 将升级到 TLS。当为 `true` 时,不会建立到服务器的 TLS 连接,并且您无法使用 `ldaps://` URL 方案。
3 唯一标识LDAP服务器上组的属性。使用DN作为groupUIDAttribute时,不能指定groupsQuery过滤器。对于细粒度过滤,请使用白名单/黑名单方法。
4 用作组名称的属性。
5 存储成员信息组上的属性。
6 唯一标识LDAP服务器上用户的属性。使用DN作为userUIDAttribute时,不能指定usersQuery过滤器。对于细粒度过滤,请使用白名单/黑名单方法。
7 用作AWS上Red Hat OpenShift Service组记录中用户名称的属性。

关于Active Directory配置文件

Active Directory模式要求您为用户条目提供LDAP查询定义,以及在内部AWS上Red Hat OpenShift Service组记录中表示它们的属性。

为清晰起见,您在AWS上创建的Red Hat OpenShift Service组应尽可能使用与可区分名称不同的属性作为用户或管理员界面字段。例如,通过电子邮件识别AWS上Red Hat OpenShift Service组的用户,但通过LDAP服务器上的组名称定义组的名称。以下配置文件创建这些关系

使用Active Directory模式的LDAP同步配置:active_directory_config.yaml
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 ] (1)
    groupMembershipAttributes: [ memberOf ] (2)
1 用作AWS上Red Hat OpenShift Service组记录中用户名称的属性。
2 用户上存储成员信息的属性。

关于增强的Active Directory配置文件

增强的Active Directory模式要求您为用户条目和组条目提供LDAP查询定义,以及在内部AWS上Red Hat OpenShift Service组记录中表示它们的属性。

为清晰起见,您在AWS上创建的Red Hat OpenShift Service组应尽可能使用与可区分名称不同的属性作为用户或管理员界面字段。例如,通过电子邮件识别AWS上Red Hat OpenShift Service组的用户,并使用组的名称作为通用名称。以下配置文件创建这些关系。

使用增强的Active Directory模式的LDAP同步配置:augmented_active_directory_config.yaml
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 (1)
    groupNameAttributes: [ cn ] (2)
    usersQuery:
        baseDN: "ou=users,dc=example,dc=com"
        scope: sub
        derefAliases: never
        filter: (objectclass=person)
        pageSize: 0
    userNameAttributes: [ mail ] (3)
    groupMembershipAttributes: [ memberOf ] (4)
1 唯一标识LDAP服务器上组的属性。使用DN作为groupUIDAttribute时,不能指定groupsQuery过滤器。对于细粒度过滤,请使用白名单/黑名单方法。
2 用作组名称的属性。
3 用作AWS上Red Hat OpenShift Service组记录中用户名称的属性。
4 用户上存储成员信息的属性。

运行LDAP同步

创建同步配置文件后,您可以开始同步。AWS上的Red Hat OpenShift Service允许管理员使用相同的服务器执行多种不同的同步类型。

将LDAP服务器与AWS上的Red Hat OpenShift Service同步

您可以将LDAP服务器上的所有组与AWS上的Red Hat OpenShift Service同步。

先决条件
  • 创建一个同步配置文件。

  • 您可以作为具有dedicated-admin角色的用户访问集群。

步骤
  • 将LDAP服务器上的所有组与AWS上的Red Hat OpenShift Service同步

    $ oc adm groups sync --sync-config=config.yaml --confirm

    默认情况下,所有组同步操作都是试运行,因此您必须在oc adm groups sync命令上设置--confirm标志才能更改AWS上Red Hat OpenShift Service组记录。

将AWS上的Red Hat OpenShift Service组与LDAP服务器同步

您可以同步AWS上Red Hat OpenShift Service中所有已存在的组,这些组对应于配置文件中指定的LDAP服务器中的组。

先决条件
  • 创建一个同步配置文件。

  • 您可以作为具有dedicated-admin角色的用户访问集群。

步骤
  • 将AWS上的Red Hat OpenShift Service组与LDAP服务器同步

    $ oc adm groups sync --type=openshift --sync-config=config.yaml --confirm

    默认情况下,所有组同步操作都是试运行,因此您必须在oc adm groups sync命令上设置--confirm标志才能更改AWS上Red Hat OpenShift Service组记录。

将LDAP服务器上的子组与AWS上的Red Hat OpenShift Service同步

您可以使用白名单文件、黑名单文件或两者都使用来将LDAP组的子集与AWS上的Red Hat OpenShift Service同步。

您可以组合使用黑名单文件、白名单文件或白名单字面量。白名单和黑名单文件每行必须包含一个唯一的组标识符,您也可以直接在命令中包含白名单字面量。这些准则适用于 LDAP 服务器上的组以及 AWS 上 Red Hat OpenShift Service 中已存在的组。

先决条件
  • 创建一个同步配置文件。

  • 您可以作为具有dedicated-admin角色的用户访问集群。

步骤
  • 要将 LDAP 组的子集与 AWS 上的 Red Hat OpenShift Service 同步,请使用以下任何命令

    $ oc adm groups sync --whitelist=<whitelist_file> \
                       --sync-config=config.yaml      \
                       --confirm
    $ oc adm groups sync --blacklist=<blacklist_file> \
                       --sync-config=config.yaml      \
                       --confirm
    $ oc adm groups sync <group_unique_identifier>    \
                       --sync-config=config.yaml      \
                       --confirm
    $ oc adm groups sync <group_unique_identifier>  \
                       --whitelist=<whitelist_file> \
                       --blacklist=<blacklist_file> \
                       --sync-config=config.yaml    \
                       --confirm
    $ oc adm groups sync --type=openshift           \
                       --whitelist=<whitelist_file> \
                       --sync-config=config.yaml    \
                       --confirm

    默认情况下,所有组同步操作都是试运行,因此您必须在oc adm groups sync命令上设置--confirm标志才能更改AWS上Red Hat OpenShift Service组记录。

运行组修剪作业

管理员还可以选择从 AWS 上 Red Hat OpenShift Service 记录中删除组,如果创建它们的 LDAP 服务器上的记录不再存在。修剪作业将接受与同步作业相同的同步配置文件以及白名单或黑名单。

例如

$ oc adm prune groups --sync-config=/path/to/ldap-sync-config.yaml --confirm
$ oc adm prune groups --whitelist=/path/to/whitelist.txt --sync-config=/path/to/ldap-sync-config.yaml --confirm
$ oc adm prune groups --blacklist=/path/to/blacklist.txt --sync-config=/path/to/ldap-sync-config.yaml --confirm

LDAP 组同步示例

本节包含 RFC 2307、Active Directory 和增强的 Active Directory 架构的示例。

这些示例假设所有用户都是其各自组的直接成员。具体来说,没有组具有其他组作为成员。有关如何同步嵌套组的信息,请参阅嵌套成员资格同步示例。

使用 RFC 2307 架构同步组

对于 RFC 2307 架构,以下示例同步名为admins的组,该组有两个成员:JaneJim。示例说明:

  • 如何将组和用户添加到 LDAP 服务器。

  • 同步后,AWS 上 Red Hat OpenShift Service 中生成的组记录将是什么。

这些示例假设所有用户都是其各自组的直接成员。具体来说,没有组具有其他组作为成员。有关如何同步嵌套组的信息,请参阅嵌套成员资格同步示例。

在 RFC 2307 架构中,用户 (Jane 和 Jim) 和组都作为一等实体存在于 LDAP 服务器上,组成员资格存储在组的属性中。以下ldif代码片段定义了此架构的用户和组

使用 RFC 2307 架构的 LDAP 条目:rfc2307.ldif
  dn: ou=users,dc=example,dc=com
  objectClass: organizationalUnit
  ou: users
  dn: cn=Jane,ou=users,dc=example,dc=com
  objectClass: person
  objectClass: organizationalPerson
  objectClass: inetOrgPerson
  cn: Jane
  sn: Smith
  displayName: Jane Smith
  mail: [email protected]
  dn: cn=Jim,ou=users,dc=example,dc=com
  objectClass: person
  objectClass: organizationalPerson
  objectClass: inetOrgPerson
  cn: Jim
  sn: Adams
  displayName: Jim Adams
  mail: [email protected]
  dn: ou=groups,dc=example,dc=com
  objectClass: organizationalUnit
  ou: groups
  dn: cn=admins,ou=groups,dc=example,dc=com (1)
  objectClass: groupOfNames
  cn: admins
  owner: cn=admin,dc=example,dc=com
  description: System Administrators
  member: cn=Jane,ou=users,dc=example,dc=com (2)
  member: cn=Jim,ou=users,dc=example,dc=com
1 该组是 LDAP 服务器中的一等实体。
2 组成员列在组属性中,带有标识性引用。
先决条件
  • 创建配置文件。

  • 您可以作为具有dedicated-admin角色的用户访问集群。

步骤
  • 使用rfc2307_config.yaml文件运行同步

    $ oc adm groups sync --sync-config=rfc2307_config.yaml --confirm

    AWS 上 Red Hat OpenShift Service 将创建以下组记录作为上述同步操作的结果

    使用rfc2307_config.yaml文件创建的 AWS 上 Red Hat OpenShift Service 组
    apiVersion: user.openshift.io/v1
    kind: Group
    metadata:
      annotations:
        openshift.io/ldap.sync-time: 2015-10-13T10:08:38-0400 (1)
        openshift.io/ldap.uid: cn=admins,ou=groups,dc=example,dc=com (2)
        openshift.io/ldap.url: LDAP_SERVER_IP:389 (3)
      creationTimestamp:
      name: admins (4)
    users: (5)
    - [email protected]
    - [email protected]
    1 此 AWS 上 Red Hat OpenShift Service 组上次与 LDAP 服务器同步的时间(ISO 6801 格式)。
    2 LDAP 服务器上组的唯一标识符。
    3 存储此组记录的LDAP服务器的IP地址和主机。
    4 同步文件中指定的组名称。
    5 组的成员,名称由同步文件指定。

使用 RFC2307 架构和用户定义的名称映射同步组

使用用户定义的名称映射同步组时,配置文件会更改为包含以下所示的这些映射。

使用 RFC 2307 架构和用户定义名称映射的 LDAP 同步配置:rfc2307_config_user_defined.yaml
kind: LDAPSyncConfig
apiVersion: v1
groupUIDNameMapping:
  "cn=admins,ou=groups,dc=example,dc=com": Administrators (1)
rfc2307:
    groupsQuery:
        baseDN: "ou=groups,dc=example,dc=com"
        scope: sub
        derefAliases: never
        pageSize: 0
    groupUIDAttribute: dn (2)
    groupNameAttributes: [ cn ] (3)
    groupMembershipAttributes: [ member ]
    usersQuery:
        baseDN: "ou=users,dc=example,dc=com"
        scope: sub
        derefAliases: never
        pageSize: 0
    userUIDAttribute: dn (4)
    userNameAttributes: [ mail ]
    tolerateMemberNotFoundErrors: false
    tolerateMemberOutOfScopeErrors: false
1 用户定义的名称映射。
2 用于用户定义名称映射中键的唯一标识符属性。使用 DN 作为 groupUIDAttribute 时,不能指定groupsQuery过滤器。要进行细粒度过滤,请使用白名单/黑名单方法。
3 如果其唯一标识符不在用户定义的名称映射中,则用于命名 AWS 上 Red Hat OpenShift Service 组的属性。
4 唯一标识LDAP服务器上用户的属性。使用DN作为userUIDAttribute时,不能指定usersQuery过滤器。对于细粒度过滤,请使用白名单/黑名单方法。
先决条件
  • 创建配置文件。

  • 您可以作为具有dedicated-admin角色的用户访问集群。

步骤
  • 使用rfc2307_config_user_defined.yaml文件运行同步

    $ oc adm groups sync --sync-config=rfc2307_config_user_defined.yaml --confirm

    AWS 上 Red Hat OpenShift Service 将创建以下组记录作为上述同步操作的结果

    使用rfc2307_config_user_defined.yaml文件创建的 AWS 上 Red Hat OpenShift Service 组
    apiVersion: user.openshift.io/v1
    kind: Group
    metadata:
      annotations:
        openshift.io/ldap.sync-time: 2015-10-13T10:08:38-0400
        openshift.io/ldap.uid: cn=admins,ou=groups,dc=example,dc=com
        openshift.io/ldap.url: LDAP_SERVER_IP:389
      creationTimestamp:
      name: Administrators (1)
    users:
    - [email protected]
    - [email protected]
    1 用户定义的名称映射中指定的组名称。

使用 RFC 2307 和用户定义的错误容限同步组

默认情况下,如果要同步的组包含成员条目位于成员查询中定义的范围之外,则组同步将失败并出现错误

Error determining LDAP group membership for "<group>": membership lookup for user "<user>" in group "<group>" failed because of "search for entry with dn="<user-dn>" would search outside of the base dn specified (dn="<base-dn>")".

这通常表示usersQuery字段中的baseDN配置错误。但是,如果baseDN有意不包含组的某些成员,则设置tolerateMemberOutOfScopeErrors: true允许组同步继续。范围外的成员将被忽略。

同样,当组同步过程无法找到组的成员时,它将直接失败并出现错误

Error determining LDAP group membership for "<group>": membership lookup for user "<user>" in group "<group>" failed because of "search for entry with base dn="<user-dn>" refers to a non-existent entry".
Error determining LDAP group membership for "<group>": membership lookup for user "<user>" in group "<group>" failed because of "search for entry with base dn="<user-dn>" and filter "<filter>" did not return any results".

这通常表示usersQuery字段配置错误。但是,如果组包含已知缺失的成员条目,则设置tolerateMemberNotFoundErrors: true允许组同步继续。有问题的成员将被忽略。

启用 LDAP 组同步的错误容限会导致同步过程忽略有问题的成员条目。如果 LDAP 组同步配置不正确,这可能会导致同步的 AWS 上 Red Hat OpenShift Service 组缺少成员。

使用 RFC 2307 架构且组成员资格存在问题的 LDAP 条目:rfc2307_problematic_users.ldif
  dn: ou=users,dc=example,dc=com
  objectClass: organizationalUnit
  ou: users
  dn: cn=Jane,ou=users,dc=example,dc=com
  objectClass: person
  objectClass: organizationalPerson
  objectClass: inetOrgPerson
  cn: Jane
  sn: Smith
  displayName: Jane Smith
  mail: [email protected]
  dn: cn=Jim,ou=users,dc=example,dc=com
  objectClass: person
  objectClass: organizationalPerson
  objectClass: inetOrgPerson
  cn: Jim
  sn: Adams
  displayName: Jim Adams
  mail: [email protected]
  dn: ou=groups,dc=example,dc=com
  objectClass: organizationalUnit
  ou: groups
  dn: cn=admins,ou=groups,dc=example,dc=com
  objectClass: groupOfNames
  cn: admins
  owner: cn=admin,dc=example,dc=com
  description: System Administrators
  member: cn=Jane,ou=users,dc=example,dc=com
  member: cn=Jim,ou=users,dc=example,dc=com
  member: cn=INVALID,ou=users,dc=example,dc=com (1)
  member: cn=Jim,ou=OUTOFSCOPE,dc=example,dc=com (2)
1 LDAP 服务器上不存在的成员。
2 可能存在的成员,但不位于同步作业的用户查询中的baseDN下。

要容忍上述示例中的错误,必须对同步配置文件进行以下添加

使用 RFC 2307 架构并容忍错误的 LDAP 同步配置:rfc2307_config_tolerating.yaml
kind: LDAPSyncConfig
apiVersion: v1
url: ldap://LDAP_SERVICE_IP:389
rfc2307:
    groupsQuery:
        baseDN: "ou=groups,dc=example,dc=com"
        scope: sub
        derefAliases: never
    groupUIDAttribute: dn
    groupNameAttributes: [ cn ]
    groupMembershipAttributes: [ member ]
    usersQuery:
        baseDN: "ou=users,dc=example,dc=com"
        scope: sub
        derefAliases: never
    userUIDAttribute: dn (1)
    userNameAttributes: [ mail ]
    tolerateMemberNotFoundErrors: true (2)
    tolerateMemberOutOfScopeErrors: true (3)
1 唯一标识LDAP服务器上用户的属性。使用DN作为userUIDAttribute时,不能指定usersQuery过滤器。对于细粒度过滤,请使用白名单/黑名单方法。
2 如果为true,则同步作业将容忍某些成员未找到的组,并且未找到成员条目的成员将被忽略。同步作业的默认行为是在未找到组的成员时失败。
3 如果为true,则同步作业将容忍某些成员位于usersQuerybase DN 中给定的用户范围之外的组,并且成员查询范围之外的成员将被忽略。同步作业的默认行为是在组的成员超出范围时失败。
先决条件
  • 创建配置文件。

  • 您可以作为具有dedicated-admin角色的用户访问集群。

步骤
  • 使用rfc2307_config_tolerating.yaml文件运行同步

    $ oc adm groups sync --sync-config=rfc2307_config_tolerating.yaml --confirm

    AWS 上 Red Hat OpenShift Service 将创建以下组记录作为上述同步操作的结果

    使用rfc2307_config.yaml文件创建的 AWS 上 Red Hat OpenShift Service 组
    apiVersion: user.openshift.io/v1
    kind: Group
    metadata:
      annotations:
        openshift.io/ldap.sync-time: 2015-10-13T10:08:38-0400
        openshift.io/ldap.uid: cn=admins,ou=groups,dc=example,dc=com
        openshift.io/ldap.url: LDAP_SERVER_IP:389
      creationTimestamp:
      name: admins
    users: (1)
    - [email protected]
    - [email protected]
    1 组成员,由同步文件指定。查找遇到可容忍错误的成员不存在。

使用 Active Directory 架构同步组

在 Active Directory 架构中,用户 (Jane 和 Jim) 都作为一等实体存在于 LDAP 服务器上,组成员资格存储在用户的属性中。以下ldif代码片段定义了此架构的用户和组

使用 Active Directory 架构的 LDAP 条目:active_directory.ldif
dn: ou=users,dc=example,dc=com
objectClass: organizationalUnit
ou: users

dn: cn=Jane,ou=users,dc=example,dc=com
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: testPerson
cn: Jane
sn: Smith
displayName: Jane Smith
mail: [email protected]
memberOf: admins (1)

dn: cn=Jim,ou=users,dc=example,dc=com
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: testPerson
cn: Jim
sn: Adams
displayName: Jim Adams
mail: [email protected]
memberOf: admins
1 用户的组成员资格列在用户的属性中,并且组不在服务器上作为条目存在。memberOf属性不必是用户上的字面属性;在某些 LDAP 服务器中,它是在搜索期间创建的并返回给客户端,但不会提交到数据库。
先决条件
  • 创建配置文件。

  • 您可以作为具有dedicated-admin角色的用户访问集群。

步骤
  • 使用active_directory_config.yaml文件运行同步

    $ oc adm groups sync --sync-config=active_directory_config.yaml --confirm

    AWS 上 Red Hat OpenShift Service 将创建以下组记录作为上述同步操作的结果

    使用active_directory_config.yaml文件创建的 AWS 上 Red Hat OpenShift Service 组
    apiVersion: user.openshift.io/v1
    kind: Group
    metadata:
      annotations:
        openshift.io/ldap.sync-time: 2015-10-13T10:08:38-0400 (1)
        openshift.io/ldap.uid: admins (2)
        openshift.io/ldap.url: LDAP_SERVER_IP:389 (3)
      creationTimestamp:
      name: admins (4)
    users: (5)
    - [email protected]
    - [email protected]
    1 此 AWS 上 Red Hat OpenShift Service 组上次与 LDAP 服务器同步的时间(ISO 6801 格式)。
    2 LDAP 服务器上组的唯一标识符。
    3 存储此组记录的LDAP服务器的IP地址和主机。
    4 LDAP 服务器中列出的组名称。
    5 组的成员,名称由同步文件指定。

使用增强型 Active Directory 架构同步组

在增强型 Active Directory 架构中,用户(Jane 和 Jim)和组都作为一等实体存在于 LDAP 服务器中,组成员关系存储在用户的属性中。以下 ldif 代码片段定义了此架构的用户和组。

使用增强型 Active Directory 架构的 LDAP 条目:augmented_active_directory.ldif
dn: ou=users,dc=example,dc=com
objectClass: organizationalUnit
ou: users

dn: cn=Jane,ou=users,dc=example,dc=com
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: testPerson
cn: Jane
sn: Smith
displayName: Jane Smith
mail: [email protected]
memberOf: cn=admins,ou=groups,dc=example,dc=com (1)

dn: cn=Jim,ou=users,dc=example,dc=com
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: testPerson
cn: Jim
sn: Adams
displayName: Jim Adams
mail: [email protected]
memberOf: cn=admins,ou=groups,dc=example,dc=com

dn: ou=groups,dc=example,dc=com
objectClass: organizationalUnit
ou: groups

dn: cn=admins,ou=groups,dc=example,dc=com (2)
objectClass: groupOfNames
cn: admins
owner: cn=admin,dc=example,dc=com
description: System Administrators
member: cn=Jane,ou=users,dc=example,dc=com
member: cn=Jim,ou=users,dc=example,dc=com
1 用户的组成员关系列在其属性中。
2 组是 LDAP 服务器上的一等实体。
先决条件
  • 创建配置文件。

  • 您可以作为具有dedicated-admin角色的用户访问集群。

步骤
  • 使用 augmented_active_directory_config.yaml 文件运行同步。

    $ oc adm groups sync --sync-config=augmented_active_directory_config.yaml --confirm

    AWS 上 Red Hat OpenShift Service 将创建以下组记录作为上述同步操作的结果

    使用 augmented_active_directory_config.yaml 文件创建的 AWS 上 Red Hat OpenShift 服务组。
    apiVersion: user.openshift.io/v1
    kind: Group
    metadata:
      annotations:
        openshift.io/ldap.sync-time: 2015-10-13T10:08:38-0400 (1)
        openshift.io/ldap.uid: cn=admins,ou=groups,dc=example,dc=com (2)
        openshift.io/ldap.url: LDAP_SERVER_IP:389 (3)
      creationTimestamp:
      name: admins (4)
    users: (5)
    - [email protected]
    - [email protected]
    1 此 AWS 上 Red Hat OpenShift Service 组上次与 LDAP 服务器同步的时间(ISO 6801 格式)。
    2 LDAP 服务器上组的唯一标识符。
    3 存储此组记录的LDAP服务器的IP地址和主机。
    4 同步文件中指定的组名称。
    5 组的成员,名称由同步文件指定。

LDAP嵌套成员关系同步示例

AWS 上的 Red Hat OpenShift 服务中的组不会嵌套。在使用数据之前,LDAP 服务器必须先扁平化组成员关系。Microsoft 的 Active Directory 服务器通过 LDAP_MATCHING_RULE_IN_CHAIN 规则(OID 为 1.2.840.113556.1.4.1941)支持此功能。此外,使用此匹配规则时,只有明确列入白名单的组才能同步。

本节提供增强型 Active Directory 架构的示例,该架构同步名为 admins 的组,该组具有一个用户 Jane 和一个组 otheradmins 作为成员。otheradmins 组具有一名用户成员:Jim。此示例说明:

  • 如何将组和用户添加到 LDAP 服务器。

  • LDAP 同步配置文件的样子。

  • 同步后,AWS 上 Red Hat OpenShift Service 中生成的组记录将是什么。

在增强型 Active Directory 架构中,用户(JaneJim)和组都作为一等实体存在于 LDAP 服务器中,组成员关系存储在用户或组的属性中。以下 ldif 代码片段定义了此架构的用户和组。

使用具有嵌套成员的增强型 Active Directory 架构的 LDAP 条目:augmented_active_directory_nested.ldif
dn: ou=users,dc=example,dc=com
objectClass: organizationalUnit
ou: users

dn: cn=Jane,ou=users,dc=example,dc=com
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: testPerson
cn: Jane
sn: Smith
displayName: Jane Smith
mail: [email protected]
memberOf: cn=admins,ou=groups,dc=example,dc=com (1)

dn: cn=Jim,ou=users,dc=example,dc=com
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: testPerson
cn: Jim
sn: Adams
displayName: Jim Adams
mail: [email protected]
memberOf: cn=otheradmins,ou=groups,dc=example,dc=com (1)

dn: ou=groups,dc=example,dc=com
objectClass: organizationalUnit
ou: groups

dn: cn=admins,ou=groups,dc=example,dc=com (2)
objectClass: group
cn: admins
owner: cn=admin,dc=example,dc=com
description: System Administrators
member: cn=Jane,ou=users,dc=example,dc=com
member: cn=otheradmins,ou=groups,dc=example,dc=com

dn: cn=otheradmins,ou=groups,dc=example,dc=com (2)
objectClass: group
cn: otheradmins
owner: cn=admin,dc=example,dc=com
description: Other System Administrators
memberOf: cn=admins,ou=groups,dc=example,dc=com  (1) (3)
member: cn=Jim,ou=users,dc=example,dc=com
1 用户和组的成员关系列在对象的属性中。
2 组是 LDAP 服务器上的一等实体。
3 otheradmins 组是 admins 组的成员。

使用 Active Directory 同步嵌套组时,必须为用户条目和组条目都提供 LDAP 查询定义,以及在内部 AWS 上 Red Hat OpenShift 服务组记录中表示它们的属性。此外,此配置需要某些更改。

  • oc adm groups sync 命令必须明确列入组的白名单。

  • 用户的 groupMembershipAttributes 必须包含 "memberOf:1.2.840.113556.1.4.1941:" 以符合 LDAP_MATCHING_RULE_IN_CHAIN 规则。

  • groupUIDAttribute 必须设置为 dn

  • groupsQuery

    • 不能设置 filter

    • 必须设置有效的 derefAliases

    • 不应设置 baseDN,因为该值会被忽略。

    • 不应设置 scope,因为该值会被忽略。

为清晰起见,您在AWS上创建的Red Hat OpenShift Service组应尽可能使用与可区分名称不同的属性作为用户或管理员界面字段。例如,通过电子邮件识别AWS上Red Hat OpenShift Service组的用户,并使用组的名称作为通用名称。以下配置文件创建这些关系

使用具有嵌套成员的增强型 Active Directory 架构的 LDAP 同步配置:augmented_active_directory_config_nested.yaml
kind: LDAPSyncConfig
apiVersion: v1
url: ldap://LDAP_SERVICE_IP:389
augmentedActiveDirectory:
    groupsQuery: (1)
        derefAliases: never
        pageSize: 0
    groupUIDAttribute: dn (2)
    groupNameAttributes: [ cn ] (3)
    usersQuery:
        baseDN: "ou=users,dc=example,dc=com"
        scope: sub
        derefAliases: never
        filter: (objectclass=person)
        pageSize: 0
    userNameAttributes: [ mail ] (4)
    groupMembershipAttributes: [ "memberOf:1.2.840.113556.1.4.1941:" ] (5)
1 不能指定 groupsQuery 筛选器。groupsQuery 的 base DN 和 scope 值将被忽略。groupsQuery 必须设置有效的 derefAliases
2 唯一标识 LDAP 服务器上组的属性。它必须设置为 dn
3 用作组名称的属性。
4 用作 AWS 上 Red Hat OpenShift 服务组记录中用户名 的属性。在大多数安装中,首选 mailsAMAccountName
5 存储用户成员信息的用户属性。请注意 LDAP_MATCHING_RULE_IN_CHAIN 的用法。
先决条件
  • 创建配置文件。

  • 您可以作为具有dedicated-admin角色的用户访问集群。

步骤
  • 使用 augmented_active_directory_config_nested.yaml 文件运行同步。

    $ oc adm groups sync \
        'cn=admins,ou=groups,dc=example,dc=com' \
        --sync-config=augmented_active_directory_config_nested.yaml \
        --confirm

    必须显式列入 cn=admins,ou=groups,dc=example,dc=com 组的白名单。

    AWS 上 Red Hat OpenShift Service 将创建以下组记录作为上述同步操作的结果

    使用 augmented_active_directory_config_nested.yaml 文件创建的 AWS 上 Red Hat OpenShift 服务组。
    apiVersion: user.openshift.io/v1
    kind: Group
    metadata:
      annotations:
        openshift.io/ldap.sync-time: 2015-10-13T10:08:38-0400 (1)
        openshift.io/ldap.uid: cn=admins,ou=groups,dc=example,dc=com (2)
        openshift.io/ldap.url: LDAP_SERVER_IP:389 (3)
      creationTimestamp:
      name: admins (4)
    users: (5)
    - [email protected]
    - [email protected]
    1 此 AWS 上 Red Hat OpenShift Service 组上次与 LDAP 服务器同步的时间(ISO 6801 格式)。
    2 LDAP 服务器上组的唯一标识符。
    3 存储此组记录的LDAP服务器的IP地址和主机。
    4 同步文件中指定的组名称。
    5 组的成员用户,名称由同步文件指定。请注意,由于 Microsoft Active Directory 服务器扁平化了组成员关系,因此包含嵌套组的成员。

LDAP 同步配置规范

配置文件的对象规范如下所示。请注意,不同的架构对象具有不同的字段。例如,v1.ActiveDirectoryConfig 没有 groupsQuery 字段,而 v1.RFC2307Config 和 v1.AugmentedActiveDirectoryConfig 都有。

不支持二进制属性。来自 LDAP 服务器的所有属性数据必须为 UTF-8 编码字符串格式。例如,切勿使用二进制属性(例如 objectGUID)作为 ID 属性。必须改为使用字符串属性,例如 sAMAccountNameuserPrincipalName

v1.LDAPSyncConfig

LDAPSyncConfig 包含定义 LDAP 组同步所需的配置选项。

名称 描述 架构

kind

表示此对象表示的 REST 资源的字符串值。服务器可以根据客户端提交请求的端点推断这一点。不可更新。采用驼峰式命名法。更多信息:https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds

字符串

apiVersion

定义此对象表示的版本化架构。服务器应将识别的架构转换为最新的内部值,并可能拒绝无法识别的值。更多信息:https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#resources

字符串

url

主机是用于连接到 LDAP 服务器的方案、主机和端口:scheme://host:port

字符串

bindDN

可选的 DN,用于绑定到 LDAP 服务器。

字符串

bindPassword

在搜索阶段绑定时使用的可选密码。

v1.StringSource

insecure

如果为 true,则表示连接不应使用 TLS。如果为 false,则 ldaps:// URL 使用 TLS 连接,ldap:// URL 将根据 https://tools.ietf.org/html/rfc2830 中的说明升级到 TLS 连接。如果将 insecure 设置为 true,则不能使用 ldaps:// URL 方案。

布尔值

ca

向服务器发出请求时使用的可选受信任证书颁发机构捆绑包。如果为空,则使用默认系统根证书。

字符串

groupUIDNameMapping

LDAP 组 UID 到 AWS 上 Red Hat OpenShift 服务组名称的可选直接映射。

对象

rfc2307

保存用于从以类似于 RFC2307 的方式设置的 LDAP 服务器提取数据的配置:一等组和用户条目,组成员关系由组条目上列出其成员的多值属性确定。

v1.RFC2307Config

activeDirectory

保存用于从以类似于 Active Directory 中使用的 LDAP 服务器提取数据的配置:一等用户条目,组成员关系由成员上列出其所属组的多值属性确定。

v1.ActiveDirectoryConfig

augmentedActiveDirectory

保存用于从以类似于上述 Active Directory 中使用的 LDAP 服务器提取数据的配置,并增加一项:存在一等组条目,用于保存元数据,但不保存组成员关系。

v1.AugmentedActiveDirectoryConfig

v1.StringSource

StringSource 允许内联指定字符串,或通过环境变量或文件外部指定。当它只包含一个字符串值时,它会编组为一个简单的 JSON 字符串。

名称 描述 架构

value

指定明文值,如果指定了 keyFile,则指定加密值。

字符串

env

指定一个环境变量,包含明文值,如果指定了keyFile,则包含加密值。

字符串

文件

引用包含明文值的文件,如果指定了keyFile,则包含加密值。

字符串

keyFile

引用包含用于解密值的关键的文件。

字符串

v1.LDAPQuery

LDAPQuery包含构建LDAP查询所需的选项。

名称 描述 架构

baseDN

所有搜索应从中开始的目录分支的DN。

字符串

scope

搜索的可选范围。可以是base:只有基对象,one:基级别上的所有对象,sub:整个子树。如果未设置,则默认为sub

字符串

derefAliases

关于别名的搜索行为。可以是never:从不取消别名引用,search:仅在搜索中取消别名引用,base:仅在查找基对象时取消别名引用,always:始终取消别名引用。如果未设置,则默认为always

字符串

timeout

保存任何对服务器的请求在放弃等待响应之前可以保持未完成的时间限制(以秒为单位)。如果为0,则不会施加客户端限制。

整数

filter

有效的LDAP搜索过滤器,用于从具有base DN的LDAP服务器检索所有相关条目。

字符串

pageSize

最大首选页面大小(以LDAP条目计)。页面大小为0表示不进行分页。

整数

v1.RFC2307Config

RFC2307Config包含必要的配置选项,用于定义LDAP组同步如何使用RFC2307模式与LDAP服务器交互。

名称 描述 架构

groupsQuery

保存返回组条目的LDAP查询模板。

v1.LDAPQuery

groupUIDAttribute

定义LDAP组条目中哪个属性将被解释为其唯一标识符。(ldapGroupUID

字符串

groupNameAttributes

定义LDAP组条目中哪些属性将被解释为其名称,用于Red Hat OpenShift Service on AWS组。

字符串数组

groupMembershipAttributes

定义LDAP组条目中哪些属性将被解释为其成员。这些属性中包含的值必须可以通过您的UserUIDAttribute查询。

字符串数组

usersQuery

保存返回用户条目的LDAP查询模板。

v1.LDAPQuery

userUIDAttribute

定义LDAP用户条目中哪个属性将被解释为其唯一标识符。它必须与从GroupMembershipAttributes中找到的值相对应。

字符串

userNameAttributes

定义LDAP用户条目中哪些属性将按顺序用作其Red Hat OpenShift Service on AWS用户名。使用第一个具有非空值的属性。这应与您的LDAPPasswordIdentityProviderPreferredUsername设置匹配。用作Red Hat OpenShift Service on AWS组记录中用户名 的属性。在大多数安装中,mailsAMAccountName是首选。

字符串数组

tolerateMemberNotFoundErrors

确定在遇到缺少的用户条目时LDAP同步作业的行为。如果为true,则不会查找任何用户的LDAP查询将被容忍,并且只会记录错误。如果为false,则如果对用户的查询未找到任何内容,则LDAP同步作业将失败。默认值为false。将此标志设置为true的配置错误的LDAP同步作业可能会导致组成员资格被删除,因此建议谨慎使用此标志。

布尔值

tolerateMemberOutOfScopeErrors

确定在遇到范围外的用户条目时LDAP同步作业的行为。如果为true,则对超出所有用户查询给出的base DN的用户进行的LDAP查询将被容忍,并且只会记录错误。如果为false,则如果用户查询将在所有用户查询指定的base DN之外进行搜索,则LDAP同步作业将失败。将此标志设置为true的配置错误的LDAP同步作业可能会导致组缺少用户,因此建议谨慎使用此标志。

布尔值

v1.ActiveDirectoryConfig

ActiveDirectoryConfig包含必要的配置选项,用于定义LDAP组同步如何使用Active Directory模式与LDAP服务器交互。

名称 描述 架构

usersQuery

保存返回用户条目的LDAP查询模板。

v1.LDAPQuery

userNameAttributes

定义LDAP用户条目中哪些属性将被解释为其Red Hat OpenShift Service on AWS用户名。用作Red Hat OpenShift Service on AWS组记录中用户名的属性。在大多数安装中,mailsAMAccountName是首选。

字符串数组

groupMembershipAttributes

定义LDAP用户条目中哪些属性将被解释为其所属的组。

字符串数组

v1.AugmentedActiveDirectoryConfig

AugmentedActiveDirectoryConfig包含必要的配置选项,用于定义LDAP组同步如何使用增强的Active Directory模式与LDAP服务器交互。

名称 描述 架构

usersQuery

保存返回用户条目的LDAP查询模板。

v1.LDAPQuery

userNameAttributes

定义LDAP用户条目中哪些属性将被解释为其Red Hat OpenShift Service on AWS用户名。用作Red Hat OpenShift Service on AWS组记录中用户名的属性。在大多数安装中,mailsAMAccountName是首选。

字符串数组

groupMembershipAttributes

定义LDAP用户条目中哪些属性将被解释为其所属的组。

字符串数组

groupsQuery

保存返回组条目的LDAP查询模板。

v1.LDAPQuery

groupUIDAttribute

定义LDAP组条目中哪个属性将被解释为其唯一标识符。(ldapGroupUID

字符串

groupNameAttributes

定义LDAP组条目中哪些属性将被解释为其名称,用于Red Hat OpenShift Service on AWS组。

字符串数组