Failed to connect to Google Container Engine

I have updated gcloud to the latest version (159.0.0)

I created a Google Container Engine node and then followed the instructions in the prompt.

gcloud container clusters get-credentials prod --zone us-west1-b --project myproject

Fetching cluster endpoint and auth data.
kubeconfig entry generated for prod

kubectl proxy
Unable to connect to the server: error executing access token command 
"/Users/me/Code/google-cloud-sdk/bin/gcloud ": exit status 

      

Any idea why it can't connect?

+3


source to share


2 answers


You can try running to make sure the config was generated correctly:

kubectl config view 

      

I had a similar issue when trying to run kubectl commands on a new Kubernetes cluster that was just created on Google Cloud Platform.

The solution for my case was to activate the default Credentials for the google app .



You can find the link below on how to activate it.

Basically, you need to set the environment variable to the .json path with credentials from GCP GOOGLE_APPLICATION_CREDENTIALS -> c:\...\..\..Credentials.json

exported from Google Cloud https://developers.google.com/identity/protocols/application-default-credentials

I found this solution on kuberenetes github issue: https://github.com/kubernetes/kubernetes/issues/30617

PS: make sure you also set environment variables for:% HOME% to% USERPROFILE%% KUBECONFIG% to% USERPROFILE%

+4


source


It looks like the default plugin for GKE doesn't work by default on windows. kubectl tries to start gcloud to get an authentication token on your cluster. If you run kubectl config view

, you will see the command it tried to run and run it yourself to see if / why it fails.

As Alexandru said, the workaround is to use the default credentials for google apps. In fact, gcloud container has created support for this, which you can switch by setting the property:

gcloud config set container/use_application_default_credentials true



or set an environment variable

%CLOUDSDK_CONTAINER_USE_APPLICATION_DEFAULT_CREDENTIALS%

before true

.

+3


source







All Articles