简体   繁体   English

kubectl 版本错误:exec 插件配置为使用 API 版本 client.authentication.k8s.io/v1alpha1

[英]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/v1alpha1v1beta1将您正在使用的 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/v1alpha1client.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_VERSIONIAM_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 apiVersionv1alpha1更改为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.

相关问题 “无法检索服务器 API 的完整列表:tap.linkerd.io/v1alpha1”在 GKE 中的私有集群上使用 Linkerd 时出错 - "unable to retrieve the complete list of server APIs: tap.linkerd.io/v1alpha1" error using Linkerd on private cluster in GKE 错误:验证失败:无法识别“”:版本 .networking.k8s.io/v1beta1 中种类“FrontendConfig”没有匹配项” - Error: validation failed: unable to recognize "": no matches for kind "FrontendConfig" in version "networking.k8s.io/v1beta1" Kube.netes apiVersion:.networking.k8s.io/v1 与 K8 Ingress 的问题 - Issue with Kubernetes apiVersion: networking.k8s.io/v1 with K8 Ingress GKE 上的 kubectl exec/logs 返回“远程错误:tls:内部错误” - kubectl exec/logs on GKE returns "remote error: tls: internal error" 更改 GKE 的 kubectl 身份验证后,用于为 kubectl 生成 kube 配置的 Jenkins 插件 - Jenkins plugin to generate kube config for kubectl after changes to kubectl authentication for GKE terraform 中的“kubectl apply -k”相当于什么? - What's the equivalent of "kubectl apply -k" in terraform? 'kubectl auth can-i --list' 有 Python 客户端 API - is there Python client API for 'kubectl auth can-i --list' Kubectl 命令抛出错误:无法连接到服务器:获取凭据:执行:退出状态 2 - Kubectl command throwing error: Unable to connect to the server: getting credentials: exec: exit status 2 elasticsearch 查询 GCP alpha 和 beta api - elasticsearch query for GCP alpha and beta api's 在 Windows 上安装 Kubectl 插件 - Install Kubectl Plugin on Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM