<p>I try to deploy one docker image that I build and is not on a public or private registry. </p>

<p>I use the <code>imagePullPolicy: IfNotPresent</code> for the Kubernetes deployment.</p>

<p>I use kubeadm v1.12 the error:</p>

<pre><code>Normal   Scheduled       35s                default-scheduler       Successfully assigned default/test-777dd9bc96-chgc7 to ip-10-0-1-154
Normal   SandboxChanged  32s                kubelet, ip-10-0-1-154  Pod sandbox changed, it will be killed and re-created.
Normal   BackOff         30s (x3 over 31s)  kubelet, ip-10-0-1-154  Back-off pulling image "test_kube"
Warning  Failed          30s (x3 over 31s)  kubelet, ip-10-0-1-154  Error: ImagePullBackOff
Normal   Pulling         15s (x2 over 34s)  kubelet, ip-10-0-1-154  pulling image "test"
Warning  Failed          13s (x2 over 33s)  kubelet, ip-10-0-1-154  Failed to pull image "test": rpc error: code = Unknown desc = Error response from daemon: pull access denied for test_kube, repository does not exist or may require 'docker login'
Warning  Failed          13s (x2 over 33s)  kubelet, ip-10-0-1-154  Error: ErrImagePull
</code></pre>

<p>My deployment file: </p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
vmetadata:
  name: test-kube
spec:
  template:
    metadata:
  labels:
    app: test
spec:
  containers:
  - name: test
    image: test
    imagePullPolicy: IfNotPresent
    ports:
    - containerPort: 3000
    env:
    - name: SECRET-KUBE
      valueFrom:
        secretKeyRef:
          name: secret-test
          key: username
</code></pre>

<blockquote>
  <p>docker images]</p>
</blockquote>

<pre><code>REPOSITORY  TAG
test   latest 
test   test  
</code></pre>

<p>In the deployment file i tried with     </p>

<blockquote>
  <p>image: test  and with image: test:test</p>
</blockquote>

<p>The same error:</p>

<blockquote>
  <p>Error: ErrImagePull</p>
</blockquote>

<ul>
<li>create a secret based on docker registry user with pull/push rights</li>
<li>use it as imagePullSecret</li>
</ul>

<p>OR</p>

<ul>
<li>pre-pull the image on the deployment node</li>
</ul>

<p><strong>Details of creating secret and usage:</strong></p>

<p>A Kubernetes cluster uses the Secret of docker-registry type to authenticate with a container registry to pull a private image.</p>

<p>Create this Secret, naming it regcred:</p>

<pre><code>kubectl create secret docker-registry regcred --docker-server=&lt;your-registry-server&gt; --docker-username=&lt;your-name&gt; --docker-password=&lt;your-pword&gt; --docker-email=&lt;your-email&gt;
</code></pre>

<p>where:</p>

<pre><code>&lt;your-registry-server&gt; is your Private Docker Registry FQDN. (https://index.docker.io/v1/ for DockerHub)
&lt;your-name&gt; is your Docker username.
&lt;your-pword&gt; is your Docker password.
&lt;your-email&gt; is your Docker email.
</code></pre>

<p>Then create a pod that uses that secret:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: &lt;your-private-image&gt;
  imagePullSecrets:
  - name: regcred
</code></pre>

<p>For the local image use case please see this post:</p>

<p><a href="https://stackoverflow.com/questions/40144138/pull-a-local-image-to-run-a-pod-in-kubernetes">Pull a local image to run a pod in Kubernetes</a></p>
