az aks create - 它用于创建服务主体,现在是托管服务标识

az aks create - it used to create Service Principal now Managed Service Identity

更新:
一位在微软工作的同事说:

Changelog entry for this behaviour change is here: https://github.com/MicrosoftDocs/azure-docs-cli/blob/master/docs-ref-conceptual/release-notes-azure-cli.md#aks-3


我正在按照正确的说明进行操作,文档一定是过时的。

https://docs.microsoft.com/en-us/azure/aks/kubernetes-service-principal

Automatically create and use a service principal.
When you create an AKS cluster in the Azure portal or using the az aks create command, Azure can automatically generate a service principal. In the following Azure CLI example, a service principal is not specified. In this scenario, the Azure CLI creates a service principal for the AKS cluster. To successfully complete the operation, your Azure account must have the proper rights to create a service principal.

az aks create --name myAKSCluster --resource-group myResourceGroup

这是几个月前发生的事情 - 请参阅已完成服务主体创建

现在,当我尝试时,我得到 Add role propagation:

问题是在 msi 中查询 servicePrincipalProfile.clientId 结果,我需要服务主体的 GUID 而不是托管服务标识。

$CLIENT_ID=$(az aks show --resource-group $AKS_RESOURCE_GROUP --name $AKS_CLUSTER_NAME --query "servicePrincipalProfile.clientId" --output tsv)
echo $CLIENT_ID

曾经工作过:

现在改变了:

如何按照文档所述使用服务主体创建 Kubernetes 集群以及它过去是如何工作的?

重现步骤:

https://github.com/MeaningOfLights/AzureTraining/blob/master/Hands-On-Labs-That-Work/80-Kubernetes.md

https://github.com/MeaningOfLights/AzureTraining/blob/master/Hands-On-Labs-That-Work/85-Kubernetes-Deployment.md

供参考:我得到了同样的结果,并按照你的link我发现这有效。

az aks show -g aks -n cluster --query identityProfile.kubeletidentity.clientId -o tsv

这返回了适当的指南,我可以将其用于我的 RBAC 分配

# get the clientId of the cluster
$clientId = (az aks show -g aks -n cluster --query identityProfile.kubeletidentity.clientId -o tsv)

# get the resourceId of the registry
$acrId=(az acr show -g acr -n myacr --query id -o tsv)


# give authority for cluster id to the acr pull
az role assignment create $clientId --role AcrPull --scope $acrId