Application not properly deployed using Kuberenetes

6/11/2018

I al developing a Spring Boot application, I used docker-compose to create my containers. And for Kubernetes I used kompose via minikubes. I pushed my images to docker hub, and I tried to deploy my container with both ways

kompose up

and

kompose convert -f docker-compose.yaml kubectl create -f (deplymentfiles)

But I get this response

WARN Volume mount on the host "/home/App/src/main/docker/postgres-data" isn't supported - ignoring path on the host 
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. 

INFO Deploying application in "default" namespace 
INFO Successfully created Service: adminer        
INFO Successfully created Service: app            
INFO Successfully created Service: mypostgres     
INFO Successfully created Deployment: adminer     
INFO Successfully created Deployment: app         
INFO Successfully created Deployment: mypostgres  
INFO Successfully created PersistentVolumeClaim: mypostgres-claim0 of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work 

when I run kubectl get pods

NAME                           READY     STATUS             RESTARTS   AGE
adminer-6cd96f8846-69qb8       1/1       Running            0          2m
app-5796c489ff-m46xk           0/1       ImagePullBackOff   0          2m
mypostgres-649865b4d8-nhglj    1/1       Running            0          2m

kubectl describe pod app-5796c489ff-m46xk

shows this

Name:           app-5796c489ff-m46xk
Namespace:      default
Node:           minikube/192.168.99.100
Start Time:     Mon, 11 Jun 2018 11:02:32 +0200
Labels:         io.kompose.service=app
                pod-template-hash=1352704599
Annotations:    <none>
Status:         Pending
IP:             172.17.0.3
Controlled By:  ReplicaSet/app-5796c489ff
Containers:
  app:
    Container ID:   
    Image:          iroolapp
    Image ID:       
    Port:           8086/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:
      DATABASE_HOST:      mypostgres
      DATABASE_NAME:      test
      DATABASE_PASSWORD:  root
      DATABASE_PORT:      5432
      DATABASE_USER:      root
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-wdb8n (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          False 
  PodScheduled   True 
Volumes:
  default-token-wdb8n:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-wdb8n
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     <none>
Events:
  Type     Reason                 Age              From               Message
  ----     ------                 ----             ----               -------
  Normal   Scheduled              3m               default-scheduler  Successfully assigned app-5796c489ff-m46xk to minikube
  Normal   SuccessfulMountVolume  3m               kubelet, minikube  MountVolume.SetUp succeeded for volume "default-token-wdb8n"
  Normal   Pulling                1m (x4 over 3m)  kubelet, minikube  pulling image "iroolapp"
  Warning  Failed                 1m (x4 over 3m)  kubelet, minikube  Failed to pull image "iroolapp": rpc error: code = Unknown desc = Error response from daemon: pull access denied for iroolapp, repository does not exist or may require 'docker login'
  Warning  Failed                 1m (x4 over 3m)  kubelet, minikube  Error: ErrImagePull
  Normal   BackOff                1m (x6 over 3m)  kubelet, minikube  Back-off pulling image "iroolapp"
  Warning  Failed                 1m (x6 over 3m)  kubelet, minikube  Error: ImagePullBackOff

Finally this is my docker-compose file

version: '3'
services:
  app:
    image: iroolapp
    depends_on:
    - mypostgres
    ports:
     - "9000:8086"
    environment:
      - DATABASE_HOST=mypostgres
      - DATABASE_USER=root
      - DATABASE_PASSWORD=root
      - DATABASE_NAME=test
      - DATABASE_PORT=5432

    networks:
        default:

  mypostgres:
    image: postgres:9.6-alpine
    container_name: mypostgres

    ports:
     - "5433:5432"


    environment:
     - POSTGRES_PASSWORD=root
     - POSTGRES_USER=root
     - POSTGRES_DB=irooldb
    volumes:
    - ./postgres-data:/var/lib/postgresql/data

  adminer:
    image: adminer
    ports:
      - 8080:8080
    networks:
        default:

networks:
   default:
      external:
        name: mynetwork

My question is: what does ImagePullBackoff refers to? using kompose is it a good approach? and is it a necessary step to push images to docker hub before using kubernetes

-- Ennar.ch
docker
docker-compose
kompose
kubernetes

4 Answers

2/26/2020

I think image name not getting a proper direction at all. If you stored in your repo then give full path like "username/repo:tag" or else first search by command in terminal "docker search imagename" . Kubernetes pull the image again and again till running condition, so may be RESTART count goes high. So give it the proper url or private repo path.

-- Tej-Singh-Rana
Source: StackOverflow

6/11/2018

ImagePullBackoff means you can't get the image.

Have you actually read the error message? It says Failed to pull image "iroolapp": rpc error: code = Unknown desc = Error response from daemon: pull access denied for iroolapp, repository does not exist or may require 'docker login'

Are you logged into docker hub? Is your image in docker hub? Because that's from where it is trying to pull the image.

-- suren
Source: StackOverflow

6/11/2018

I figured it out, In fact in my docker-compose file I should specify the image refering to the image posted in the repository pushed in the docker hub:

image: docker.io/<dockerHub username>/<imagename>
-- Ennar.ch
Source: StackOverflow

6/11/2018

Q1

what does ImagePullBackoff refers to

From the log, you can see it tried several times to pull the image "iroolapp" pod app-5796c489ff-m46xk's container needs (see the field image of pod's container) from the registry and all failed. The ImagePullBackoff occured after those failures.

Q2

using kompose is it a good approach?

Havn't used it...

Q3

and is it a necessary step to push images to docker hub before using kubernetes

It's not. If just for simple test, you can use local image by setting the imagePullPolicy to IfNotPreset or Never (make sure the image's loaded). Alternatively you can have your private registry.

-- wineinlib
Source: StackOverflow