我在 VirtualBox 上创建了一个新的 kubernetes 集群。我有一个主节点和两个工作节点。我想使用仪表板,但出现错误。当我运行kubectl proxy
master 开始监听端口 8001 时:
Starting to serve on 127.0.0.1:8001
然后我在我的主机上创建一个 SSH 隧道:
ssh user@10.10.10.50 -N -L 8001:127.0.0.1:8001
但是当我localhost:8001/ui
在浏览器上输入时,我得到了这个:
{
"paths": [
"/apis",
"/apis/",
"/apis/apiextensions.k8s.io",
"/apis/apiextensions.k8s.io/v1beta1",
"/healthz",
"/healthz/etcd",
"/healthz/ping",
"/healthz/poststarthook/generic-apiserver-start-informers",
"/healthz/poststarthook/start-apiextensions-controllers",
"/healthz/poststarthook/start-apiextensions-informers",
"/metrics",
"/openapi/v2",
"/swagger-2.0.0.json",
"/swagger-2.0.0.pb-v1",
"/swagger-2.0.0.pb-v1.gz",
"/swagger.json",
"/swaggerapi",
"/version"
]
}
如果我想直接通过 api 进入仪表板:
https://10.10.10.50:6443/api/v1/namespaces/kube-system/services
我收到此错误:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "services is forbidden: User \"system:anonymous\" cannot list services in the namespace \"kube-system\"",
"reason": "Forbidden",
"details": {
"kind": "services"
},
"code": 403
}
我知道这与身份验证有关,但我不知道应该如何在集群上定义用户名/密码或在主节点和主机之间共享密钥。或者我应该如何使用 .kube/config 文件中的密钥。