死磕k8s系统-dashboard配置
实战
1 | wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml |
查看运行状态
1 | [root@node1 ~]# kubectl get pods -n kubernetes-dashboard |
访问 dashboard
- 通过nginx Ingress 访问。
- 通过kube-proxy 访问。
通过 nginx Ingress 访问 dashboard
1 | cat > dashboard-ingress.yaml <<EOF |
1 | kubectl apply -f dashboard-ingress.yaml |
浏览器访问 URL:https://dashboard.biglittleant.cn
自己配置hosts解析,或者用命令这样验证结果。
curl -I https://dashboard.biglittleant.cn -x 192.168.66.11:80
通过 port forward 访问 dashboard
启动端口转发:
1 | [root@node2 ~]# kubectl port-forward -n kubernetes-dashboard svc/kubernetes-dashboard 4443:443 --address 0.0.0.0 |
浏览器访问 URL:https://192.168.66.12:4443/
如果chrome 浏览器不让访问,可以在chrome该页面上,直接键盘敲入这11个字符:thisisunsafe
创建登录 Dashboard 的 token 和 kubeconfig 配置文件
dashboard 默认只支持 token 认证(不支持 client 证书认证),所以如果使用 Kubeconfig 文件,需要将 token 写入到该文件。
创建登录 token
1 | kubectl create sa dashboard-admin -n kube-system |
使用输出的 token 登录 Dashboard。
创建使用 token 的 KubeConfig 文件
1 | # node1 上操作 |
用生成的 dashboard.kubeconfig 登录 Dashboard。
1 | [root@node1 ~]# sz -y dashboard.kubeconfig |
访问成功的界面
参考文档
Fail to login - Access Control is not helping
Organizing Cluster Access Using kubeconfig Files
Cannot access dashboard with no error
Can’t sign in into dashboard
基于kubernetes集群部署DashBoard
Kubernetes Dashboard
在开启TLS的Kubernetes1.6集群上安装Dashboard
Kubernetes Dashboard 1.7.0部署二三事
报错汇总
k8s自动启动dashboard
1 | "dial tcp 10.0.0.1:443: getsockopt: no route to host" |
1 | systemctl restart flanneld docker |
Ingress 访问 dashboard服务
点击登录,不能实现跳转
Let me have a summary:
if you use recommend yaml to deploy dashboard, you should only access your dashboard by https , and you should generete you certs, refer to guide
then , you can run kubectl proxy –address=’0.0.0.0’ –accept-hosts=’^*$’ to visit dashboard on “http://localhost:8001/ui" . This page need to login use token, generete refer to this page. Also you can add NodePort to you yaml and access to it use :
if you deploy use http alternative method, you can only access your dashboard by
After deploy, you should also generate you token and add header Authorization: Bearer
The offical wiki is a little bit confused so I reordered it here.
解决办法:使用https登陆。