2

Hello since yesterday morning I'm running into issues trying to access one of my Kubernetes cluster hosted on Google container engine. I had never had problem until it started to fail but now each kubectl command I try to execute fails by telling "error: failed to negotiate an api version;".

i.e:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.4",
GitCommit:"dd6b458ef8dbf24aff55795baa68f83383c9b3a9", GitTreeState:"clean",
BuildDate:"2016-08-01T16:45:16Z", GoVersion:"go1.6.2", Compiler:"gc",
Platform:"darwin/amd64"}
error: failed to negotiate an api version; server supports: map[], client
supports: map[v1:{} apps/v1alpha1:{} autoscaling/v1:{} componentconfig/v1alpha1:{} 
batch/v1:{} batch/v2alpha1:{} authentication.k8s.io/v1beta1:{} federation/v1beta1:{} 
rbac.authorization.k8s.io/v1alpha1:{} authorization.k8s.io/v1beta1:{} extensions/v1beta1:{} 
policy/v1alpha1:{}]

I have tried to delete then recreate my cluster without success and I made sure the kubernetes version are the same on the server and on the client (1.3.4). I can see the pool of instance running in the google cloud console as well as the cluster when I go to the container engine tab but I have little clue how to proceed from here, can anyone give me some light on what might going on?

Many thanks! Fabrice.

  • Did you set a custom user name (other than admin) when you created your cluster? Did you try to authenticate using a cluster certificate? – George Aug 24 '16 at 20:46

1 Answers1

2

I have been fighting with this issue for a few days, but finally found a solution that worked for me. I wanted to "start over" from the very beginning because I was suspicious that my configuration was broken/"poisoned," but I'm not sure which (if any) of the first 8 steps were truly necessary:

  1. Backup the existing configuration for gcloud and kubectl
    • mv ~/.kube/config ~/.kube/config.old
    • mv ~/.config ~/.config.old
  2. Delete the google cloud sdk
    • rm -rf ~/bin/google-cloud-sdk
  3. Remove the lines from my ~/.bash_profile that were added during the prior installation process using a text editor (one line that sets PATH and one line that enables bash completion)
  4. Download the latest google cloud sdk
  5. Unpack the archive and run the install.sh script
  6. Run gcloud init and follow the instructions it gives
    • I answered "y" for everything (configure for use with google container engine, modify the .bash_profile, and enable bash completion), but minimally you should configure it for use with google container engine
  7. gcloud components install kubectl
  8. gcloud container clusters get-credentials

When I ran kubectl version at this point, I got a different error! This is what I refer to as "progress." Now it told me that "google could not find the default credentials" and to follow the instructions at this page. Briefly:

  1. Create the service account as described, download the .json key, and move it to a directory of your choosing
  2. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path to the key you downloaded
  3. Install the gcloud beta component (gcloud components install beta)
  4. Run gcloud beta auth application-default login

After that, kubectl version worked again! Hope this works for you, too.