运行 "az aks get-credentials" 命令时出现 Azure Kubernetes 错误
Azure Kubernetes Error when running "az aks get-credentials" command
Azure 管理员为我们创建了一个集群。
在 VM 上,我安装了 "az cli" and "kubectl"
。
使用我在 Azure 门户中的帐户,我可以看到它所属的 Kubernetes 服务和资源组。
从 Azure 门户中该集群的级别,我可以看到我有一个角色:
"AKS Cluster Admin Operator"
我使用我的帐户通过 kubectl 登录了虚拟机。我需要配置我的 kubectl 以与我们的集群一起工作。
当我尝试执行时:
az aks get-credentials --resource-group FRONT-AKS-NA2 --name front-aks
我遇到错误:
ForbiddenError: The client 'my_name@my_comp.COM' with object id
'4ea46ad637c6' does not have authorization to perform action
'Microsoft.ContainerService/managedClusters/listClusterUserCredential/action'
over scope
'/subscriptions/89e05d73-8862-4007-a700-0f895fc0f7ea/resourceGroups/FRONT-AKS-NA2/providers/Microsoft.ContainerService/managedClusters/front-aks'
or the scope is invalid. If access was recently granted, please
refresh your credentials.
好吧,我看到了评论,你已经得到了解决方案。所以我只能向你解释其中的区别。希望对您有所帮助!
当您使用不带参数 --admin
的命令 az aks get-credentials
时,这意味着 CLI 命令使用 default value: Cluster user. And when you use the cluster user, it just works if you integrate AKS with the AAD. But you said you just have the AKS Cluster Admin Operator
role, so the appropriate parameter is --admin
. You can get more details here.
在我这边,有点危险。如果AKS集群只是为了测试,没有问题。但如果是用于生产,我建议你与AAD集成,然后给用户适当的权限。因为admin用户意味着你拥有所有的权限,你知道的,这是不安全的。
在我的例子中,刷新最近授予的凭据对这个有帮助:
az account set --subscription "your current subscription name"
导致重新登录并解决问题。
Azure 管理员为我们创建了一个集群。
在 VM 上,我安装了 "az cli" and "kubectl"
。
使用我在 Azure 门户中的帐户,我可以看到它所属的 Kubernetes 服务和资源组。
从 Azure 门户中该集群的级别,我可以看到我有一个角色:
"AKS Cluster Admin Operator"
我使用我的帐户通过 kubectl 登录了虚拟机。我需要配置我的 kubectl 以与我们的集群一起工作。 当我尝试执行时:
az aks get-credentials --resource-group FRONT-AKS-NA2 --name front-aks
我遇到错误:
ForbiddenError: The client 'my_name@my_comp.COM' with object id '4ea46ad637c6' does not have authorization to perform action 'Microsoft.ContainerService/managedClusters/listClusterUserCredential/action' over scope '/subscriptions/89e05d73-8862-4007-a700-0f895fc0f7ea/resourceGroups/FRONT-AKS-NA2/providers/Microsoft.ContainerService/managedClusters/front-aks' or the scope is invalid. If access was recently granted, please refresh your credentials.
好吧,我看到了评论,你已经得到了解决方案。所以我只能向你解释其中的区别。希望对您有所帮助!
当您使用不带参数 --admin
的命令 az aks get-credentials
时,这意味着 CLI 命令使用 default value: Cluster user. And when you use the cluster user, it just works if you integrate AKS with the AAD. But you said you just have the AKS Cluster Admin Operator
role, so the appropriate parameter is --admin
. You can get more details here.
在我这边,有点危险。如果AKS集群只是为了测试,没有问题。但如果是用于生产,我建议你与AAD集成,然后给用户适当的权限。因为admin用户意味着你拥有所有的权限,你知道的,这是不安全的。
在我的例子中,刷新最近授予的凭据对这个有帮助:
az account set --subscription "your current subscription name"
导致重新登录并解决问题。