CentOS Stream 9
Sponsored Link

OKD 4 : Identity プロバイダーを設定 : LDAP2022/08/02

 
Identity プロバイダーに LDAP を設定します。
Identity プロバイダーは複数設定可能です。
当例では、HTPasswd Identity プロバイダー設定済みに加えて、LDAP Identity プロバイダーを設定します。
OKD 4 クラスターは以下の通り構成しています。
LDAP サーバーは Windows 2022 Active Directory を利用します。
--------------+----------------+-----------------+--------------
              |10.0.0.25       |                 |10.0.0.24
+-------------+-------------+  |  +--------------+-------------+
|   [mgr.okd4.srv.world]    |  |  | [bootstrap.okd4.srv.world] |
|        Manager Node       |  |  |       Bootstrap Node       |
|           DNS             |  |  |                            |
|          Nginx            |  |  |                            |
+---------------------------+  |  +----------------------------+
                               |
--------------+----------------+-----------------+--------------
              |10.0.0.40       |                 |10.0.0.41
+-------------+-------------+  |  +--------------+-------------+
| [master-0.okd4.srv.world] |  |  |  [master-1.okd4.srv.world] |
|      Control Plane#1      |  |  |      Control Plane#2       | 
|                           |  |  |                            |
|                           |  |  |                            |
+---------------------------+  |  +----------------------------+
                               |
--------------+----------------+-----------------+--------------
              |10.0.0.42                         |10.0.0.100
+-------------+-------------+     +--------------+-------------+
| [master-2.okd4.srv.world] |     |      [fd3s.srv.world]      |
|      Control Plane#3      |     |      Active Directory      | 
|                           |     |                            |
|                           |     |                            |
+---------------------------+     +----------------------------+

[1]
Active Directory 側に、OKD クラスターからの接続用の ドメインユーザーを作成しておきます。
当例では [ldapuser] で進めます。権限は通常の [Domain Users] のみで OK です。
[2] Manager ノードで Identity プロバイダー設定を追加します。
# LDAP シークレットを生成
# [binduserpass] の箇所は 接続用 AD ユーザーのパスワードを指定

[root@mgr ~]#
oc create secret generic ldap-secret --from-literal=bindPassword=binduserpass -n openshift-config

secret/ldap-secret created
[root@mgr ~]#
oc edit oauth cluster
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
  annotations:
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"config.openshift.io/v1","kind":"OAuth","metadata":{"annotations":{},"name":"cluster"},"spec":{"identityProviders":[{"htpasswd":{"fileData":{"name":"htpass-secret"}},"mappingMethod":"claim","name":"HTPasswdIdentityProvider","type":"HTPasswd"}]}}
    release.openshift.io/create-only: "true"
  creationTimestamp: "2022-08-02T05:37:54Z"
  generation: 2
  name: cluster
  ownerReferences:
  - apiVersion: config.openshift.io/v1
    kind: ClusterVersion
    name: version
    uid: d4c7b280-4d13-477d-b271-53f3c0187af6
    resourceVersion: "41842"
  uid: 047a4c8a-f942-47b1-bc36-38202ffb9ffa
spec:
  identityProviders:
  - htpasswd:
      fileData:
        name: htpass-secret
    mappingMethod: claim
    name: HTPasswdIdentityProvider
    type: HTPasswd
  - ldap:
      attributes:
        email:
          - mail
        id:
          - sAMAccountName
        name:
          - displayName
        preferredUsername:
          - cn
      bindDN: ldapuser@srv.world
      bindPassword:
        name: ldap-secret
      insecure: true
      url: >-
        ldap://10.0.0.100:389/ou=LDAPUsers,dc=srv,dc=world?sAMAccountName?sub?(objectClass=*)
    mappingMethod: claim
    name: LdapIdentityProvider
    type: LDAP

# LDAP 用の設定を追記
# [bindDN] : 接続用 AD ユーザーを指定
# [url] : LDAP サーバーと検索範囲
# ⇒ 上例の場合 ベース DN から [LDAPUsers] OU 配下に検索範囲を限定
# [name] : 任意の名称
  こちらを参考に、必要に応じて API トークンを取得しておきます。任意の AD ユーザーでログインできれば OK です。
[3] 任意のクライアントコンピューターから 任意の AD ユーザーでクラスターにログインして確認しておきます。
[centos@client ~]$
oc login -u ADUser01 https://api.okd4.srv.world:6443

The server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y/n): y

Authentication required for https://api.okd4.srv.world:6443 (openshift)
Username: ADUser01
Password:
Login successful.

You don't have any projects. You can try to create a new project, by running

    oc new-project <projectname>

Welcome! See 'oc help' to get started.

[centos@client ~]$
oc whoami

AD User01
関連コンテンツ