【问题标题】:AKS attach-acr error after migrating from one subscription to another从一个订阅迁移到另一个订阅后出现 AKS attach-acr 错误
【发布时间】:2021-09-17 22:06:29
【问题描述】:

我刚刚在 Azure 上从一个订阅迁移到另一个订阅。虽然subscriptionId是一样的,但是tenantId已经变了。

迁移后,我的 AKS 群集无法再从 ACR 中提取图像。我的 AKS 当前使用我认为在迁移后不再有效的服务原则。我已经更新了服务原理,但是还是拉不出来图片。

还有其他需要注意的配置吗?

【问题讨论】:

    标签: azure azure-aks azure-container-registry


    【解决方案1】:

    请验证角色“AcrPull”是否仍分配给 AKS 节点池的托管标识 (Kubelet)。

    Terrafrom 示例:

      resource "azurerm_role_assignment" "example" {
        scope                            = azurerm_container_registry.acr.id
        role_definition_name             = "AcrPull"
        principal_id                     = azurerm_kubernetes_cluster.aks.kubelet_identity[0].object_id
      }
    

    AZ cli 示例:

    export KUBE_ID=$(az aks show -g <resource group> -n <aks cluster name> --query identityProfile.kubeletidentity.objectId -o tsv)
    export ACR_ID=$(az acr show -g <resource group> -n <acr name> --query id -o tsv)
    az role assignment create --assignee $KUBE_ID --role "AcrPull" --scope $ACR_ID
    

    【讨论】:

    • 我的 KUBE_ID 为空。这是否意味着我应该创建一个新的 az 角色?我检查了 AKS,我的 IdentityProfile 为空,因为我使用的是 SP
    • 然后试试这个(对于 KUBE_ID):--query identity.principalId
    • 您也可以将 ACR 附加到 AKS -> docs.microsoft.com/en-us/azure/aks/…
    • 实际上刚刚意识到我在尝试错误的集群。我尝试了 Az CLI 命令,我收到以下错误“无法在图形数据库中找到 'xxx-xxxx-xxx' 的用户或服务主体。如果受让人是 appId,请确保使用 'az 创建相应的服务主体ad sp create --id xxx-xxxx-xxx'"
    • 我在尝试附加 ACR 时收到此错误“无法为 ACR 创建角色分配。您是此订阅的所有者吗?”我是订阅的全局管理员
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    • 2021-11-30
    • 2017-04-13
    • 1970-01-01
    • 2020-12-17
    • 1970-01-01
    相关资源
    最近更新 更多