【发布时间】:2018-10-27 17:28:38
【问题描述】:
流程:
带有 api 服务器 (https://192.168.0.10:6443) 负载均衡器 (10.10.0.2) 笔记本电脑的 kubernetes 集群。
想法:
我想从我的笔记本电脑上运行 kubectl 指向负载均衡器,其中 reveres 代理会将我重定向到 api 服务器。
步骤:
- 我将 kubeconfig(在我的笔记本电脑上)文件中的服务器 IP 更改为 LB 的 IP:
是https://192.168.0.10:6443 是http://10.10.0.2:8080/
- 我是这样配置 nginx 的:
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
location / {
proxy_pass https://192.168.0.10:6443;
}
}
现在运行例如 kubectl get nodes 我希望得到节点列表,但它不起作用:
错误:您必须登录到服务器(未经授权)
$ curl http://10.10.0.2:8080/
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "Unauthorized",
"reason": "Unauthorized",
"code": 401
如果我添加到 nginx 配置中:
ssl on;
ssl_certificate /root/certs/admin-k-master-1.pem;
ssl_certificate_key /root/certs/admin-k-master-1-key.pem;
并将 kubeconfig 文件服务器 IP 更改为 https://10.10.0.2:8080/
$ kubect get nodes
Unable to connect to the server: x509: certificate is valid for 192.168.0.10 not 10.10.0.2
有类似的topic,但与kubectl无关。
我怎样才能做到这一点?或者我做错了什么。
【问题讨论】:
标签: kubernetes load-balancing kubectl