1.下载模板文件

wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

修改service模板,新增type:NodePot和nodePort:30443

2.部署

kubectl apply -f recommended.yaml

3.查看pod和服务

kubectl get pods  -n kubernetes-dashboard

4.查看service

kubectl get svc -n kubernetes-dashboard

5.访问路径查看是否部署成功

https://192.168.1.8:30443/#/login

6. 创建访问账户、获取登陆token

vi k8s-dashboard-user.yaml

内容如下

kubectl apply -f  k8s-dashboard-user.yaml

kubectl -n kubernetes-dashboard create token admin-user

 

7.复制上一步获取的token到dashboard登陆页点击登陆按钮

登陆成功