2

我需要为 Kubernetes 实现一个自定义的身份验证和授权模块。这必须通过网络挂钩来完成。

身份验证授权webhook的文档描述了 API 服务器需要启动的配置文件。

对于身份验证和授权,配置文件看起来相同,如下所示:

# clusters refers to the remote service.
clusters:
  - name: name-of-remote-authn-service
    cluster:
      certificate-authority: /path/to/ca.pem         # CA for verifying the remote service.
      server: https://authn.example.com/authenticate # URL of remote service to query. Must use 'https'.

# users refers to the API server's webhook configuration.
users:
  - name: name-of-api-server
    user:
      client-certificate: /path/to/cert.pem # cert for the webhook plugin to use
      client-key: /path/to/key.pem          # key matching the cert

# kubeconfig files require a context. Provide one for the API server.
current-context: webhook
contexts:
- context:
    cluster: name-of-remote-authn-service
    user: name-of-api-sever
  name: webhook

我可以看到该clusters部分指的是远程服务,即它定义了 webhook,从而回答了 API 服务器需要回答的问题:“当需要 authn/authz 决策时,要命中的 URL 端点是什么,当我通过 HTTPS 连接,谁是 Webhook 的 TLS 证书的 CA 机构,以便我知道我可以信任远程 Webhook?”

我不确定该users部分。client-certificateclient-key字段的目的是什么?文件中的注释说“要使用的 webhook 插件的证书”,但是由于这个配置文件是给 API 服务器的,而不是 web 钩子,我不明白这是什么意思。这是一个允许 webhook 服务验证 API 服务器将使用它启动的连接的证书吗?即客户端证书需要进入 webhook 服务器的信任库?

这两个假设都正确吗?

4

1 回答 1

0

Kubernetes webhook 使用双向 SSL 身份验证,因此users部分中的字段用于配置“客户端身份验证”的证书。

clusters部分配置只是正常工作的一种 SSL 身份验证方式,即服务器(这里是您的 webhook 模块)将使用配置的证书验证客户端(这里是 Kubernetes)的请求。

只要您在users部分配置证书,客户端(Kubernetes)就可以验证服务器(webhook 模块)的响应,就像单向 SSL 的反向 CA 身份验证一样。

于 2017-11-28T01:20:49.977 回答