获得用户tonken名称
kubectl get secrets -n kubernetes-dashboard | grep dashboard-admin
#获取详细token
kubectl describe secrets dashboard-admin-token-v8kqn -n kubernetes-dashboar
#修改config,将token放入config
vi /root/.kube/config
将token放入最后一行,与之前格式对齐,输入token:
#赋予用户权限
kubectl create clusterrolebinding test:anonymous —clusterrole=cluster-admin —user=system:anonymous

k8s-token - 图1