How to generate kubernetes dashboard access token
How to generate kubernetes dashboard access token
1. Create the dashboard service account
Run the following command to create a service account
kubectl create serviceaccount kubernetes-dashboard-admin-sa -n kube-system
The command will create a service account in the namespace of kube-system. replace your namespace instate of kube-system
2. Bind the service account to the cluster-admin role
kubectl create clusterrolebinding kubernetes-dashboard-admin-sa --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard-admin-sa
3. List Secretes
kubectl get secrets -n kube-system
if you using kubernetes 1.23 or above please use following to get secret
kubectl -n kube-system create token kubernetes-dashboard-admin-sa
then you dont have to follow step 4.
4. get the token from secret
kubectl describe secret kubernetes-dashboard-admin-sa-token-lj8cc -n kube-system
Here your secret name can be different. Now copy the token and use it to login kubernetes dashboard.