kubectl access to Google Cloud Container Engine fails

11/4/2016

In Google Cloud Platform I have a Container-Cluster with three running instances. I now want to connect from my terminal to be able to run kubectl commands. For this I ran the command

gcloud container clusters get-credentials cluster-1 --zone europe-west1-b --project project-id

I am using the real project name of course. This is the command shown by the dashboard when clicking on 'connect with the cluster'. The output of this command is:

Fetching cluster endpoint and auth data.
kubeconfig entry generated for cluster-1.

But when I run kubectlcommands afterwards like kubectl cluster-info I always get:

Unable to connect to the server: oauth2: cannot fetch token: 400 Bad Request
Response: {
  "error" : "invalid_grant",
  "error_description" : "Token has been revoked."
}

What am I missing here? gcloud commands like gcloud container clusters list work

-- P.J.Meisch
gcloud
google-kubernetes-engine
kubectl
kubernetes

1 Answer

11/4/2016

I tried from a different machine at home, and there it was working after installing and setting up gcloud. I think that on my work machine there is still an oauth token stored with which I authenticated to a different google account I used for a test.

Edit: I got it running now. the problem was that I missed the second of the necessary calls:

gcloud auth login
gcloud auth application-default login
-- P.J.Meisch
Source: StackOverflow