Search code examples
kubernetesgoogle-kubernetes-engine

kubectl: Unsuccessful API Version Negotiation (google-kubernetes-engine)


I'm facing difficulties while trying to access one of my Kubernetes. I encounter an error message stating the following whenever I execute the kubectl command:

error: failed to negotiate an API version

Could someone help me comprehend what could have gone wrong?

Despite my efforts to troubleshoot this problem, I've been unable to resolve the issue on my own.


Solution

  • When you are running kubectl command and you are getting an error: failed to negotiate an api version because this command needs to be authenticated.

    Follow the two workarounds and have a try :

    • As per this doc , you need to Ensure kubectl has authentication credentials:
           gcloud auth application-default login
    
    • You can also try below :
           Install the gcloud beta component (gcloud components install beta)
           Run gcloud beta auth application-default login
          After that, the kubectl version will work.
    

    Refer to this doc for more information