kubernetes部署dashboard
下载dashboard资源清单文件
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
下载不了直接访问网址复制粘贴
修改recommended.yaml文件
创建pod
kubectl create -f recommended.yaml
[root@k8s-master dashboard]# kubectl get svc -n kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dashboard-metrics-scraper ClusterIP 10.110.7.250 <none> 8000/TCP 131m
kubernetes-dashboard NodePort 10.99.209.27 <none> 443:30001/TCP 131m
网页打开
https://nodeip:30001
token从下面步骤中生成填写
eyJhbGciOiJSUzI1NiIsImtpZCI6IjB2MExlc1ZWMm8wZGstU09OTlZLc1U4aDF6MGx6alBYN1BLWVdWQkhINE0ifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tbGhiOGwiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiZDU1ZjUxMDUtMWI3MC00NDFmLWE4YjgtOTMxZTRjY2ExMzFjIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmVybmV0ZXMtZGFzaGJvYXJkOmRhc2hib2FyZC1hZG1pbiJ9.zLdWBB9-lEDWyyUzyprh2Yab6FfZycEA2zoqehSDkGGyxx9dXEHMNxuJWIT2rrioo3q0Kpr8LZv0Vn2afVW3satyw4p_AxRvufnFjMlEJNfhT1P6ar6Jf7rSXUPotBl7DV0kH_PXL4zNpSZ4bt5P55OyRlUbmDZ161nwz3tZNQ8ePNRN-50Tw0MpJEM9LE4jB7eAxRRMYwXVmmA8hIxnDNC9faHaiBS-VFEWXC74LY9N5Jn9QqcPMvanjKmwF-TYPewiupKBgN0HQAnefN148PlzgAcEiXUF1DJHayxrY8R7ln2n-XX0hv6rKV8A_-CaUqImjQ4n2m8qvN6aAm4LOg
token生成如下
[root@k8s-master dashboard]# kubectl create serviceaccount admin-user -n kubernetes-dashboard
serviceaccount/admin-user created
[root@k8s-master dashboard]# kubectl create clusterrolebinding admin-user --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:admin-user
clusterrolebinding.rbac.authorization.k8s.io/admin-user created
[root@k8s-master dashboard]# kubectl -n kubernetes-dashboard get secrets
NAME TYPE DATA AGE
admin-user-token-q8l2j kubernetes.io/service-account-token 3 115m
dashboard-admin-token-lhb8l kubernetes.io/service-account-token 3 106m
default-token-bcjt2 kubernetes.io/service-account-token 3 117m
kubernetes-dashboard-certs Opaque 0 117m
kubernetes-dashboard-csrf Opaque 1 117m
kubernetes-dashboard-key-holder Opaque 2 117m
kubernetes-dashboard-token-wfp8z kubernetes.io/service-account-token 3 117m
#选择dashboard-admin-token-lhb8l
[root@k8s-master dashboard]# kubectl -n kubernetes-dashboard describe secrets dashboard-admin-token-lhb8l | grep token | awk '{print $2}'
dashboard-admin-token-lhb8l
kubernetes.io/service-account-token
eyJhbGciOiJSUzI1NiIsImtpZCI6IjB2MExlc1ZWMm8wZGstU09OTlZLc1U4aDF6MGx6alBYN1BLWVdWQkhINE0ifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tbGhiOGwiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiZDU1ZjUxMDUtMWI3MC00NDFmLWE4YjgtOTMxZTRjY2ExMzFjIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmVybmV0ZXMtZGFzaGJvYXJkOmRhc2hib2FyZC1hZG1pbiJ9.zLdWBB9-lEDWyyUzyprh2Yab6FfZycEA2zoqehSDkGGyxx9dXEHMNxuJWIT2rrioo3q0Kpr8LZv0Vn2afVW3satyw4p_AxRvufnFjMlEJNfhT1P6ar6Jf7rSXUPotBl7DV0kH_PXL4zNpSZ4bt5P55OyRlUbmDZ161nwz3tZNQ8ePNRN-50Tw0MpJEM9LE4jB7eAxRRMYwXVmmA8hIxnDNC9faHaiBS-VFEWXC74LY9N5Jn9QqcPMvanjKmwF-TYPewiupKBgN0HQAnefN148PlzgAcEiXUF1DJHayxrY8R7ln2n-XX0hv6rKV8A_-CaUqImjQ4n2m8qvN6aAm4LOg