[英]kubectl versions Error: exec plugin is configured to use API version client.authentication.k8s.io/v1alpha1
I was setting up my new Mac for my eks environment.我正在为我的 eks 环境设置我的新 Mac。 After the installation of kubectl, aws-iam-authenticator and the kubeconfig file placement in default location.
安装 kubectl 后,aws-iam-authenticator 和 kubeconfig 文件放置在默认位置。 I ran the command kubectl command and got this error mentioned below in command block.
我运行命令 kubectl 命令并在命令块中收到下面提到的错误。
My cluster uses v1alpha1 client auth api version so basically i wanted to use the same one in my Mac as well.我的集群使用 v1alpha1 client auth api 版本,所以基本上我也想在我的 Mac 中使用相同的版本。
I tried with latest version (1.23.0) of kubectl as well, still the same error.我也尝试了 kubectl 的最新版本 (1.23.0),仍然是同样的错误。 Whereas When i tried to do with aws-iam-authenticator (version 0.5.5) I was not able to download lower version.
而当我尝试使用 aws-iam-authenticator(版本 0.5.5)时,我无法下载较低版本。
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谢谢和问候,萨拉瓦纳
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
.您正在使用
aws-iam-authenticator
0.5.5
,AWS 将其在0.5.4
中的行为方式更改为需要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
这取决于您的配置,但您可以尝试通过检查您的 kubeconfig 文件(通常在
~/.kube/config
中)从client.authentication.k8s.io/v1alpha1
到v1beta1
将您正在使用的 K8s 上下文更改为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否则切换回
aws-iam-authenticator
0.5.3
- 如果您使用 M1 架构,您可能需要从源代码构建它,因为没有为它构建darwin-arm64
二进制文件
这对我使用 M1 芯片有用
sed -i .bak -e 's/v1alpha1/v1beta1/' ~/.kube/config
I also solved this by updating the apiVersion
value in my kube config file ( ~/.kube/config
).我还通过更新我的 kube 配置文件 (
~/.kube/config
) 中的apiVersion
值解决了这个问题。
client.authentication.k8s.io/v1alpha1
to client.authentication.k8s.io/v1beta1
client.authentication.k8s.io/v1alpha1
到client.authentication.k8s.io/v1beta1
我用下面的命令解决了这个问题
aws eks update-kubeconfig --name mycluster
Also make sure the AWS CLI version is up-to-date.还要确保 AWS CLI 版本是最新的。 Otherwise, AWS IAM Authenticator might not work with v1beta1:
否则,AWS IAM Authenticator 可能无法与 v1beta1 一起使用:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
This might be helpful to fix this issue for those who were using GitHub actions.对于使用 GitHub 操作的用户,这可能有助于解决此问题。 For my situation I was using
kodermax/kubectl-aws-eks
with GitHub actions.对于我的情况,我将
kodermax/kubectl-aws-eks
与 GitHub 操作一起使用。
I added the KUBECTL_VERSION
and IAM_VERSION
environment variables for each steps using kodermax/kubectl-aws-eks
to keep them in fixed versions.我使用
kodermax/kubectl-aws-eks
为每个步骤添加了KUBECTL_VERSION
和IAM_VERSION
环境变量,以将它们保持在固定版本中。
- 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"
Using kubectl 1.21.9 fixed it for me, with asdf:使用 kubectl 1.21.9 为我修复了它,使用 asdf:
asdf plugin-add kubectl https://github.com/asdf-community/asdf-kubectl.git
asdf install kubectl 1.21.9
And I would recommend having a .tools-versions
file with:我建议使用
.tools-versions
文件:
kubectl 1.21.9
This question is a duplicate of error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1" CircleCI这个问题是错误的重复: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1" CircleCI
Please change the authentication apiVersion
from v1alpha1
to v1beta1
.请将
authentication apiVersion
从v1alpha1
更改为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).有时,如果 Kube 缓存损坏(在我的情况下发生),就会发生这种情况。
Deleting and recreating the below folder worked for me.删除和重新创建以下文件夹对我有用。
sudo rm -rf $HOME/.kube && mkdir -p $HOME/.kube
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.