How to fix kubectl exec plugin invalid apiVersion client.authentication.k8s.io/v1alpha1

In case you are getting an invalid API version error trying to execute any command with kubectl the only fix I can recommend is to downgrade it to an older version

In my experience any execution of kubectl resulted in a following error

error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1"

Double check the current version (if it works)

 kubectl version

if you are at Major:1 and Minor: 24, then you probably need to downgrade to 1.23.6

How to do it on Apple Silicon / M1 or M2

cd /tmp
sudo rm -f /usr/local/bin/kubectl
curl -LO "https://dl.k8s.io/release/v1.23.6/bin/darwin/arm64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
sudo chown root: /usr/local/bin/kubectl
kubectl version

This will install an older version which will solve any issues