imagepullbackoff while pulling image from azure co

2019-09-16 18:47发布

问题:

First i have created the docker image and created kubernetes cluster in azure container service. Then tag and push the image to my repository, but while pulling my image from azure container registry to kubernetes cluster the pod are created but in status it shows imagepullback off

The yaml file for basic api image

**apiVersion: v1
kind: Pod
metadata:
  name: myapis
spec:
  containers:
    - name: myapis
      image: ciqsample.azurecr.io/myapis
  imagePullSecrets:
    - name: samplekey**

回答1:

This error means we use wrong key and password to pull image.
Can you run this command to check secret exist or not?kubectl get secret

root@k8s-master-BBF71727-0:~# kubectl get secret
NAME                  TYPE                                  DATA      AGE
azurecr               kubernetes.io/dockercfg               1         57m
default-token-clm2d   kubernetes.io/service-account-token   3         2h

Then check the secret.

root@k8s-master-BBF71727-0:~# kubectl get secret azurecr --output=yaml

We can use this command script to create secret:

kubectl create secret docker-register yoursecretname --docker-server=jason.azurecr.io/xxxx/test --docker-username={UserName} --docker-password={Password} --docker-email=team@domain.com

By the way, for test please login Azure container registry with your registry credentials, then try to pull image from Azure container registry.
Login
docker login myregistry.azurecr.io -u xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -p myPassword

Pull the image from your registry

docker pull myregistry.azurecr.io/samples/nginx