Fix: “error: exec plugin: invalid apiVersion “client.authentication.k8s.io/v1alpha1″”

Have you getting error: exec plugin: invalid apiVersion “client.authentication.k8s.io/v1alpha1”. No worries lot of people facing same error on internet.

Above error can occurred in different scenario like

  1. When you configuring an EKS cluster using terraform in a private subnet and trying to access it using a VPN in a public subnet. When you configured it, it works fine but now when you run kubectl get pods or kubectl get svc, it will through the error: error: exec plugin: invalid apiVersion “client.authentication.k8s.io/v1alpha1”
  2. When you deploy deployment in circleci and running the kubectl cli you will get error between kubectl and the eks tool of the aws-cli. you will get error: exec plugin: invalid apiVersion “client.authentication.k8s.io/v1alpha1”
  3. Update kubectl from v1.23.6 to 1.24.0 and run commands
aws eks update-kubeconfig --name ${EKS_CLUSTER_NAME} --region ${REGION}
kubectl version

you will get error: exec plugin: invalid apiVersion “client.authentication.k8s.io/v1alpha1”

How to Fix “error: exec plugin: invalid apiVersion “client.authentication.k8s.io/v1alpha1″”?

Fix 1: Downgrade the kubectl version

Scenario:

When you configuring an EKS cluster using terraform in a private subnet and trying to access it using a VPN in a public subnet. When you configured it, it works fine but now when you run kubectl get pods or kubectl get svc,

Solution:

Actually its problem with kubectl version 1.24. So, Downgrade to 1.23.6 will fix the issue for now until it is not fixed in kubectl version 1.24

sudo apt install kubectl=1.23.6-00

Fix 2: Update cli version

Scenario:

When you deploy deployment in circleci and running the kubectl cli you will get error between kubectl and the eks tool of the aws-cli.

or

Update kubectl from v1.23.6 to 1.24.0

Solution:

This issue is fixed in the latest version of CLI. So, make sure that you have updated your CLI version to at least 1.23.9 in v1 or 2.6.3 in v2.

You then may need to delete your ~/.kube/config file and run aws eks update-kubeconfig --name [cluster_name] to recreate it as mentioned here.

1. Update aws cli
2. update kub config

pip3 install awscli --upgrade --user
aws eks update-kubeconfig --name ${EKS_CLUSTER_NAME} --region ${REGION}

Conclusion

Now, I have explained the scenario and fixes for both scenario. I am hoping above fixes resolved your issues.

Read More:

Steam Summer Sale is Live now! To Check the Steam Summer Sale Clues Answers, Click Below: