I am getting the ErrImagePull error while creating the pod with the Yaml file.
My yaml file part
containers:
- image: kodekloud/votingapp
name: voting
imagePullPolicy: IfNotPresent
I’m using the minikube cluster.
I am getting the ErrImagePull error while creating the pod with the Yaml file.
My yaml file part
containers:
I’m using the minikube cluster.
Your problem is that the image name is wrong. Please try kodekloud/examplevotingapp_vote:v1 instead.
But the provided image name in the Yaml file is present locally.
I built it with the docker built command.
How is minikube configured? I haven’t tried this using the docker driver, but in most configurations I use, minikube’s install of kubernetes will not find a docker image that you load on minikube’s docker server. I tried the following:
# set my shell to use minikube's docker server
eval $(minikube -p minikube docker-env)
# cd into the KK version of the voting app repo
$ cd example-voting-app-kk/vote
# build the image
$ docker build -t test-voter .
# Try to run the image using docker run. This works:
$ docker run test-voter
# Try to run a pod with it. This does *not* work
$ kubectl run test-voter --image test-voter
$ kubectl get po test-voter
$ kubectl get po test-voter
NAME READY STATUS RESTARTS AGE
test-voter 0/1 ImagePullBackOff 0 7m46s
Describe shows that the problem is, K8s isn’t looking in the docker server:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 28s default-scheduler Successfully assigned default/test-voter to minikube
Normal BackOff 19s kubelet Back-off pulling image "test-voter"
Warning Failed 19s kubelet Error: ImagePullBackOff
Normal Pulling 4s (x2 over 27s) kubelet Pulling image "test-voter"
Warning Failed 3s (x2 over 19s) kubelet Failed to pull image "test-voter": Error response from daemon: pull access denied for test-voter, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Warning Failed 3s (x2 over 19s) kubelet Error: ErrImagePull
So for whatever reason, the obvious thing does not work with minikube. There are ways to do this (look up “skaffold k8s” for a way to do what you want here), but you need to do something special to get this to work.
I went through the minikube docs, and can confirm if you use
minikube image build -t my-image-name:my-tag .
that it will build the image where minikube can find it and
k run my-image --image my-image-name:my-tag --image-pull-policy=Never
then it will use your local copy, and won’t try docker hub; the --image-pull-policy=Never
is required.
Good on you for figuring out before I did.
Thank you much, your efforts are appreciated
The best solution is to build the docker image locally on the virtual machine and load that image to the minikube cluster through the following command:
minikube image load kodekloud/voting-app:latest
then check the image in the minikube cluster through:
minikube ssh
docker images
and see whether the loaded image is present in the minikube cluster.
This solved my problem.