kubectl versions Error: exec plugin is configured to use API version client.authentication.k8s.io/v1alpha1

Viewed 26152

I was setting up my new Mac for my eks environment. After the installation of kubectl, aws-iam-authenticator and the kubeconfig file placement in default location. I ran the command kubectl command and got this error mentioned below in command block.

My cluster uses v1alpha1 client auth api version so basically i wanted to use the same one in my Mac as well.

I tried with latest version (1.23.0) of kubectl as well, still the same error. Whereas When i tried to do with aws-iam-authenticator (version 0.5.5) I was not able to download lower version.

Can someone help me to resolve it?

% kubectl version          
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"darwin/amd64"}
Unable to connect to the server: getting credentials: exec plugin is configured to use API version client.authentication.k8s.io/v1alpha1, plugin returned version client.authentication.k8s.io/v1beta1

Thanks and Regards, Saravana

8 Answers

I have the same problem

You're using aws-iam-authenticator 0.5.5, AWS changed the way it behaves in 0.5.4 to require v1beta1.

It depends on your configuration, but you can try to change the K8s context you're using to v1beta1 by checking your kubeconfig file (usually in ~/.kube/config) from client.authentication.k8s.io/v1alpha1 to client.authentication.k8s.io/v1beta1

Otherwise switch back to aws-iam-authenticator 0.5.3 - you might need to build it from source if you're using the M1 architecture as there's no darwin-arm64 binary built for it

This worked for me using M1 chip

sed -i .bak -e 's/v1alpha1/v1beta1/' ~/.kube/config

I fixed the issue with command below

aws eks update-kubeconfig --name mycluster 

I also solved this by updating the apiVersion value in my kube config file (~/.kube/config).

client.authentication.k8s.io/v1alpha1 to client.authentication.k8s.io/v1beta1

This might be helpful to fix this issue for those who were using GitHub actions. For my situation I was using kodermax/kubectl-aws-eks with GitHub actions.

I added the KUBECTL_VERSION and IAM_VERSION environment variables for each steps using kodermax/kubectl-aws-eks to keep them in fixed versions.

  - name: deploy to cluster
    uses: kodermax/kubectl-aws-eks@master
    env:
      KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA_STAGING }}
      ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
      ECR_REPOSITORY: my-app
      IMAGE_TAG: ${{ github.sha }
      KUBECTL_VERSION: "v1.23.6"
      IAM_VERSION: "0.5.3"

Please change the authentication apiVersion from v1alpha1 to v1beta1.

Old

apiVersion: client.authentication.k8s.io/v1alpha1

New

apiVersion: client.authentication.k8s.io/v1beta1

Sometimes this can happen if the Kube cache is corrupted (which happened in my case).

Deleting and recreating the below folder worked for me.

sudo rm -rf $HOME/.kube && mkdir -p $HOME/.kube
Related