在 K8S 中运行时,如何在 Elasticsearch 密钥库上添加 oidc 客户端密钥?

时间:2021-04-10 10:08:04

标签: elasticsearch kubernetes

我有一个在 AWS EKS 中运行的自托管 Elasticsearch 集群,我想设置 oidc 身份验证。我按照说明操作:https://www.elastic.co/guide/en/cloud/current/ec-secure-clusters-oidc.html#ec-oidc-client-secret

client-secret 设置中,它提到

You’ll need to add the client secret to the keystore

所以我使用基本身份验证启动了 ES 集群,并使用命令 elasticsearch-keystore add xpack.security.authc.realms.oidc.oidc-realm.rp.client_secret 将密钥添加到密钥库中。

之后我更新 ES yaml 文件以包含配置:

xpack:
  security:
    authc:
      realms:
        oidc:
          oidc-realm-name: 
            order: 2 
            rp.client_id: "client-id" 
            rp.response_type: "code"
            rp.redirect_uri: "<KIBANA_ENDPOINT_URL>/api/security/v1/oidc" 
            op.issuer: "<check with your OpenID Connect Provider>" 
            op.authorization_endpoint: "<check with your OpenID Connect Provider>" 
            op.token_endpoint: "<check with your OpenID Connect Provider>" 
            op.userinfo_endpoint: "<check with your OpenID Connect Provider>" 
            op.jwkset_path: "<check with your OpenID Connect Provider>" 
            claims.principal: sub 
            claims.groups: "http://example.info/claims/groups" 

然后我运行 rollout restart 来重新启动 pod,但在启动 Elasticsearch 集群时出现以下错误:

java.lang.IllegalStateException: security initialization failed
Likely root cause: SettingsException[The configuration setting [xpack.security.authc.realms.oidc.oidc-realm.rp.client_secret] is required]

ES好像没有找到我在Keystore中添加的secret。

然后我意识到当我运行 rollout restart 以应用 oidc 配置时它丢失了密钥库。所以我的问题是在 K8S 的 Elasticsearch 上添加 OIDC 的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

如果您使用 Helm 进行部署,最好的方法是将其添加到图表的值中。 您需要在集群中创建一个密钥,它将由 InitContainer 添加到密钥库中。 More details on the Helm chart README