Search code examples
kuberneteskubectlkubernetes-podkubernetes-deployment

How to resolve this issue ErrImageNeverPull pod creation status kubernetes


I am creating a pod from an image which resides on the master node. When I create a pod on the master node to be scheduled on the worker node, I get the status of pod ErrImageNeverPull

kind: Pod
metadata:
   name: cloud-pipe
   labels:
      app: cloud-pipe
spec:
   containers:
     - name: cloud-pipe
       image: cloud-pipeline:latest
       command: ["sleep"]
       args: ["infinity"]

Kubectl describe pod details:

   Type     Reason             Age                   From               Message
   - ---     ------             ----                  ----               -------   
    Normal   Scheduled          15m                   default-scheduler  Successfully assigned 
    default/cloud-pipe to knode
    Warning  ErrImageNeverPull  5m54s (x49 over 16m)  kubelet            Container image "cloud- 
    pipeline:latest" is not present with pull policy of Never
    Warning  Failed             51s (x72 over 16m)    kubelet            Error: ErrImageNeverPull

How to resolve this issue. Also, my question is does Kubernetes by default looks on the worker node for the image to exist?. Thanks


Solution

  • When kubernetes creates containers, it first looks to local images, and then will try registry(docker registry by default)

    You are getting this error because:

    • your image cant be found localy on your node.

    • you specified imagePullPolicy: Never, so you will never try to download image from registry

    You have few ways of resolving this, but all of them generally instruct you to get image locally and tag it properly.

    To get image on your node you can:

    Once you get image, tag it and specify in the deployment

    docker tag cloud-pipeline:latest mytest:mytest
    
    kind: Pod
    metadata:
       name: cloud-pipe
       labels:
          app: cloud-pipe
    spec:
       containers:
         - name: cloud-pipe
           image: mytest:mytest
           imagePullPolicy: Never
           command: ["sleep"]
           args: ["infinity"]
    

    Or you can configure own local registry, push tagged image into it, and use imagePullPolicy: IfNotPresent. More information in @dryairship answer

    Also please be sure using eval $(minikube docker-env) for imagePullPolicy: Never images, in case you are using minikube (you havent specified any tag, but it can be helpful). More information in Getting “ErrImageNeverPull” in pods question