Unable to connect to the server: getting credentials: exec: executable kubelogin not found

回答 2 浏览 4784 2023-04-12

我为Kubernetes创建了新的config文件,从Powershell中的Azureaz aks get-credentials --resource-group <RGName> --name <ClusterName>。得到的消息是Merged "cluster_name" as current context in C:\michu\.kube\config。我把这个文件复制到默认的.kube\config位置,现在当我试图运行任何命令时,例如kubectl get pods,我收到了:

Unable to connect to the server: getting credentials: exec: executable kubelogin not found

It looks like you are trying to use a client-go credential plugin that is not installed.

To learn more about this feature, consult the documentation available at:
      https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins

这里有什么不对吗?

我刚刚意识到,当我输入 kubectl config get-contexts 时,我可以看到我的 cluster_name,我甚至可以通过 kubectl config use-context cluster_name 切换到这个,消息是正确的:Switched to context cluster_name 但所有其他命令仍然以 Unable to connect to the server: getting credentilas: exec: executable kubelogin not found 结尾

Michu93 提问于2023-04-12
2 个回答
#1楼 已采纳
得票数 2

这个错误意味着无法找到kubelogin的可执行文件。你需要使用az aks install-cli在azure cli中安装kubelogin,然后它就会像预期的那样工作。

请参考github的安装过程。

我在我的环境中尝试了同样的要求,它对我来说是有效的,具体如下。

az aks get-credentials --resource-group caroline --name sampleaks1
kubectl get pods

输出:

enter image description here

一旦你有了aks的凭证,运行kubectl get pods会提示你输入Azure kubernetes service authentication with AAD,如图所示。

enter image description here

在bash中给kubectl 验证是否安装成功。

enter image description here

如果问题仍旧存在,那么就会出现、

  1. 删除~/.kube/内的所有缓存或任何未使用的文件夹,并在末尾添加--admin标志,运行AKS凭证命令。

    请参考@Geert Baeke的文档,以获得更多相关信息。

  2. 检查kube配置的版本,如果需要的话,可以进行升级。

Jahnavi 提问于2023-04-12
Andrii Andriichuk 修改于2023-05-09
#2楼
得票数 0

试着运行下面的az aks install-cli

来源:https://learn.microsoft.com/en-us/answers/questions/1106601/aks-access-issue

Amy Doxy 提问于2023-05-08