Unable to pull image from Azure Container Registry

4/10/2019

We recently had an issue with our Azure Kubernetes Cluster not reporting back any data through the Azure Portal. To fix this, I updated the Kubernetes version to the latest version as was recommended on GitHub. After the upgrade was complete, we were able to view logs and monitoring data through the portal, but one of the containers stored in our Azure Container Registry is not able to be pulled by the Kubernetes Cluster.

The error I see in the Kuberenetes Management page is:

Failed to pull image "myacr.azurecr.io/container:190305.191": [rpc error: code = Unknown desc = Error response from daemon: Get https://myacr.azurecr.io/v2/mycontainer/manifests/190305.191: unauthorized: authentication required, rpc error: code = Unknown desc = Error response from daemon: Get https://myacr.azurecr.io/v2/mycontainer/manifests/190305.191: unauthorized: authentication required]

My original setup used the first script provided in this document and it worked correctly without issue. Once I started receiving the error, I ran it again just to make sure.

Once I saw that failed, I then deleted the account from the permissions on both the ACR and the AKS. Again, it failed to pull the image.

After that, I tried using the second method of creating an Kubernetes secret and received the same error.

At this point, I'm unsure what else to check. I've verified that I can run docker pull on my machine and pull the image, but there seems to be a breakdown between the AKS and the ACR that I can not sort out.

-- Ian
azure
containers
kubernetes

1 Answer

2/21/2020

It's been a while since I originally posted this, but I did stumble across a currently stable solution to the problem.

The service principal, for whatever reason, is not able to maintain a connection to the ACR. So if your cluster ever goes down, you lose the ability to pull from the ACR. I had this happen multiple times over the last year and as I moved more of my Kubernetes deployment to Azure, it became a bigger and bigger issue.

I stumbled across this Microsoft Doc and noticed the mention of the --attach-acr command.

This is what the full command looks like:

az aks create -n myAKSCluster -g myResourceGroup --generate-ssh-keys --attach-acr $MYACR

Since setting it up with that flag, I have had 0 issues with it.

knock on wood

-- Ian
Source: StackOverflow