Why is my Kubernetes deployment registering as unavailable even though it runs in Docker?

5/11/2019

I have a docker image I have created that works on docker like this (local docker)n...

docker run -p 4000:8080 jrg/hello-kerb

Now I am trying to run it as a Kubernetes pod. To do this I create the deployment...

kubectl create deployment hello-kerb --image=jrg/hello-kerb

Then I run kubectl get deployments but the new deployment comes as unavailable...

NAME         DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
hello-kerb   1         1         1            0           17s

I was using this site as the instructions. It shows that the status should be available...

NAME         DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
hello-node   1         1         1            1           1m

What am I missing? Why is the deployment unavailable?

UPDATE

$ kubectl get pod
NAME                          READY   STATUS             RESTARTS   AGE
hello-kerb-6f8f84b7d6-r7wk7   0/1     ImagePullBackOff   0          12s
-- Jackie
docker
kubernetes

2 Answers

5/11/2019

If you are running a local image (from docker build) it is directly available to the docker daemon and can be executed. If you are using a remote daemon, f.e. in a kubernetes cluster, it will try to get the image from the default registry, since the image is not available locally. This is usually dockerhub. I checked https://hub.docker.com/u/jrg/ and there seems to be no repository and therefore no jrg/hello-kerb

So how can you solve this? When using minikube, you can build (and provide) the image using the docker daemon that is provided by minikube.

eval $(minikube docker-env)
docker build -t jrg/hello-kerb .

You could also provide the image at a registry that is reachable from your container runtime in the kubernetes cluster, f.e. dockerhub.

-- Thomas
Source: StackOverflow

5/11/2019

I solved this by using kubectl edit deployment hello-kerb then finding "imagePullPolicy" (:/PullPolicy). Finally I changed the value from "Always" to "Never". After saving this when I run kubectl get pod it shows...

NAME                          READY   STATUS    RESTARTS   AGE
hello-kerb-6f744b6cc5-x6dw6   1/1     Running   0          6m 

And I can access it.

-- Jackie
Source: StackOverflow