AKS icon indicating copy to clipboard operation
AKS copied to clipboard

Unable to pull image from ACR using managed identity

Open spewu opened this issue 6 years ago • 4 comments

I am having trouble configuring AKS correctly to pull images from ACR.

First I created an ACR using the portal. The name is likvido.

Then I run these commands to create a Windows AKS cluster:

az aks create \
    --resource-group kubernetes-staging \
    --name staging-win \
    --node-count 1 \
    --enable-addons monitoring \
    --kubernetes-version 1.16.9 \
    --generate-ssh-keys \
    --vm-set-type VirtualMachineScaleSets \
    --load-balancer-sku standard \
    --node-vm-size Standard_B2s \
    --network-plugin azure \
    --enable-managed-identity \
    --attach-acr likvido

az aks nodepool add \
    --resource-group kubernetes-staging \
    --cluster-name staging-win \
    --os-type Windows \
    --name npwin \
    --node-count 1 \
    --kubernetes-version 1.16.9

When trying to deploy a pod using an image from ACR, I get this result:

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

Since I am using a managed identity and I also attached ACR during creation of the cluster, I do not know why I am unable to pull images from there.

Any help is greatly appreciated!

Thanks

spewu avatar May 27 '20 17:05 spewu

perhaps a couple of things to verify/test.

  1. I always attach ACR instances using their id and not their name. Although the documentation mentions that you can use both, I definitely prefer using the ID.
  2. I think I remember running into similar problems quite some time ago. If I remember correctly it took about 10 minutes before I was able to pull images on all different nodes. perhaps it some kind of credential propagation that has to happen before you can pull the corresponding image.
  3. Check the role assignments of the identity assigned to AKS az role assignment list
  4. Perhaps you can use Azure Sentinel or ACR logs to see if the pull image request is issued with or without the service principal

thorstenhans avatar May 28 '20 12:05 thorstenhans

perhaps a couple of things to verify/test.

  1. I always attach ACR instances using their id and not their name. Although the documentation mentions that you can use both, I definitely prefer using the ID.
  2. I think I remember running into similar problems quite some time ago. If I remember correctly it took about 10 minutes before I was able to pull images on all different nodes. perhaps it some kind of credential propagation that has to happen before you can pull the corresponding image.
  3. Check the role assignments of the identity assigned to AKS az role assignment list
  4. Perhaps you can use Azure Sentinel or ACR logs to see if the pull image request is issued with or without the service principal

Thanks a lot for your good suggestions @ThorstenHans

I just found another similar issue, and I expect that I am running into the same problem: https://github.com/Azure/AKS/issues/1428#issuecomment-630999906

Ad 1) I also tried using the ID, and that had the same problem Ad 2) This is a good point, but it still did not work 12 hours later Ad 3) I did have a look at this, and it is difficult to decipher the output in my opinion, as the managed identity stuff seems to use GUID names. When I created my own service-principal (before I realized that was a bad idea) this was useful though Ad 4) I do not know what Azure Sentinel is, so I have some research to do I guess :)

spewu avatar May 28 '20 12:05 spewu

In your ACR access control, add a role assignment with your AKS node MSI. It works great for me.

starbloom avatar May 29 '20 01:05 starbloom

Duplicate of #1428

seanmck avatar May 29 '20 06:05 seanmck