AKS/K8s authentication error when deploying some image tags; other tags succeed

Viewed 2391

Problem

I am running an Azure Pipeline to deploy specifically tagged images from Azure Container Registry (ACR) into an AKS cluster. For some image tags, the deployment succeeds. For other image tags, the deployment fails to pull the image. The deployed pod shows ImagePullBackOff.

Setup

An Azure Container Registry (ACR) contains a repository named my_repo_name Repository my_repo_name contains several image tags, examples: my_repo_name:0.4.0-51775-custom-hostaliases.485, my_repo_name:0.4.0-51775-custom-hostaliases.473, my_repo_name:0.4.0-alpha.449 An Azure Pipeline builds/publishes a Docker image to ACR and/or deploys an image to AKS

Strangeness

The deployment pipeline succeeds for my_repo_name:0.4.0-51775-custom-hostaliases.473, my_repo_name:0.4.0-alpha.459, and several other image tags. However, the deployment pipeline fails for my_repo_name:0.4.0-51775-custom-hostaliases.485 and several other image tags.

Error

kubectl describe shows: Warning Failed 26s (x3 over 73s) kubelet Failed to pull image "my_repo_name.azurecr.io/my_repo_name:0.4.0-51775-custom-hostaliases.485": rpc error: code = Unknown desc = failed to pull and unpack image "my_repo_name.azurecr.io/my_repo_name:0.4.0-51775-custom-hostaliases.485": failed to resolve reference "my_repo_name.azurecr.io/my_repo_name:0.4.0-51775-custom-hostaliases.485": failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized

I checked the ACR. All image tags that I am trying to deploy exist in ACR.

Questions

What would cause K8s to have the authorization to pull some images tags and lack authorization for other image tags?

What tools, logs, etc. can help me troubleshoot this issue? I turned Azure Pipeline logging to debug mode, looked through App Insights logging at pod-level, used kubectl describe.

2 Answers

According to my experience, there is nothing that will cause the issue that credential works for some tags and not work for other tags in the same repository. In ACR, the smallest scope of the permission is the repository. So it seems strange. Maybe the credential expires or the network connectivity is no good or the firewall of the ACR blocks the requests.

You can use the Azure CLI command az acr check-health to check the health of the ACR. Of course, you need to check the credential you use to authenticate for the ACR.

I was facing the same issue. In my case the problem was the helm version that I was using. In my case:

  • Image: jettech/kube-webhook-certgen:v1.5.1
  • Helm version (working): 3.36.0

Before, my Helm version was 3.6.x (I don't remember well).

When installing, I uses:

$ helm upgrade -i my_release --version 3.36.0 \
Related