AKS unable to pull image from ACR

RITAM SUR 0 Reputation points
2024-11-13T12:48:32.12+00:00

Created an AKS cluster, attached the ACR to the AKS.
The AKS can pull other images from the same repository. But when ever I am running the below deployment it is failing with error: Failed to pull image "conatinerregistry01.azurecr.io/nginxnonrooti:v1": [rpc error: code = NotFound desc = failed to pull and unpack image "conatinerregistry01.azurecr.io/nginxnonrooti:v1": no match for platform in manifest: not found, failed to pull and unpack image "conatinerregistry01.azurecr.io/nginxnonrooti:v1": failed to resolve reference "conatinerregistry01.azurecr.io/nginxnonrooti:v1": failed to authorize: failed to fetch anonymous token: unexpected status from GET request to https://conatinerregistry01.azurecr.io/oauth2/token?scope=repository%3Anginxnonrooti%3Apull&service=conatinerregistry01.azurecr.io: 401 Unauthorized]

Deployment:
apiVersion: apps/v1

kind: Deployment

metadata:

name: nginx-deployment

labels:

app: nginx

spec:

replicas: 2

selector:

matchLabels:

app: nginx

template:

metadata:

labels:

app: nginx

spec:

initContainers:

  • name: init-nginx

image: busybox

command: ['sh', '-c', 'echo "Initializing NGINX setup...."; sleep 3']

#securityContext:

runAsNonRoot: true

runAsUser: 1010

runAsGroup: 1010

fsGroup: 1010

#imagePullSecrets:

- name: acr-auth

containers:

  • name: nginx-container

image: conatinerregistry01.azurecr.io/nginxnonrooti:v1

imagePullPolicy: IfNotPresent

ports:

  • containerPort: 8080

resources:

requests:

memory: "200Mi"

cpu: "250m"

limits:

memory: "500Mi"

cpu: "500m"

livenessProbe:

httpGet:

path: /

port: 8080

initialDelaySeconds: 15

periodSeconds: 10

timeoutSeconds: 5

failureThreshold: 3

readinessProbe:

httpGet:

path: /

port: 8080

initialDelaySeconds: 15

periodSeconds: 10

timeoutSeconds: 5

successThreshold: 1

failureThreshold: 3

securityContext:

runAsNonRoot: true

runAsUser: 1010

runAsGroup: 1010

fsGroup: 1010

Azure Container Registry
Azure Container Registry
An Azure service that provides a registry of Docker and Open Container Initiative images.
468 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,207 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sai Krishna Katakam 1,510 Reputation points Microsoft Vendor
    2024-11-14T16:12:36.2233333+00:00

    Hi RITAM SUR,

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue:

    AKS unable to pull image from ACR.

    Solution:

    The problem was building the Docker image on a MacBook (ARM architecture) but deploying on an amd64 environment. The fix was to build the image for amd64:

    docker buildx build --platform linux/amd64 -t <image-name>:amd64 .

    After pushing the image to ACR, deployment could pull and run it successfully. This ensures compatibility for ARM-to-amd64 deployments.

    If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    Thank you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.