获取资源编排文件

wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta1/aio/deploy/recommended.yaml --no-check-certificate

 

更换此文件中的namespace为:kube-system

sed -i '/namespace/ s/kubernetes-dashboard/kube-system/g' recommended.yaml

 

recommanded.yaml的40行和44行添加如下内容:

 

启动k8s dashboard

docker pull kubernetesui/dashboard:v2.0.0-beta1 
kubectl apply -f recommended.yaml 
kubectl get pods,svc -n kube-system

 

访问:https://192.168.71.101:30001/

 

创建管理员用户,并获取token

kubectl create serviceaccount dashboard-admin -n kube-system 
kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin 

#查找管理员用户的token名字 
kubectl get secret -n kube-system |grep dashboard-admin

显示以下内容:

[root@k8smaster ~]# kubectl get secret -n kube-system |grep dashboard-admin 
dashboard-admin-token-n2jdf kubernetes.io/service-account-token 3 50s

 

获取token值:

kubectl describe secret dashboard-admin-token-n2jdf -n kube-system

 

输出:

[root@k8smaster ~]# kubectl describe secret dashboard-admin-token-n2jdf -n kube-system
Name:         dashboard-admin-token-n2jdf
Namespace:    kube-system
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: dashboard-admin
              kubernetes.io/service-account.uid: 0df63166-71d2-4f03-8b1a-8e0ee7ec610a

Type:  kubernetes.io/service-account-token

Data
====
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6Ii1EN05YU0d4d0J4c1FzdDU1eUF5YTh3THoydC1NMktMS0tpUWVjckJtQVUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tbjJqZGYiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiMGRmNjMxNjYtNzFkMi00ZjAzLThiMWEtOGUwZWU3ZWM2MTBhIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.TOHvgMA_iLGlgB7xx3Jk6CTHuUDS7VWZc7w6iZgkXQhYdeMs4SSMIgyIk0aNvv8KVyH0M8eB6kwSx9RXOIdfMn4vMQqErHZF9pLWC1JkudCk7gsb9oe1uFHIsvJAy0vJVd9ebp4E9f6ScN-dzxaMb7d3e11DHurMthLXJl9GPmizh0C5qNDre6-U0VRlbNI328qLNo6ebXlE2wHVxbA-8dU3ub9KlekwOy32Ww5bOS0DFqKyuDDG1AMgST51IA1m6hvz1XK_B2iqROr2XUcxXQatF2X1hvFlRGV63G1Nxcji-5kwtgs0wpjOnGh1YfoXCXY0giCIW9HjrhBp_9xRkQ

访问:https://192.168.71.101:30001/,输入token即可。谷歌浏览器可能会有问题,火狐亲测可行

 

 

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