Kubernetes - Error message ImagePullBackOff when deploy a pod

2/14/2019

Hello kubernetes developers,

i get the error 'ImagePullBackOff' if deploy a pod in kubernetes. Pulling in docker to get the image from git-hub repository is no problem. But what is wrong with my configuration?

I tried this workaround to create a secret-key with the following command.

kubectl create secret docker-registry secretkey \
        --docker-server=registry.hub.docker.com \
        --docker-username=reponame \
        --docker-password=repopassword \
        --docker-email=repoemail

And this is the yaml file to create the kubernetes pod.

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: gps-restful-server
  name: gps-restful-server
spec:
  containers:
  - image: tux/gps:latest
    name: gps-restful-server
    ports:
    - containerPort: 8080
    resources: {}
    volumeMounts:
    - mountPath: /var/www/html/modules
      name: gps-modules
    - mountPath: /var/www/html/profiles
      name: gps-profile
    - mountPath: /var/www/html/themes
      name: gps-theme
    - mountPath: /var/www/html/sites
      name: gps-sites
    imagePullPolicy: Always
  restartPolicy: OnFailure
  imagePullSecrets:
    - name: secretkey
  volumes:
  - name: gps-modules
    persistentVolumeClaim:
      claimName: gps-modules
  - name: gps-profile
    persistentVolumeClaim:
      claimName: gps-profile
  - name: gps-theme
    persistentVolumeClaim:
      claimName: gps-theme
  - name: gps-sites
    persistentVolumeClaim:
      claimName: gps-sites
status: {}

To deploy the pod in kubernetes, i execute the command:

kubectl create -f gps-restful-server-pod.yaml.

Get the status from the pod:

kubectl get all
NAME                           READY     STATUS             RESTARTS   AGE
pod/telemetry-restful-server   0/1       ImagePullBackOff   0          12m  
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP    1h

Description of the pod:

kubectl describe pod gps-restful-server
Name:               gps-restful-server
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               minikube/192.168.178.92
Start Time:         Thu, 14 Feb 2019 16:56:25 +0100
Labels:             io.kompose.service=gps-restful-server
Annotations:        <none>
Status:             Pending
IP:                 172.17.0.3
Containers:
  gps-restful-server:
    Container ID:
    Image:          tux/gps:latest
    Image ID:
    Port:           8080/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-4t28k (ro)
      /var/www/html/modules from gps-modules (rw)
      /var/www/html/profiles from gps-profile (rw)
      /var/www/html/sites from gps-sites (rw)
      /var/www/html/themes from gps-theme (rw)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  gps-modules:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  gps-modules
    ReadOnly:   false
  gps-profile:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  gps-profile
    ReadOnly:   false
  gps-theme:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  gps-theme
    ReadOnly:   false
  gps-sites:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  gps-sites
    ReadOnly:   false
  default-token-4t28k:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-4t28k
    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  4m               default-scheduler  Successfully assigned default/gps-restful-server to minikube
  Normal   Pulling    2m (x4 over 4m)  kubelet, minikube  pulling image "tux/gps:latest"
  Warning  Failed     2m (x4 over 4m)  kubelet, minikube  Failed to pull image "tux/gps:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for tux/gps, repository does not exist or may require 'docker login'
  Warning  Failed     2m (x4 over 4m)  kubelet, minikube  Error: ErrImagePull
  Warning  Failed     2m (x6 over 4m)  kubelet, minikube  Error: ImagePullBackOff
  Normal   BackOff    2m (x7 over 4m)  kubelet, minikube  Back-off pulling image "tux/gps:latest"

How it's possible to pull the image from docker-hub in kubernetes?

-- Mux
image
kubernetes

2 Answers

2/16/2019

The Image tux/gps:latest does not exist because its a dummy value. Solution to ImagePullBackoff:

  1. Make sure that your Image points to latest version repouser/reponame:latest
  2. Create a secret docker-registry (look above)
  3. Server address[docker-hub registry]
  4. Add the following propertie in pod yaml file (look above):

imagePullSecrets:
- name: secretkey

-- Mux
Source: StackOverflow

2/15/2019

The issue was caused due to the wrong value of key pods.spec.containers.image.

The image property of a container supports the same syntax as the docker command does, including private registries and tags.

k8s Images

-- Suresh Vishnoi
Source: StackOverflow