Tuesday, 13 March 2018

Login to Kubernetes dashboard using token


Aim:

Steps to login to Kubernetes dashboard using Token.

Steps:

Kubernetes dashboard login page will look like below:


You have the option to log in to Kubernetes dashboard using 'Kubeconfig' or 'Token' method.

If you want to login using 'Token', to get the required token value, execute following commands:

kubectl get secrets

To get secrets in a specific namespace, say 'kube-system', execute following:

kubectl get secrets -n kube-system

This will display all the secrets in namespace 'kube-system'.

[root@vmdocc7176 ~]# kubectl get secrets -n kube-system
NAME                                             TYPE                                  DATA      AGE
attachdetach-controller-token-db5cj              kubernetes.io/service-account-token   3         1h
bootstrap-signer-token-xg79w                     kubernetes.io/service-account-token   3         1h
bootstrap-token-446d7b                           bootstrap.kubernetes.io/token         7         1h
calico-cni-plugin-token-ql769                    kubernetes.io/service-account-token   3         1h
calico-kube-controllers-token-2gz6p              kubernetes.io/service-account-token   3         1h
certificate-controller-token-rcfh2               kubernetes.io/service-account-token   3         1h
clusterrole-aggregation-controller-token-9bn58   kubernetes.io/service-account-token   3         1h
cronjob-controller-token-trcnj                   kubernetes.io/service-account-token   3         1h
daemon-set-controller-token-6vjm8                kubernetes.io/service-account-token   3         1h
default-token-74gbh                              kubernetes.io/service-account-token   3         1h
deployment-controller-token-5cxg6                kubernetes.io/service-account-token   3         1h
disruption-controller-token-fvm5w                kubernetes.io/service-account-token   3         1h
endpoint-controller-token-t78ds                  kubernetes.io/service-account-token   3         1h

To print token for a specific secret, execute the following command:

kubectl describe secret <secret_name>

For example to print token for 'default-token-74gbh' secret in namespace 'kube-system', execute the following command:

kubectl -n kube-system describe secret default-token-74gbh

Copy the token value from the above output and paste to kubernetes login page.


You will have privileges according to the token used.

No comments:

Post a Comment