which token to use for kubernetes-dashboard login with Google cloud platform which token to use for kubernetes-dashboard login with Google cloud platform kubernetes kubernetes

which token to use for kubernetes-dashboard login with Google cloud platform


After you connect the cluster with gcloud container clusters get-credentials.Use the following command to get the access token of current-context

kubectl config view | grep -A10 "name: $(kubectl config current-context)" | awk '$1=="access-token:"{print $2}'


gcloud doesn't put the credentials into the kubeconfig but keeps them in its own files.

With GKE you can get a token for your GCloud account - much nicer than repurposing one from a Service Account.

Assuming that you have jq installed you can get your personal access token like this:

gcloud get-credentials <GKE cluster name> --zone <zone> --project <project>gcloud config config-helper --format=json | jq .credential.access_token


I experienced the same issue - in my case the solution was to get the access token from kubectl config view:

[...]users:- name: <YOUR CLUSTER NAME>  user:    auth-provider:      config:        access-token: <YOUR ACCESS TOKEN>        cmd-args: config config-helper --format=json        cmd-path: /usr/local/lib/google-cloud-sdk/bin/gcloud        expiry: 2018-02-12T13:36:51Z        expiry-key: '{.credential.token_expiry}'        token-key: '{.credential.access_token}'      name: gcp[...]