Kubernetes-dashboard安裝、配置令牌和kubeconfig登陸

安裝dashboardnode

kubectl apply -f  https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
修改nodePortgit

kubectl patch svc -n kube-system kubernetes-dashboard -p '{"spec":{"type":"NodePort"}}'github

建立dashboard管理用戶json

kubectl create serviceaccount dashboard-admin -n kube-systemapp

綁定用戶爲集羣管理用戶jsonp

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

也可綁定爲普通角色.net

一、獲取tockenserver

kubectl describe secret -n kube-system dashboard-admintoken

在dashboard後臺使用tocken(令牌)方式登陸便可

二、生成kubeconfig文件

DASH_TOCKEN=$(kubectl get secret -n kube-system dashboard-admin-token-l7kpn -o jsonpath={.data.token}|base64 -d)

kubectl config set-cluster kubernetes --server=192.168.0.25:6443 --kubeconfig=/root/dashbord-admin.conf

kubectl config set-credentials dashboard-admin --token=$DASH_TOCKEN --kubeconfig=/root/dashbord-admin.conf

kubectl config set-context dashboard-admin@kubernetes --cluster=kubernetes --user=dashboard-admin --kubeconfig=/root/dashbord-admin.conf

kubectl config user-context dashboard-admin@kubernets --kubeconfig=/root/dashbord-admin.conf

生成的dashbord-admin.conf便可用於登陸dashboard

相關文章
相關標籤/搜索