Kubernetes suddenly stopped being able to connect to server

10/23/2019

I was successfully able to connect to the kubernetes cluster and work with the services and pods. At one point this changed and everytime I try to connect to the cluster I get the following error:

PS C:\Users\xxx> kubectl get pods
Unable to connect to the server: error parsing output for access token command "C:\\Program Files (x86)\\Google\\Cloud SDK\\google-cloud-sdk\\bin\\gcloud.cmd config config-helper --format=json": yaml: line 4: could not find expected ':'

I am unsure of what the issue is. Google unfortunately doesn't yield any results for me either.

I have not changed any config files or anything. It was a matter of it working one second and not working the next.

Thanks.

-- BURGERFLIPPER101
gcloud
kubernetes

1 Answer

10/23/2019

It looks like the default auth plugin for GKE might be buggy on windows. kubectl is trying to run gcloud to get a token to authenticate to your cluster. If you run kubectl config view you can see the command it tried to run, and run it yourself to see if/why it fails.

As Alexandru said, a workaround is to use Google Application Default Credentials. Actually, gcloud container has built in support for doing this, which you can toggle by setting a property:

gcloud config set container/use_application_default_credentials true Try running this or set environment variable

%CLOUDSDK_CONTAINER_USE_APPLICATION_DEFAULT_CREDENTIALS% to true.

Referenced from here

The workaround for this issue being:

gcloud container clusters get-credentials <cluster-name> If you dont know your cluster name find it by gcloud container clusters list Finally, if those don't have issues, do gcloud auth application-default login and login with relative details

-- DuDoff
Source: StackOverflow