<p>I tried to deploy kubernetes using minikube using both from local docker image and from docker hub. But both doesn't work. </p>

<p>method-1: 
Using save and load the tar file, created the image and it is available to kubectl.</p>

<pre><code>root@arun-desktop-e470:/var/local/dprojects/elasticsearch# kubectl get pods --all-namespaces -o jsonpath="{..image}" |tr -s '[[:space:]]' '\n' |sort |uniq -c|grep elk
      2 elk/elasticsearch:latest
</code></pre>

<p>Execute below commands to create the deployment:</p>

<pre><code>kubectl run elastic --image=elk/elasticsearch:latest --port=9200
kubectl expose deployment elastic --target-port=9200 --type=NodePort
minikube service elastic --url
</code></pre>

<p>From kubectl describe pod command,</p>

<pre><code>  Warning  Failed     122m (x4 over 124m)   kubelet, minikube  Failed to pull image "elk/elasticsearch:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for elk/elasticsearch, repository does not exist or may require 'docker login'
</code></pre>

<p>Method-2:
I did pushed the image to my docker hub repository, (<a href="https://hub.docker.com/r/get2arun/elk/tags" rel="nofollow noreferrer">https://hub.docker.com/r/get2arun/elk/tags</a>) and then login to docker hub in the terminal and created the deployment again. </p>

<p>pushed to docker hub like below and hence I have permission to push and pull the images to my docker hub account. I have checked the "collaborators" under manage repositories and it has my docker hub id.</p>

<pre><code>root@arun-desktop-e470:~# docker push get2arun/elk:elasticsearch_v1
The push refers to repository [docker.io/get2arun/elk]
19b7091eba36: Layer already exists 
237c06a69e1c: Layer already exists 
c84fa0f11212: Layer already exists 
6ca6c301e2ab: Layer already exists 
76dd25653d9b: Layer already exists 
602956e7a499: Layer already exists 
bde76be259f3: Layer already exists 
2333287a7524: Layer already exists 
d108ac3bd6ab: Layer already exists 
elasticsearch_v1: digest: sha256:6f0b981b5dedfbe3f8e0291dc17fc09d32739ec3e0dab6195190ab0cc3071821 size: 2214
</code></pre>

<p>kubectl run elasticsearch-v2 --image=get2arun/elk:elasticsearch_v1 --port=9200</p>

<p>From kubectl describe pods command:</p>

<pre><code>  Normal   BackOff    21s               kubelet, minikube  Back-off pulling image "get2arun/elk:elasticsearch_v1"
  Warning  Failed     21s               kubelet, minikube  Error: ImagePullBackOff
  Normal   Pulling    7s (x2 over 24s)  kubelet, minikube  Pulling image "get2arun/elk:elasticsearch_v1"
  Warning  Failed     4s (x2 over 21s)  kubelet, minikube  Failed to pull image "get2arun/elk:elasticsearch_v1": rpc error: code = Unknown desc = Error response from daemon: pull access denied for get2arun/elk, repository does not exist or may require 'docker login'
</code></pre>

<p>I removed the proxy settings and tried from open wifi account but still seeing permission denied.</p>

<p>This error message is not sufficient to identify the issue and hoping there should be some way to narrow down these kind of issues.</p>

<ol>
<li>What happens in the background when Kubernetes is asked to use the
local docker image or pull the image from docker hub? </li>
<li>How to get all the log information when deployment is started ?</li>
<li>What are the other sources for logs</li>
</ol>

<p>In method-1, as the image is not pushed to the repository, you have to use the imagePullPolicy.</p>

<h3>Never try to pull the image</h3>

<pre><code>imagePullPolicy: Never
</code></pre>

<h3>Try to pull the image, if it is not present</h3>

<pre><code>imagePullPolicy: IfNotPresent
</code></pre>

<p>I think IfNotPresent is ideal, if you want to use local image / repository. Use as per your requirement.</p>

<h3>kubectl</h3>

<pre><code>kubectl run elastic --image=elk/elasticsearch:latest --port=9200 --image-pull-policy IfNotPresent
</code></pre>
