1.安装
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml ###卸载使用delete
2.查看Deployment和Service
fxx2@kube-node-1:~$ sudo kubectl --namespace=kubernetes-dashboard get service kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard NodePort 10.107.42.57 <none> 443:32149/TCP 36h
###sudo kubectl --namespace=kubernetes-dashboard get deployment kubernetes-dashboard
3.修改service类型为NodePort
sudo kubectl --namespace=kubernetes-dashboard edit service kubernetes-dashboard
.... selector: k8s-app: kubernetes-dashboard sessionAffinity: None type: NodePort ###此处
....
4.创建Service Account和ClusterRoleBinding
sudo kubectl apply -f dashboard-adminuser.yaml ###如下
fxx2@kube-node-1:~$ cat dashboard-adminuser.yaml 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
5.查看token
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
6.访问
https://<master_ip>:<service_port>,选择使用token登陆。
「 文章如果对你有帮助,请点个赞哦^^ 」 
0
若无特殊注明,文章均为本站原创或整理发布。
转载请注明本文地址:https://om.fangxiaoxiong.com/1856.html