Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Zheaoli/335bba0ad0e49a214c61cbaaa1b20306 to your computer and use it in GitHub Desktop.
Save Zheaoli/335bba0ad0e49a214c61cbaaa1b20306 to your computer and use it in GitHub Desktop.
新版 v1.24.0 kubectl cli 在 aws eks 上使用失效的解决方法.md

Please update your awscli to 2.6.3

In v1.24.0, kubectl will report the following error when relying on the kubeconfig generated by aws-cli

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

The reason is that Kubernetes deprecated client.authentication.k8s.io/v1alpha1" from the exec plugin in PR108616

And the aws-cli update PR6476 has not been merged. There are two solutions

1. Roll back kubectl to any version less than v1.24.0 2. Take MacOS + HomeBrew as an example: 1. Modify "client.authentication.k8s.io/v1alpha1" in your kubeconfig to "client.authentication.k8s.io/v1beta1" 2. Put "client.authentication.k8s.io/ in /usr/local/Cellar/awscli/{awscliVersion}/libexec/lib/python3.9/site-packages/awscli/customizations/eks/get_token.py v1alpha1" changed to "client.authentication.k8s.io/v1beta1"

升级 awscli 到 2.6.3

在 v1.24.0 中,kubectl 在依赖 aws-cli 生成的 kubeconfig 的时候会报错如下

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

原因是,Kubernetes 在 PR108616 中将 client.authentication.k8s.io/v1alpha1"exec plugin 中废弃

而 aws-cli 的更新 PR6476 还没有合并。解决方法有两个

1. 将 kubectl 回退至任意小于 v1.24.0 的版本 2. 以 MacOS + HomeBrew 为例: 1. 修改你 kubeconfig 中的 "client.authentication.k8s.io/v1alpha1" 为 "client.authentication.k8s.io/v1beta1" 2. 将 /usr/local/Cellar/awscli/{awscliVersion}/libexec/lib/python3.9/site-packages/awscli/customizations/eks/get_token.py 中的 "client.authentication.k8s.io/v1alpha1" 修改为 "client.authentication.k8s.io/v1beta1"

@sailakhan74
Copy link

Proper fix for Mac OSX users:

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

I have been facing this issue from past few days and I had a temp workaround. This worked perfectly fine now.

@Nikhil1Raina
Copy link

This helped me perfectly!

@Nikhil1Raina
Copy link

Proper fix for Mac OSX users:

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

This was a really good and perfect help!!!

@medianatraaj
Copy link

it works!!!

@crypto-benko
Copy link

you have to modify the config after upgrading awscli.

Change v1alpha1 to v1beta1:

<             apiVersion: client.authentication.k8s.io/v1beta1
---
>             apiVersion: client.authentication.k8s.io/v1alpha1

@deny4ll
Copy link

deny4ll commented Jul 5, 2022

you have to modify the config after upgrading awscli.

Change v1alpha1 to v1beta1:

<             apiVersion: client.authentication.k8s.io/v1beta1
---
>             apiVersion: client.authentication.k8s.io/v1alpha1

yep, this works!

using kubectl 1.24.2 Darwin arm64

@ariv803
Copy link

ariv803 commented Jul 11, 2022

why is the original post crossed out?

@shashtel
Copy link

shashtel commented Jul 11, 2022

you have to modify the config after upgrading awscli.

Change v1alpha1 to v1beta1:

<             apiVersion: client.authentication.k8s.io/v1beta1
---
>             apiVersion: client.authentication.k8s.io/v1alpha1

Thank you for the suggestion. This worked for me as well.

@emartinsFagundes
Copy link

Proper fix for Mac OSX users:

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

Thank you for the suggestion. This worked for me as well.

@ariv803
Copy link

ariv803 commented Jul 15, 2022

The issue I had was my kubctl command was pointed to the kubernetes included in Docker desktop , so me installing a newer version via homebrew didn't work. Check for this like:

~ % which kubectl  
/usr/local/bin/kubectl
 ~ % ls -la /usr/local/bin/kubectl
lrwxr-xr-x  1 root  wheel  55 Feb 15 14:19 /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl

