官网
https://kubernetes.io/zh-cn/docs/tasks/access-application-cluster/web-ui-dashboard/
一、下载资源清单文件
- 上述官网提供的地址无法访问,所以无法直接部署
#官方给的地址
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.1/aio/deploy/recommended.yaml
-
需要到GitHub上下载,解压后,获得recommend.yaml
https://github.com/kubernetes/dashboard/releases -
修改recommend.yaml中name为:kubernetes-dashboard 的Service资源,增加NodePort
二、安装
kubectl apply -f recommend.yaml
三、访问
四、创建dashboard服务账号
官网介绍:https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
获取token
kubectl create token admin-user -n kubernetes-dashboard
清理操作
-
删除ServiceAccount
kubectl delete serviceaccount admin-user -n kubernetes-dashboard
-
删除ClusterRoleBinding
kubectl delete clusterrolebinding admin-user -n kubernetes-dashboard