If you’re ended up choosing this option to log in to your Kubernetes dashboard but don’t know how, this post helps you out with that.
Create a Service Account
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
kubectl apply -f dashboard-adminuser.yml
serviceaccount/admin-user created
Create ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kube-system
kubectl apply -f admin-role-binding.yml
clusterrolebinding.rbac.authorization.k8s.io/admin-user created
Get the Access Token
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
Name: admin-user-token-mqgx6
Namespace: kube-system
Labels:
Annotations: kubernetes.io/service-account.name: admin-user
kubernetes.io/service-account.uid: 132a8df1-139b-4e27-85e1-eb9b6e99cd48
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1720 bytes
namespace: 11 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6ImVjQ1JBOXJEUjFLUlFKS ....
Login
Select the token option, copy the token from the terminal and paste it there: