What is ImagePullBackOff status on a Kubernetes pod ?
When I was trying to run kubernetes Pods in Google Cloud Platform, I got the status as ImagePullBackOff for one of the kubernetes pod. Let’s see what is ImagePullBackOff status and how to resolve the same.
ImagePullBackOff status on a Kubernetes Pod
After doing kubernetes pods deployment, I wanted to check if all pods are up and running. Therefore, I ran the following kubectl command to fetch all the pods running in the namespace “mv“.
One of the kubernetes pod “kafka-producer-service-776979bc89-bhvbm” was showing the status as ImagePullBackOff as shown below.
$ kubectl get pods -n mv NAME READY STATUS RESTARTS AGE kafka-producer-service-776979bc89-bhvbm 1/2 ImagePullBackOff 0 18s kafka-77fb6497c9-h9lns 2/2 Running 0 47m zookeeper-65fcbf6ccb-5knt8 2/2 Running 0 47m
Actually the expected status for all the pods is “Running” but one of the pod shows READY 1/2 which means there are two containers should be up and running in that pod, but one of the container is not ready.
Troubleshooting ImagePullBackOff Status
First, I had checked my kubernetes deployment YAML configuration file.
--- apiVersion: apps/v1 kind: Deployment metadata: name: kafka-producer-service spec: replicas: 1 selector: matchLabels: app: kafka-producer-service template: metadata: labels: app: kafka-producer-service spec: containers: - name: kafka-producer-servicee image: sneppets/kafka-producer-service:latest ports: - containerPort: 8080 env: - name: MONGODB_HOST value: mongodb - name: KAFKA_HOST value: kafka imagePullPolicy: Always --- apiVersion: v1 kind: Service metadata: name: kafka-producer-service spec: selector: app: kafka-producer-service ports: - port: 80 targetPort: 8080
As you can see clearly that in the deployment YAML section, the containers spec for image was mentioned as “sneppets/kafka-producer-service:latest“. It means that when you run this deployment script, it will try to look for docker images in the docker hub registry.
Then I checked my Docker hub repositories for the specified image. And I could see that there is no docker image found in the name of kafka-producer-service in the repository “sneppets” in the docker hub.
Therefore, the issue ImagePullBackOff status is due to missing image in the public docker registry.
Solution
To fix the ImagePullBackOff issue, you need to run the following command and ensure you push the image to the docker registry.
First, build your application using tools like Maven.
$ mvn clean install -Dmaven.test.skip=true
Run the following command to build docker image locally.
$ docker image build -t kafka-producer-service .
Create a image tag by running the following command.
$ docker image tag kafka-producer-service sneppets/kafka-producer-service
Finally, push the image to the docker registry repository.
$ docker image push sneppets/kafka-producer-service
That’s all, now you can run the deployment YAML scripts again and try running the kubectl command, you would not see the status ImagePullBackOff status now.
$ kubectl get pods -n mv NAME READY STATUS RESTARTS AGE kafka-producer-service-776979bc89-bhvbm 2/2 Running 0 18s kafka-77fb6497c9-h9lns 2/2 Running 0 47m zookeeper-65fcbf6ccb-5knt8 2/2 Running 0 47m
Also, see that READY shows not 2/2 for kafka-producer-service which means that both the containers are up and running now.
Hope it helped 🙂
- How to Explore Docker Container’s File System ?
- Docker EXPOSE Port only to the Host on Google Cloud
- Get Docker Container’s IP Address from the Host
- Copy Files between Host and Docker Container
- Start Stop Restart MariaDB on Linux OS
- kubectl unable to connect to server: x509: certificate signed by unknown authority
- How to list all Containers running in Kubernetes Pod ?
- How to find which users belongs to a specific group in linux
- Give write permissions for specific user or group for specific folder in linux
- How to remove an image tag from docker hub ?
- Build a Docker Image with a Dockerfile and Cloud Build in GCP?
- How to create GCP project on Google Cloud Platform
- MariaDB – How to set max_connections permanently ?
- Create GCP project on Google Cloud Platform
- Is it possible to change Google Cloud Platform Project ID ?
- Create non-root SSH user account and provide access to specific folders
- Delete docker repository from the docker hub
- Unable to connect to the server: dial tcp i/o timeout