Kubernetes 仪表板 - 登录后发生未知服务器错误

Kubernetes Dashboard - Unknown server error after login

我已经通过 Kubespray 成功部署了 Kubernetes,一切似乎都运行良好。我能够通过 kubectl 和列表节点、pods、服务、机密等访问集群。也可以应用新的资源和仪表板端点让我获得仪表板登录页面。

我已经使用不同服务帐户的令牌登录(默认,kubernetes-dashboard,kubernetes-admin,...)......每次登录我都会得到与 中描述的相同的弹出窗口例如。

所以我按照所述为默认服务帐户应用了 clusterrolebinding。当我现在使用默认帐户令牌登录时,我只得到一个

Unknown Server Error (404)
the server could not find the requested resource
Redirecting to previous state in 3 seconds...

box 之后将我重定向到登录页面。如果我通过 kubectl proxy 连接到 Dashboard,其行为相同。访问是通过 public 集群 IP 的 HTTPS 以及通过代理

的 HTTP

我正在使用 Kubernetes 1.16.2 和最新的 Kubespray master commit 18d19d9e

编辑: 我销毁并重新配置了集群以获得一个新的 Kubespray 提供的实例,使所有步骤具有确定性,添加更多信息...

kubectl -n kube-system logs --follow kubernetes-dashboard-556b9ff8f8-jbmgg -- 在登录尝试期间给我

2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Incoming HTTP/2.0 GET /api/v1/csrftoken/login request from 10.233.74.0:57458: { contents hidden }
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Incoming HTTP/2.0 POST /api/v1/login request from 10.233.74.0:57458: { contents hidden }
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Incoming HTTP/2.0 GET /api/v1/login/status request from 10.233.74.0:57458: {}
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Incoming HTTP/2.0 GET /api/v1/csrftoken/token request from 10.233.74.0:57458: {}
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Incoming HTTP/2.0 POST /api/v1/token/refresh request from 10.233.74.0:57458: { contents hidden }
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Incoming HTTP/2.0 GET /api/v1/login/status request from 10.233.74.0:57458: {}
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Incoming HTTP/2.0 GET /api/v1/csrftoken/token request from 10.233.74.0:57458: {}
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Incoming HTTP/2.0 POST /api/v1/token/refresh request from 10.233.74.0:57458: { contents hidden }
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:02 [2019-12-16T12:35:02Z] Incoming HTTP/2.0 GET /api/v1/overview/default?filterBy=&itemsPerPage=10&name=&page=1&sortBy=d,creationTimestamp request from 10.233.74.0:57458: {}
2019/12/16 12:35:03 Getting config category
2019/12/16 12:35:03 Getting discovery and load balancing category
2019/12/16 12:35:03 Getting lists of all workloads
2019/12/16 12:35:03 the server could not find the requested resource
2019/12/16 12:35:03 [2019-12-16T12:35:03Z] Outcoming response to 10.233.74.0:57458 with 404 status code
2019/12/16 12:35:03 No metric client provided. Skipping metrics.
2019/12/16 12:35:03 No metric client provided. Skipping metrics.
2019/12/16 12:35:03 No metric client provided. Skipping metrics.
2019/12/16 12:35:03 Getting pod metrics
2019/12/16 12:35:03 No metric client provided. Skipping metrics.
2019/12/16 12:35:03 No metric client provided. Skipping metrics.
2019/12/16 12:35:03 [2019-12-16T12:35:03Z] Incoming HTTP/2.0 GET /api/v1/systembanner request from 10.233.74.0:57458: {}
2019/12/16 12:35:03 [2019-12-16T12:35:03Z] Incoming HTTP/2.0 GET /api/v1/login/status request from 10.233.74.0:57458: {}
2019/12/16 12:35:03 [2019-12-16T12:35:03Z] Incoming HTTP/2.0 GET /api/v1/rbac/status request from 10.233.74.0:57458: {}
2019/12/16 12:35:03 [2019-12-16T12:35:03Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:03 [2019-12-16T12:35:03Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:03 [2019-12-16T12:35:03Z] Outcoming response to 10.233.74.0:57458 with 200 status code
2019/12/16 12:35:12 Metric client health check failed: the server could not find the requested resource (get services heapster). Retrying in 30 seconds.
2019/12/16 12:35:42 Metric client health check failed: the server could not find the requested resource (get services heapster). Retrying in 30 seconds.

我找到了一个奇怪的解决方法来让仪表板正常工作,但这对我们在生产中不可用,也许有人可以解释一下:

  1. 我以服务帐户 kube-system:default 为例(注意:此时未分配 cluster-admin
  2. 我得到它的令牌并用它登录
  3. 仪表板显然向我显示 "forbidden-popups"
  4. 在登录状态下,我 运行 kubectl create clusterrolebinding default-admin --clusterrole cluster-admin --serviceaccount=kube-system:default
  5. 我刷新了保存我的仪表板会话的浏览器选项卡...等等,一切都正确显示了。

因此我无法注销并再次登录,我总是必须删除 clusterrolebinding,然后登录,然后再次应用 clusterrolebinding。

这似乎与 kubespray 提供的集群密切相关,所以有人可以用 kubespray 重现吗?

如果您使用证书进行连接,您的证书应该在 system:masters 组中 所以包括 "Subject: O=system:masters, CN="

您也可以创建一个Token,然后使用token代替证书:

您的集群角色可能绑定到 "Service Account" 而不是您的组,您应该在 yaml file.Your 服务帐户中检查您的组是否有访问令牌,使用它来验证而不是您的证书。

使用它创建一个令牌并使用它。

kubectl describe secret $(kubectl get secret | grep cluster-admin | awk '{print }')

令牌:

更新 kubeconfig 以使用该令牌而不是您当前使用的证书对您自己进行身份验证,并且您应该成功通过该集群管理服务帐户的身份验证。

好的,这似乎是 Kubespray Github repo issue #5347

中发布的错误