配置外部身份验证

KubeSphere 支持设置外部身份验证,平台管理员可以通过 secret(保密字典)配置身份提供者。

配置外部身份提供者后,允许使用 LDAP、CAS、GitHub、阿里云 IDaas、或 OpenID Connect 的用户名和密码登录 KubeSphere Web 控制台。

操作步骤

  1. 以具有 platform-admin 角色的用户登录 KubeSphere Web 控制台。

  2. 点击集群管理,并进入 host 集群。

  3. 在左侧导航栏选择配置 > 保密字典

  4. 在页面点击创建

  5. 创建保密字典对话框,点击右上角的编辑 YAML 开关,使用 yaml 创建保密字典。

  6. 按照以下示例及配置说明修改 yaml 文件,配置完成后,点击创建

  7. 登出 KubeSphere Web 控制台,在登录页面,根据配置的外部身份验证类型,输入 LDAP、CAS、GitHub、阿里云 IDaas、或 OpenID Connect 的用户名和密码登录。

说明

多集群环境中,只需要在主集群中进行配置。

OpenLDAP 示例 yaml

apiVersion: v1
kind: Secret
metadata:
  namespace: kubesphere-system
  name: identity-provider-ldap
  labels:
    config.kubesphere.io/type: identityprovider
stringData:
  configuration.yaml: |
    name: openldap
    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
type: config.kubesphere.io/identityprovider
注意
  • secret 必须创建在 kubeshere-system 项目中。

  • secret 必须包含 type。

    type: config.kubesphere.io/identityprovider

  • secret 必须包含 label。

    config.kubesphere.io/type: identityprovider

配置说明

上述示例的 stringData:configuration.yaml 参数中:

  • name: 指定外部身份验证的名称,必须唯一,否则会创建失败。

  • type: 指定外部身份验证的类型,支持以下类型:

    • LDAP: LDAPIdentityProvider

    • CAS: CASIdentityProvider

    • GitHub: GitHubIdentityProvider

    • 阿里云 IDaas: AliyunIDaaSProvider

    • OpenID Connect: OIDCIdentityProvider

  • mappingMethod: 指定外部身份用户与 KubeSphere 用户的关联方式。

    • auto: 自动创建相同名称的 KubeSphere 用户,当平台中已存在名称时会创建失败。

    • manual: 登录后创建一个任意名称的新用户。

    • lookup: 自动关联已存在的具有相同名称的 KubeSphere 用户,如果不存在该名称的用户,则创建失败。

  • provider: 外部身份验证的具体参数。以下是不同身份验证类型的 provider 参数示例。

    • LDAPIdentityProvider

      host: 192.168.0.2:389
      managerDN: uid=root,cn=users,dc=nas
      managerPassword: "********"
      userSearchBase: cn=users,dc=nas
      loginAttribute: uid
      mailAttribute: mail
    • CASIdentityProvider

      redirectURL: "https://ks-console:30880/oauth/redirect/cas"
      casServerURL: "https://cas.example.org/cas"
      insecureSkipVerify: true
    • OIDCIdentityProvider

      clientID: '********'
      clientSecret: '********'
      issuer: https://accounts.google.com
      redirectURL:  'https://ks-console/oauth/redirect/google'
    • GitHubIdentityProvider

      clientID: '******'
      clientSecret: '******'
      redirectURL: 'https://ks-console/oauth/redirect/github'

    阿里云 IDaaS 身份提供者的配置方法,请参阅阿里云 IDaaS 文档

    使用开源 TOPIAM 集成标准 OIDC 身份提供商配置方法,请参阅 TOPIAM 集成 KubeSphere 文档

通过邮件接收 KubeSphere 最新的技术博客与产品更新的通知


感谢您的反馈。如果您有关于如何使用 KubeSphere 的具体问题,请在 Slack 上提问。如果您想报告问题或提出改进建议,请在 GitHub 存储库中打开问题。