Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl access to Google Cloud Container Engine fails

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

like image 792
P.J.Meisch Avatar asked Nov 28 '22 00:11

P.J.Meisch


1 Answers

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
like image 166
P.J.Meisch Avatar answered Dec 04 '22 01:12

P.J.Meisch