1. 部署 Dashboard UI
[root@k8s-master ~]# kubectl apply -f
https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recomme
nded.yaml
一般上面的网站访问不了 可以下载我上传的资源DashBoard的recommended.yaml
vim recommended.yaml
复制粘贴我上传的yaml文件
[root@k8s-master01 ~]# kubectl apply -f recommended.yaml
[root@k8s-master01 ~]# kubectl get pod -n kubernetes-dashboard
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-5657497c4c-zh5t5 1/1 Running 0 112s
kubernetes-dashboard-78f87ddfc-96b7l 1/1 Running 0 112s
2.设置访问端口
找到 type: ClusterIP 改为 type: NodePort
[root@k8s-master01 ~]# kubectl edit svc kubernetes-dashboard -n kubernetes-dashboard
访问
3. 创建访问账户
[root@k8s-master01 ~]# vi dashuser.yamlapiVersion: v1
kind: ServiceAccount
metadata:name: admin-usernamespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:name: admin-user
roleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: cluster-admin
subjects:
- kind: ServiceAccountname: admin-usernamespace: kubernetes-dashboard
[root@k8s-master01 ~]# kubectl apply -f dashuser.yaml
4. 令牌访问
[root@k8s-master01 ~]# kubectl apply -f dashuser.yaml
serviceaccount/admin-user created
clusterrolebinding.rbac.authorization.k8s.io/admin-user created
[root@k8s-master01 ~]# kubectl -n kubernetes-dashboard create token admin-user