Recently I have provisioned a new EKS cluster (version 1.22) on AWS. After updating the kubeconfig with AWS CLI v2 with the following command:

~# aws eks --region ap-southeast-1 update-kubeconfig --name my-cluster
Added new context arn:aws:eks:ap-southeast-1:<account id>:cluster/my-cluster to /Users/alex/.kube/config

I tried to get the namespaces with the following command and encountered an error:

~# kubectl get ns
error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1"

I googled for a solution and found that this is an issue with aws cli itself (https://github.com/aws/aws-cli/issues/6920).

The solution to fix this issue is to update the cli to the latest version available:

MacOS

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" && sudo installer -pkg AWSCLIV2.pkg -target /

Linux

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install

Others

Please refer to AWS official documentations (https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)

Manual Method

Edit your kubeconfig file and replace client.authentication.k8s.io/v1alpha1 with client.authentication.k8s.io/v1beta1.

After updating the CLI, we will need to update the kubeconfig again by executing the following command:

~# aws eks --region ap-southeast-1 update-kubeconfig --name my-cluster
Added new context arn:aws:eks:ap-southeast-1:<account id>:cluster/my-cluster to /Users/alex/.kube/config

After which, we can perform any operations on our newly provisioned cluster.

~# kubectl get ns
NAME              STATUS   AGE
default           Active   58m
kube-node-lease   Active   58m
kube-public       Active   58m
kube-system       Active   58m