Cha*_*tte 0 proxy kubernetes kubectl
我在 kubernetes API 前面添加了一个代理,以便使用自制的身份验证系统对用户进行身份验证(以及其他操作)。
我修改了 kube 配置,让 kubectl 访问代理。代理有自己的 kubeconfig 和有效的证书颁发机构数据,因此我不需要任何凭据。
到目前为止,一切正常,这是我本地需要的最低配置:
clusters:
- cluster:
server: http://localhost:8080
name: proxy
contexts:
- context:
cluster: proxy
name: proxy
current-context: proxy
Run Code Online (Sandbox Code Playgroud)
现在身份验证应该基于令牌,我希望能够将其作为 kubectl 请求标头的一部分进行传递。
我尝试了多种配置,在 kubeconfig 中添加带有令牌的用户,例如
clusters:
- cluster:
server: http://localhost:8080
name: proxy
contexts:
- context:
cluster: proxy
user: robin
name: proxy
current-context: proxy
users:
- name: robin
user:
token: my-token
Run Code Online (Sandbox Code Playgroud)
或者指定一个身份验证提供者,例如
clusters:
- cluster:
server: http://localhost:8080
name: proxy
contexts:
- context:
cluster: proxy
user: robin
name: proxy
current-context: proxy
users:
- name: robin
user:
auth-provider:
config:
access-token: my-token
Run Code Online (Sandbox Code Playgroud)
我什至在没有任何用户的情况下进行了尝试,只需将我的令牌添加为首选项的一部分,因为我想要的只是将令牌放在标头中
clusters:
- cluster:
server: http://localhost:8080
name: proxy
contexts:
- context:
cluster: proxy
name: proxy
current-context: proxy
preferences:
token: my-token
Run Code Online (Sandbox Code Playgroud)
但我始终无法看到 my-token 作为代理端请求标头的一部分。转储请求,我得到的只是:
GET /api/v1/namespaces/default/pods?limit=500 HTTP/1.1
Host: localhost:8080
Accept: application/json;as=Table;v=v1beta1;g=meta.k8s.io, application/json
Accept-Encoding: gzip
User-Agent: kubectl/v1.11.0 (darwin/amd64) kubernetes/91e7b4f
Run Code Online (Sandbox Code Playgroud)
我显然在这里遗漏了一些东西,kubectl 如何不在其标头中传递用户信息?假设我没有代理,“kubectl -> kubernetes”令牌身份验证如何工作?
如果有人有在 kubernetes 和客户端之间添加这种身份验证层的经验,我可以使用一些帮助:)
归档时间: |
|
查看次数: |
1436 次 |
最近记录: |