Resolving ImagePullBackOff and Accessing a LoadBalancer Service in Minikube
Ray Ch
Posted on April 15, 2023
Summary: This document details the steps taken to resolve the ImagePullBackOff error and access a LoadBalancer service in a Kubernetes cluster running on Minikube.
Issue
The ImagePullBackOff error occurred while deploying the hello-world-microservice in a Kubernetes cluster running on Minikube. This issue prevented the deployment from starting. Additionally, accessing the LoadBalancer service using the curl command did not return any output.
Resolution
Fixing the ImagePullBackOff error
- Update the image name in the Kubernetes deployment manifest to use the correct image name available in the container registry.
- Apply the updated deployment manifest:
kubectl apply -f k8s-deployment.yaml
In terraform terraform apply
Accessing the LoadBalancer service
Check the logs of the running pods to see if there is any error or if the application has started properly:
kubectl logs hello-world-microservice-b849675f-gns8s -n hello-world
kubectl logs hello-world-microservice-b849675f-jrgpp -n hello-world
Access the service from within the cluster using a temporary pod with the curl command:
kubectl run curl-test --image=curlimages/curl:latest --rm -it --restart=Never --namespace=hello-world --command -- sh
Then, within the curl-test, Run:
curl hello-world-microservice:80
I am doing this because it's a web application. This depends on and defer based on the program.
My issue with Minikube
The actual problem I had was not with code and image but Minikube.
Since Minikube doesn't support the LoadBalancer service type out-of-the-box, run the minikube tunnel command in a separate terminal to create a network route on the host to the service CIDR of the cluster using the cluster's IP address as a gateway:
minikube tunnel
Check if the service's external IP:
kubectl get svc hello-world-microservice -n hello-world
Access the service using the external IP and port:
curl http://<EXTERNAL_IP>:80
Conclusion
By updating the image name in the Kubernetes deployment manifest and using the minikube tunnel command, I was successful in resolving the ImagePullBackOff error and accessed the LoadBalancer service in the Minikube Kubernetes cluster.
Posted on April 15, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.