我需要为 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-certificate
和client-key
字段的目的是什么?文件中的注释说“要使用的 webhook 插件的证书”,但是由于这个配置文件是给 API 服务器的,而不是 web 钩子,我不明白这是什么意思。这是一个允许 webhook 服务验证 API 服务器将使用它启动的连接的证书吗?即客户端证书需要进入 webhook 服务器的信任库?
这两个假设都正确吗?