Failed to pull image "xx.azurecr.io/xx:latest": rpc error: code = Unknown desc = Error response from daemon: unauthorized: authentication required

时间:2019-04-08 12:58:18

标签: image authentication required azure-aks azure-acr

My ACR and AKS are on same Azure Directory with same subscription.

After giving ACR Pull access to my Service Principal, nothing worked and still getting this error.

Error :- Failed to pull image "xx.azurecr.io/xx:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://xx.azurecr.io/v2/xx/manifests/latest: unauthorized: authentication required

screenshot of dashboard

3 个答案:

答案 0 :(得分:0)

从错误消息中,它表明您不进行身份验证以将映像拉到Azure容器注册表中。

对于AKS,有两种方法可以获取从Azure容器注册表中提取图像的权限。

一个是向AKS群集使用的服务主体授予权限。您可以在Grant AKS access to ACR中获取详细信息。这样,您只需要一个服务主体即可。

另一个是将权限授予与AKS使用的服务主体不同的新服务主体。然后,使用服务主体创建一个秘密以提取映像。您可以在Access with Kubernetes Secret中获取详细信息。

它们是两种不同的方式,因此您应确保步骤中没有错误。要检查服务主体的角色分配,请使用如下CLI命令:

az role assignment list --assignee $SP_ID --role acrpull --scope $ACR_ID

SP_ID取决于您使用的方式。

答案 1 :(得分:0)

集群运行时使用的服务主体不是我想的主体。要进行检查,请按照以下步骤操作。

  1. 运行命令“ az aks show -n aks-群集名称-g资源组名称| grep客户端”

  2. 运行逗号“ az ad凭据列表--id”-此命令用于检查机密是否关联。

  3. 登录到Azure门户。

  4. 导航到Azure容器注册表

  5. IAM->查看角色分配->检查具有最少“ AcrPull”访问权限的列表中是否存在客户端ID。如果没有,则授予对SP的访问权限。

请在YAML中检查我们是否看到正确的身份验证。

答案 2 :(得分:0)

造成此错误的原因不同:默认情况下,使用AKS群集创建的服务主体将在一年后过期。 https://docs.microsoft.com/en-us/azure/aks/update-credentials上的说明显示了如何更新或创建新的主体。