linux - 服务被禁止:用户 \"system:anonymous\" 无法列出命名空间 \"kube-system\ 中的服务
问题描述
我在 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 文件中的密钥。
解决方案
我想使用仪表板,但出现错误。
根据仪表板文档的摘录,成功默认安装仪表板后(默认仪表板部署包含运行所需的最小 RBAC 权限集):
要从本地工作站访问 Dashboard,您必须为 Kubernetes 集群创建一个安全通道。运行以下命令:
kubectl proxy
现在访问仪表板:
http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
无需进行隧道或任何其他更改。到目前为止,仪表板的默认安装总是像一个魅力,如果你有任何单独配置,那么可能会有一些问题......
推荐阅读
- docusignapi - 实现docusign connect api
- python - 如何将字符串转换为csv文件中的浮点数
- javascript - 所有数组值都相同时的拼接问题
- c# - .Net Core 3 worker 服务应用程序,带有带有参数的构造函数的插件
- powershell - 过滤大型 CSV 文件时出现内存异常
- tomcat - Tomcat 错误 404:源服务器没有找到目标资源的当前表示或不愿意透露存在的表示
- python - 如何在sklearn中获得isolationforest的顶级预测
- c - 无法在 CodeBlocks 上编译 C 程序:未定义对“WinMain@16”的引用
- javascript - Node 可以并行运行多个文件读取流吗?
- regex - Linux用连续数字替换特定字符串