简体   繁体   中英

Azure Kubernetes cannot pull a image from ACR container

I could use some help with Azure AKS and ACR Integration. I create a ACR container and attach this container to the AKS cluster. I enable managed identity when creating AKS and I was hoping that ACR also uses managed identity

Here is the script I am using..

az group create --name $RESOURCEGROUP --location eastus
az acr create -n $REGISTRYNAME -g $RESOURCEGROUP --sku Basic
az aks create -n $CLUSTERNAME -g $RESOURCEGROUP --node-count $NODECOUNT --enable-addons monitoring --generate-ssh-keys --enable-managed-identity --attach-acr $REGISTRYNAME
az aks get-credentials -g $RESOURCEGROUP -n $CLUSTERNAME

On AKS, when I get pods, I have a Image Pull error

在此处输入图像描述

I see that AKS is using managed identity and ACR is using a Principal ID. How do I fix this issue

在此处输入图像描述

Getting the simillar issue once i tried with same cmdlet which you given.

kubectl apply -f acr-nginx.yaml

you need to try setting imagePullPolicy to Never and it just worked.

As kubectl describe pod mypd , Kubectl was trying to pull the image, and of course this image doesn't exis on remote server, hence the failure.

Above property will avoid connecting to registry and will use image from docker local images cache.

For Working with ACR & AKS

Import an image into your ACR Import an image from docker hub into your ACR by running the following:

az acr import  -n <acr-name> --source docker.io/library/nginx:latest --image nginx:v1

Would suggest to you follow this Microsoft document Deploy the sample image from ACR to AKS

spec:
      containers:
      - name: nginx
        image: <acr-name>.azurecr.io/nginx:v1
        imagePullPolicy: Never
        ports:
        - containerPort: 80

Refernce: Why am I getting an ErrImagePull error in this Kube.netes deployment?

The ErrImageNeverPull error suggests that your pod spec lists imagePullPolicy: Never, meaning that the kubelet will only look in the node's own cache and not try to pull from ACR. If you remove that, it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM