3

I am trying to create a pod based on a container image from local machine not from public registry. I am retrieving the status of pod as ImagePullBackoff Docker file

FROM tensorflow/tensorflow:latest-py3
RUN pip install -q keras==2.3.1
RUN pip install pillow
RUN mkdir -p /app/src
WORKDIR /app/src
COPY . ./
EXPOSE 31700
CMD ["python", "test.py"]

To build the docker image

docker build -t tensor-keras .

To create a pod without using yaml file

kubectl run server --image=tensor-keras:latest

Yaml file

apiVersion: v1 
kind: Pod
metadata:
 name: server
 labels: 
    app: server
spec:
 containers:
  - name:  tensor-keras
    image: tensor-keras:latest
    ports:
    - containerPort: 31700

I am retreiving the status of the pod as

  NAME          READY   STATUS             RESTARTS   AGE
  server         0/1   ImagePullBackOff      0        27m        

  

Help is highly appreciated thanks

Fabrice Jammes
  • 2,275
  • 1
  • 26
  • 39
abaair davis
  • 189
  • 7

1 Answers1

4

By default, Kubernetes will try to pull your image from a remote container repository. In your case, your image name is not prefixed by a container repository url, so it uses default one, most of the time it is set to Docker Hub.

What is the value of the imagePullPolicy field? For you use-case it should be set to Never to use local image. Which tool are you using to run your Kubernetes instance?

  • For example, with minikube, procedure to use a local image is described here: https://stackoverflow.com/a/42564211/2784039
  • With kind, you should use command kind load docker-image <tensor-keras:latest> o load the image inside your cluser
  • With k3s, using local image should work out of the box, if imagePullPolicy is set to Never
Fabrice Jammes
  • 2,275
  • 1
  • 26
  • 39
  • Thanks for your wonderful help @fjammes, I am not using minikube, or k3s I am using k8s. I will try your solultion and will update you asap – abaair davis Oct 26 '20 at 15:48
  • Hi @fjammes, I tried this solution , now the status is crashloopbackoff. – abaair davis Oct 26 '20 at 15:53
  • 1
    @abaairdavis As the underlying issue of accessing an image was resolved, please consider creating another question with information specific to the `Crashloopbackoff` state of your `Pod` like `$ kubectl describe pod server`, `$ kubectl logs server`. – Dawid Kruk Oct 27 '20 at 14:09
  • Hi, thanks @DawidKruk for your wonderful help. I have solved the issue, the issue was of the docker image file – abaair davis Oct 27 '20 at 14:12