Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "ErrImageNeverPull" in pods

Am using minikube to test out the deployment and was going through this link

And my manifest file for deployment is like

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: webapp
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: webapp
    spec:
      containers:
      - name: webapp
        imagePullPolicy: Never # <-- here we go!
        image: sams
        ports:
        - containerPort: 80

and after this when I tried to execute the below commands got output

user@usesr:~/Downloads$ kubectl create -f mydeployment.yaml --validate=false

deployment "webapp" created

user@user:~/Downloads$ kubectl get deployments

NAME      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
----     --------   -------   ----------   ---------   ----              
webapp    1         1         1            0           9s

user@user:~/Downloads$ kubectl get pods

NAME                     READY     STATUS              RESTARTS   AGE
----     --------   -------   ----------   ---------   ----              
webapp-5bf5bd94d-2xgs8   0/1       ErrImageNeverPull   0          21s

I tried to pull images even from Docker-Hub by removing line imagePullPolicy: Never from the deployment.yml But getting the same error. Can anyone help me here to identify where and what's going wrong?

Updated the question as per the comment

kubectl describe pod $POD_NAME
Name:           webapp-5bf5bd94d-2xgs8
Namespace:      default
Node:           minikube/10.0.2.15
Start Time:     Fri, 31 May 2019 14:25:41 +0530
Labels:         app=webapp
            pod-template-hash=5bf5bd94d
Annotations:    <none>
Status:         Pending
IP:             172.17.0.4
Controlled By:  ReplicaSet/webapp-5bf5bd94d
Containers:
  webapp:
    Container ID:   
    Image:          sams
    Image ID:       
    Port:           80/TCP
    State:          Waiting
      Reason:       ErrImageNeverPull
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-wf82w (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  default-token-wf82w:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-wf82w
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
             node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason             Age                From               Message
  ----     ------             ----               ----               -------
  Normal   Scheduled          18m                default-scheduler  Successfully assigned default/webapp-5bf5bd94d-2xgs8 to minikube
  Warning  ErrImageNeverPull  8m (x50 over 18m)  kubelet, minikube  Container image "sams" is not present with pull policy of Never
  Warning  Failed             3m (x73 over 18m)  kubelet, minikube  Error: ErrImageNeverPull    

docker images:

REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
----------                             ---                 --------            -------             ----
<none>                                 <none>              723ce2b3d962        3 hours ago         1.91GB
bean_ben501/sams                       latest              c7c4a04713f4        4 hours ago         278MB
sams                                   latest              c7c4a04713f4        4 hours ago         278MB
sams                                   v1                  c7c4a04713f4        4 hours ago         278MB
<none>                                 <none>              b222da630bc3        4 hours ago         1.91GB
mcr.microsoft.com/dotnet/core/sdk      2.2-stretch         e4747ec2aaff        9 days ago          1.74GB
mcr.microsoft.com/dotnet/core/aspnet   2.2-stretch-slim    f6d51449c477        9 days ago          260MB

like image 704
Prateek Naik Avatar asked May 31 '19 09:05

Prateek Naik


People also ask

How many containers should I run in a pod?

Remember that every container in a pod runs on the same node, and you can't independently stop or restart containers; usual best practice is to run one container in a pod, with additional containers only for things like an Istio network-proxy sidecar.

Can volume be shared between pods?

Creating a Pod that runs two Containers In the configuration file, you can see that the Pod has a Volume named shared-data . The first container listed in the configuration file runs an nginx server. The mount path for the shared Volume is /usr/share/nginx/html .

Can pods be automatically destroyed?

Pods can never be automatically destroyed.

Can a pod have multiple containers?

At the same time, a Pod can contain more than one container, usually because these containers are relatively tightly coupled.


Video Answer


2 Answers

When using a single VM for Kubernetes, it’s useful to reuse Minikube’s built-in Docker daemon. Reusing the built-in daemon means you don’t have to build a Docker registry on your host machine and push the image into it. Instead, you can build inside the same Docker daemon as Minikube, which speeds up local experiments.

The following command does the magic eval $(minikube docker-env) Then you have to rebuild your image again.

for imagePullPolicy: Never the images need to be on the minikube node.

This answer provide details

local-images-in minikube docker environment

like image 135
Suresh Vishnoi Avatar answered Oct 14 '22 01:10

Suresh Vishnoi


You need to use eval $(minikube docker-env) in your current terminal window. This will use the minikube docker-env for the current session.

The image needs to be on the minikube virtual machine. So now you need to build your image again.

But be careful ! Don't use sudo when building the image. It won't use the minikube docker-env.

After you close the terminal, everything will be as it was before.

Then, use imagePullPolicy: Never in the manifest file to use the local image registry.

Example:

apiVersion: v1
kind: Pod
metadata:
  name: demo
spec:
  containers:
  - name: demo
    image: demo
    imagePullPolicy: Never # <-- here
    ports:
    - containerPort: 3000
like image 35
Tomas Lukac Avatar answered Oct 14 '22 01:10

Tomas Lukac