K8s - 解决Dashboard无法启动问题(Minikube搭建的集群)
作者:hangge | 2021-05-12 08:10
1,问题描述
(1)使用 Minikube 在 CentOS 7 虚拟系统下搭建了一个 Kubernetes 集群,但执行 minikube dashboard 启动 Dashboard 时一直卡在“正在验证 proxy 运行状况 ...”
(2)改用如下命令启动 Dashboard 可以显示更详细信息:
(3)可以发现启动一直报 503 错误,然后不断地重试:
minikube dashboard --alsologtostderr -v=1
(3)可以发现启动一直报 503 错误,然后不断地重试:
http://127.0.0.1:46862/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ response: <nil> &{Status:503 Service Unavailable StatusCode:503 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Cache-Control:[no-cache, private] Content-Length:[188] Content-Type:[application/json] Date:[Thu, 29 Apr 2021 09:26:00 GMT]] Body:0xc0002c7640 ContentLength:188 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc0002c8800 TLS:<nil>}
I0429 17:26:00.108030 3912 retry.go:30] will retry after 644.295µs: Temporary Error: unexpected response code: 503
(4)执行如下命令查看所有的 Pod,发现 kubernetes-dashboard 一直没启动成功,在不断地重试:
kubectl get pods --all-namespaces
(5)执行如下命令查看该 Pod 的 log:
(6)发现是路由问题:
kubectl logs --namespace=kubernetes-dashboard kubernetes-dashboard-7b65b89587-84wl8
(6)发现是路由问题:
panic: Get "https://10.96.0.1:443/api/v1/namespaces/kubernetes-dashboard/secrets/kubernetes-dashboard-csrf": dial tcp 10.96.0.1:443: connect: no route to host
goroutine 1 [running]:
github.com/kubernetes/dashboard/src/app/backend/client/csrf.(*csrfTokenManager).init(0xc000147440)
/home/runner/work/dashboard/dashboard/src/app/backend/client/csrf/manager.go:41 +0x446
github.com/kubernetes/dashboard/src/app/backend/client/csrf.NewCsrfTokenManager(...)
2,解决办法
(1)依次执行如下命令刷新 iptables,并重启相关服务:
systemctl stop kubelet systemctl stop docker iptables --flush iptables -tnat --flush systemctl start kubelet systemctl start docker
(2)稍等一会后 kubernetes-dashboard 这个 Pod 便会启动成功,然后执行 minikube dashboard 即可启动 Dashboard。
全部评论(0)