ErrImageNeverPull error in kubernetes of windows docker desktop

11/27/2021

I have below YAML file used in Kubernetes of Windows Docker Desktop.

---
apiVersion: apps/v1
kind: Deployment
metadata:
    name: thoughts-backend
    labels:
        app: thoughts-backend
    namespace: example
spec:
    replicas: 1
    selector:
        matchLabels:
            app: thoughts-backend
    template:
        metadata:
            labels:
                app: thoughts-backend
        spec:
            containers:
                - name: thoughts-backend-service
                  image: thoughts_server:latest
                  imagePullPolicy: Never
                  ports:
                     - containerPort: 8000
                  env:
                      - name: DATABASE_ENGINE
                        value: POSTGRESQL
                      - name: POSTGRES_DB
                        value: thoughts
                      - name: POSTGRES_USER
                        value: postgres
                      - name: POSTGRES_PASSWORD
                        value: somepassword
                      - name: POSTGRES_PORT
                        value: "5432"
                      - name: POSTGRES_HOST
                        value: "127.0.0.1"

                - name: thoughts-backend-db
                  image: thoughts_backend_db:latest
                  imagePullPolicy: Never

---
apiVersion: v1
kind: Service
metadata:
    namespace: example
    labels:
        app: thoughts-service
    name: thoughts-service
spec:
    ports:
        - name: thoughts-backend
          port: 80
          targetPort: 8000
    selector:
        app: thoughts-backend
    type: NodePort
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    name: thoughts-backend-ingress
    namespace: example
spec:
    rules:
        - host: thoughts.example.local
          http:
            paths:
              - backend:
                  serviceName: thoughts-service
                  servicePort: 80
                path: /

When I run kubectl get pods -n example I get ErrImageNeverPull error.

> kubectl get pods -n example
NAME                                READY   STATUS              RESTARTS   AGE
thoughts-backend-55c686f6f5-dhjj2   0/2     ErrImageNeverPull   0          3h43m
>

Following is the output of describe command.

  > kubectl describe pod thoughts-backend-55c686f6f5-dhjj2  -n example
    Name:         thoughts-backend-55c686f6f5-dhjj2
    Namespace:    example
    Priority:     0
    Node:         docker-desktop/192.168.65.4
    Start Time:   Sat, 27 Nov 2021 16:31:29 +0530
    Labels:       app=thoughts-backend
                  pod-template-hash=55c686f6f5
    Annotations:  <none>
    Status:       Pending
    IP:           10.1.0.23
    IPs:
      IP:           10.1.0.23
    Controlled By:  ReplicaSet/thoughts-backend-55c686f6f5
    Containers:
      thoughts-backend-service:
        Container ID:
        Image:          thoughts_server:latest
        Image ID:
        Port:           8000/TCP
        Host Port:      0/TCP
        State:          Waiting
          Reason:       ErrImageNeverPull
        Ready:          False
        Restart Count:  0
        Environment:
          DATABASE_ENGINE:    POSTGRESQL
          POSTGRES_DB:        thoughts
          POSTGRES_USER:      postgres
          POSTGRES_PASSWORD:  somepassword
          POSTGRES_PORT:      5432
          POSTGRES_HOST:      127.0.0.1
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-tqssf (ro)
      thoughts-backend-db:
        Container ID:
        Image:          thoughts_backend_db:latest
        Image ID:
        Port:           <none>
        Host Port:      <none>
        State:          Waiting
          Reason:       ErrImageNeverPull
        Ready:          False
        Restart Count:  0
        Environment:    <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-tqssf (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             False
      ContainersReady   False
      PodScheduled      True
    Volumes:
      kube-api-access-tqssf:
        Type:                    Projected (a volume that contains injected data from multiple sources)
        TokenExpirationSeconds:  3607
        ConfigMapName:           kube-root-ca.crt
        ConfigMapOptional:       <nil>
        DownwardAPI:             true
    QoS Class:                   BestEffort
    Node-Selectors:              <none>
    Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
    Events:
      Type     Reason             Age                    From     Message
      ----     ------             ----                   ----     -------
      Warning  ErrImageNeverPull  3m4s (x326 over 4h1m)  kubelet  Container image "thoughts_server:latest" is not present with pull policy of Never

The Kubernetes version is

> kubectl.exe version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.5", GitCommit:"aea7bbadd2fc0cd689de94a54e5b7b758869d691", GitTreeState:"clean", BuildDate:"2021-09-15T21:10:45Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.5", GitCommit:"aea7bbadd2fc0cd689de94a54e5b7b758869d691", GitTreeState:"clean", BuildDate:"2021-09-15T21:04:16Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}

I am not sure what is this error and how to fix this in Docker-Desktop? Can anyone help me? I run Kubernetes in Docker-desktop application on Windows.

   "thoughts_server:latest" is not present with pull policy of Never      

Further, added output of docker images for help in debugging.

> docker images
REPOSITORY                                      TAG                                                     IMAGE ID       CREATED         SIZE
k8s.gcr.io/ingress-nginx/controller             <none>                                                  ae1a7201ec95   3 days ago      285MB
httpd                                           latest                                                  ad17c88403e2   8 days ago      143MB
nginx                                           latest                                                  ea335eea17ab   10 days ago     141MB
kubernetesui/dashboard                          v2.4.0                                                  72f07539ffb5   6 weeks ago     221MB
k8s.gcr.io/ingress-nginx/kube-webhook-certgen   <none>                                                  c41e9fcadf5a   6 weeks ago     47.7MB
docker/desktop-kubernetes                       kubernetes-v1.21.5-cni-v0.8.5-critools-v1.17.0-debian   967a1c03eb00   2 months ago    290MB
k8s.gcr.io/kube-apiserver                       v1.21.5                                                 7b2ac941d4c3   2 months ago    126MB
k8s.gcr.io/kube-scheduler                       v1.21.5                                                 8e60ea3644d6   2 months ago    50.8MB
k8s.gcr.io/kube-controller-manager              v1.21.5                                                 184ef4d127b4   2 months ago    120MB
k8s.gcr.io/kube-proxy                           v1.21.5                                                 e08abd2be730   2 months ago    104MB
kubernetesui/metrics-scraper                    v1.0.7                                                  7801cfc6d5c0   5 months ago    34.4MB
docker/desktop-vpnkit-controller                v2.0                                                    8c2c38aa676e   6 months ago    21MB
docker/desktop-storage-provisioner              v2.0                                                    99f89471f470   7 months ago    41.9MB
k8s.gcr.io/pause                                3.4.1                                                   0f8457a4c2ec   10 months ago   683kB
k8s.gcr.io/coredns/coredns                      v1.8.0                                                  296a6d5035e2   13 months ago   42.5MB
k8s.gcr.io/etcd                                 3.4.13-0                                                0369cf4303ff   15 months ago   253MB

Further, added output of kubernetes get pod -o wide command

> kubectl get nodes -o wide
NAME             STATUS   ROLES                  AGE   VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE         KERNEL-VERSION                   CONTAINER-RUNTIME
docker-desktop   Ready    control-plane,master   21h   v1.21.5   192.168.65.4   <none>        Docker Desktop   5.4.72-microsoft-standard-WSL2   docker://20.10.10
-- myquest
docker-desktop
kubernetes

1 Answer

11/27/2021

Per docs,

By default, the kubelet tries to pull each image from the specified registry. However, if the imagePullPolicy property of the container is set to IfNotPresent or Never, then a local image is used (preferentially or exclusively, respectively).

You use imagePullPolicy: Never directive in your Deployment and when you try to deploy your manifest, kubelet fails to find required images locally.

-- jabbson
Source: StackOverflow