@mumubin
Copy link

mumubin commented Jul 30, 2022

Don't need downgrade kubectl. Changing kube config to v1beta1 works
sed -i -e "s,client.authentication.k8s.io/v1alpha1,client.authentication.k8s.io/v1beta1,g" ~/.kube/config

@kaushil24
Copy link

Proper fix for Mac OSX users:

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

Worked like a charm!!! 🥳 🥳 🥳

@SilaMi
Copy link

SilaMi commented Aug 3, 2022

Don't need downgrade kubectl. Changing kube config to v1beta1 works sed -i -e "s,client.authentication.k8s.io/v1alpha1,client.authentication.k8s.io/v1beta1,g" ~/.kube/config

Thanks a lot! After updating the awscli, I made a change from alpha to beta and it all worked! And no need to downgrade :)

@hnarimani
Copy link

Proper fix for Mac OSX users:

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

Worked like a charm!!! 🥳 🥳 🥳

@abdul-alaa
Copy link

Proper fix for Mac OSX users:

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

Thanks man worked for me !!

@jjasonwall
Copy link

Thanks so much! This worked for me. Really helped

@jamesrgrinter
Copy link

NB. The "clean" way to update the kubectl/config entry, after updating the installed awscli version to 2.6.3 or beyond, is almost certainly to delete the context and then re-add it, i.e.

$ kubectl config delete-context $cluster_name
$ aws --region="$aws_region" eks update-kubeconfig --name="$cluster_name" --alias="$cluster_name" --profile="$aws_profile"

(adjust the shell variables and/or aws ... eks update-kubeconfig command line to suit your particular needs)

@mukundmckinsey
Copy link

you have to modify the config after upgrading awscli.
Change v1alpha1 to v1beta1:

<             apiVersion: client.authentication.k8s.io/v1beta1
---
>             apiVersion: client.authentication.k8s.io/v1alpha1

Thank you for the suggestion. This worked for me as well.

worked for me! Thanks

@WhatsUpGit
Copy link

Thank you so much!!!

@sunnykr1
Copy link

sunnykr1 commented Nov 7, 2022

Proper fix for Mac OSX users:

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

it worked for me. Thank you so much

@AmirAliyu04
Copy link

how do you update kubeconfig from apiVersion: client.authentication.k8s.io/v1beta1 to apiVersion: client.authentication.k8s.io/v1alpha1

@JGustavo0
Copy link

apiVersion: client.authentication.k8s.io/v1beta1

It worked for me. Thanks 💪.

@Whitilied
Copy link

aws eks update-kubeconfig --name {cluster-name}

@nan-wang
Copy link

nan-wang commented Mar 21, 2023

aws eks update-kubeconfig --name {cluster-name}

this worked for me. Thanks!

@hahmim
Copy link

hahmim commented Apr 18, 2023

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

worked perfectly here as well thank you!!

@tarun-cumulations
Copy link

cd
mv kubectl kubectl_1.24
mv bin bin_1.24
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.23.15/2023-01-11/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin
kubectl version

This helped!

@konark111
Copy link

cd
mv kubectl kubectl_1.24
mv bin bin_1.24
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.23.15/2023-01-11/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin
kubectl version

Thank you so much....finally I was able to connect to eks...

@amarintel
Copy link

you have to modify the config after upgrading awscli.
Change v1alpha1 to v1beta1:

<             apiVersion: client.authentication.k8s.io/v1beta1
---
>             apiVersion: client.authentication.k8s.io/v1alpha1

yep, this works!

using kubectl 1.24.2 Darwin arm64

great, this worked for us !

@DawnSunshine
Copy link

For ubuntu:

1. kubectl Client Version: v1.28.2
2. aws-cli/1.29.50
3. client.authentication.k8s.io/v1alpha1 - > client.authentication.k8s.io/v1beta1

It worked for me.

@Strik3ria
Copy link

In case this would be helpful to anyone not having success with the above recommendations:

My issue ended up being that I had installed awscli with Python 2.7. I uninstalled that version then installed awscli with pip3 instead of just pip and then my problem went away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment