How to generate access token to login

Products

...

Kubernetes Engine

How to generate access token to login

Step 1: You can login to Kubernetes using access token.

To generate access token you need create a service account for Kubernetes dashboard service. To create dashboard service account with the below mentioned yaml file using vi or nano editor.

Text

1
2# kubernetes-dashboard-service-account.yaml
3apiVersion: v1
4kind: ServiceAccount
5metadata:
6 name: kubernetes-dashboard-admin-user
7 namespace: kubernetes-dashboard
8---
9apiVersion: rbac.authorization.k8s.io/v1
10kind: ClusterRoleBinding
11metadata:
12 name: kubernetes-dashboard-admin-user
13roleRef:
14 apiGroup: rbac.authorization.k8s.io
15 kind: ClusterRole
16 name: cluster-admin
17subjects:
18- kind: ServiceAccount
19 name: kubernetes-dashboard-admin-user
20 namespace: kubernetes-dashboard
21---
22apiVersion: v1
23kind: Secret
24type: kubernetes.io/service-account-token
25metadata:
26 name: kubernetes-dashboard-token
27 namespace: kubernetes-dashboard
28 annotations:
29 kubernetes.io/service-account.name: kubernetes-dashboard-admin-user

kubernetes-dashboard-service-account.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
name: kubernetes-dashboard-admin-user
namespace: kubernetes-dashboard


apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard-admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard-admin-user
namespace: kubernetes-dashboard


apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
name: kubernetes-dashboard-token
namespace: kubernetes-dashboard
annotations:
kubernetes.io/service-account.name: kubernetes-dashboard-admin-user



Step 2: Generate the access token using the following command

kubectl apply -f kubernetes-dashboard-service-account.yaml

Following output is generated from the above command



Step 3: Once the token is generated, use the following command to get the access token.

kubectl describe secret $(kubectl get secrets -n kubernetes-dashboard | grep kubernetes-dashboard-token | awk '{print $1}') -n kubernetes-dashboard

Step 4: From the above command, the output generated is given in screenshot below



Copy the generated token & paste it in the dashboard page in the token option as shown below & click on sign in button.



Step 5: On clicking on the sign in option, you will get the kubernetes dashboard.



Docs powered by Archbee

Step 2: Generate the access token using the following command

Step 3: Once the token is generated, use the following command to get the access token.

Step 4: From the above command, the output generated is given in screenshot below

Step 5: On clicking on the sign in option, you will get the kubernetes dashboard.

Press space bar to start a drag.
When dragging you can use the arrow keys to move the item around and escape to cancel.
Some screen readers may require you to be in focus mode or to use your pass through key

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us