7

This may be an obvious mistake, but it took me a while to figure out (as I'm new to kubernetes), so I'm posting it here to ease the life of others.

Was getting the following error:

D:\>kubectl get pods
error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1beta1"

The kubectl version was:

D:\>kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", 
GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11- 
26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}
error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1beta1"

My kube config file contained:

exec:
  apiVersion: client.authentication.k8s.io/v1beta1

I tried changing apiVersion to v1alpha1, v1,etc. None of that helped with different errors along the way.

Lidia
  • 2,005
  • 5
  • 25
  • 32
  • 1
    Does this answer your question? [error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1" CircleCI](https://stackoverflow.com/questions/72126048/error-exec-plugin-invalid-apiversion-client-authentication-k8s-io-v1alpha1-c) – Dorian Jun 01 '22 at 07:37

2 Answers2

7

The issue was with kubectl version, and in particular with docker desktop installed on the system. When I finally explicitly downloaded version 1.16 but kubectl was still reporting 1.10, it was easy to spot the problem. I moved PATH variable pointing to my kubectl.exe to the front (top) of the PATH, tried in a new CMD window and kubectl worked fine.

Btw, this issue with kubectl being picked up from docker desktop install is noted on the kubectl download site, I just never noticed it.

Lidia
  • 2,005
  • 5
  • 25
  • 32
3

For Mac OSX, the issue can be fixed by doing the following:

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.23.6/bin/darwin/amd64/kubectl

chmod +x ./kubectl

sudo mv ./kubectl /usr/local/bin/kubectl
K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110