Unable to connect to the server: getting credentials: exec: executable kubelogin not found
我为Kubernetes创建了新的config
文件,从Powershell
中的Azure
到az 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
结尾
这个错误意味着无法找到kubelogin
的可执行文件。你需要使用az aks install-cli
在azure cli中安装kubelogin
,然后它就会像预期的那样工作。
请参考github的安装过程。
我在我的环境中尝试了同样的要求,它对我来说是有效的,具体如下。
az aks get-credentials --resource-group caroline --name sampleaks1
kubectl get pods
输出:
一旦你有了aks
的凭证,运行kubectl get pods
会提示你输入Azure kubernetes service authentication with AAD
,如图所示。
在bash中给kubectl
验证是否安装成功。
如果问题仍旧存在,那么就会出现、
删除~/.kube/内的所有缓存或任何未使用的文件夹,并在末尾添加
--admin
标志,运行AKS凭证命令。请参考@Geert Baeke的文档,以获得更多相关信息。
检查kube配置的版本,如果需要的话,可以进行升级。
试着运行下面的az aks install-cli
来源:https://learn.microsoft.com/en-us/answers/questions/1106601/aks-access-issue