首页 > 解决方案 > 错误:为处于 CREATED 状态的 pod 分配身份失败 - AKS AAD-Pod 身份

问题描述

对于使用托管标识 AAD-POD 标识的 aks (1.14.8) 的 NMI 日志中的 pod,我收到以下错误。我已按照https://github.com/Azure/aad-pod-identity中指定的步骤进行操作,但我们希望将托管标识用于 azure sql paas。参考链接:https ://trstringer.com/connect-k8s-apps-msi/

E0618 17:19:40.762387 1 server.go:370] failed to get matching identities for pod: default/schedulerserviceapi-7fc4dc9547-95vbw, error: getting assigned identities for pod default/schedulerserviceapi-7fc4dc9547-95vbw in CREATED state failed after 16 attempts, retry duration [5]s. Error: <nil>

标签: azure-aks

解决方案


造成这种情况的可能原因是您的集群服务主体没有该角色Managed Identity Operator

您可以检查mic服务的日志,并查找以下日志片段“无权执行操作 Microsoft.ManagedIdentity/userAssignedIdentities/assign/action'”

您可以使用以下 CLI 命令将角色分配给服务主体:

# retrieve cluster service principal clientId ($SP_CLIENT_ID below)
az aks show -g $RESOURCE_GROUP -n $AKS_CLUSTER_NAME --query servicePrincipalProfile.clientId -o tsv

# assign role to SP
az role assignment create --role "Managed Identity Operator" --assignee $SP_CLIENT_ID  --scope /subscriptions/$SUBSCRIPTION_ID/resourcegroups/$RESOURCE_GROUP

参考:https ://github.com/Azure/aad-pod-identity/issues/585


推荐阅读