LDAP身份提供者
本文档描述了如何使用 LDAP 服务作为外部身份提供者,允许您根据 LDAP 服务对用户进行身份验证。
准备工作
- 您需要部署一个 Kubernetes 集群,并在集群中安装 KubeSphere。有关详细信息,请参阅在 Linux 上安装和在 Kubernetes 上安装。
- 您需要获取 LDAP 服务的管理员专有名称(DN)和管理员密码。
步骤
以
admin身份登录 KubeSphere,将光标移动到右下角
,点击 kubectl,然后执行以下命令来编辑 CRD ClusterConfiguration中的ks-installer:kubectl -n kubesphere-system edit cc ks-installer示例:
spec: authentication: jwtSecret: '' maximumClockSkew: 10s multipleLogin: true oauthOptions: accessTokenMaxAge: 1h accessTokenInactivityTimeout: 30m identityProviders: - name: LDAP type: LDAPIdentityProvider mappingMethod: auto provider: host: 192.168.0.2:389 managerDN: uid=root,cn=users,dc=nas managerPassword: ******** userSearchBase: cn=users,dc=nas loginAttribute: uid mailAttribute: mail在
spec:authentication部分配置oauthOptions:identityProviders以外的字段信息请参阅设置外部身份认证。在
oauthOptions:identityProviders部分配置字段。name: 用户定义的 LDAP 服务名称。type: 必须将该值设置为LDAPIdentityProvider才能将 LDAP 服务用作身份提供者。mappingMethod: 帐户映射方式,值可以是auto或者lookup。- 如果值为
auto(默认),需要指定新的用户名。KubeSphere 根据用户名自动创建并关联 LDAP 用户。 - 如果值为
lookup,需要执行步骤 4 以手动关联现有 KubeSphere 用户和 LDAP 用户。
- 如果值为
provider:host: LDAP 服务的地址和端口号。managerDN: 用于绑定到 LDAP 目录的 DN 。managerPassword:managerDN对应的密码。userSearchBase: 用户搜索基。设置为所有 LDAP 用户所在目录级别的 DN 。loginAttribute: 标识 LDAP 用户的属性。mailAttribute: 标识 LDAP 用户的电子邮件地址的属性。
如果
mappingMethod设置为lookup,可以运行以下命令并添加标签来进行帐户关联。如果mappingMethod是auto可以跳过这个部分。kubectl edit user <KubeSphere username>labels: iam.docs.kubesphere-carryon.top/identify-provider: <LDAP service name> iam.docs.kubesphere-carryon.top/origin-uid: <LDAP username>字段配置完成后,保存修改,然后等待 ks-installer 完成重启。
备注
KubeSphere Web 控制台在 ks-installer 重新启动期间不可用。请等待重启完成。如果您使用 KubeSphere 3.2.0,请在配置 LDAP 之后执行以下命令并等待至
ks-installer成功运行:kubectl -n kubesphere-system set image deployment/ks-apiserver *=kubesphere/ks-apiserver:v3.2.1备注
如果您使用 KubeSphere 3.2.1,请跳过该步骤。进入KubeSphere登录页面,输入 LDAP 用户的用户名和密码登录。
备注
LDAP 用户的用户名是loginAttribute指定的属性值。
反馈
这篇文章对您有帮助吗?
通过邮件接收 KubeSphere 最新的技术博客与产品更新的通知
感谢您的反馈。如果您有关于如何使用 KubeSphere 的具体问题,请在 Slack 上提问。如果您想报告问题或提出改进建议,请在 GitHub 存储库中打开问题。
页面内容