<p>On an on-premise Kubernetes Cluster, how to use locally build images in the Kubernetes deployment manifest without having it uploaded to a Docker Registry (like Docker Hub)?</p>

JucaPirama
<p>You already have an on-prem machine. All you need to do is just do a docker build from your dockerfile, do a suitable docker tag and create the manifest.</p>

<p>Kubernetes doesn't directly pull from the registry. First it searches for the image on local storage and then docker registry.</p>

<ol>
<li><p>Pull latest nginx image</p>

<p><strong>docker pull nginx</strong></p>

<p><strong>docker tag nginx:latest test:test8970</strong></p></li>
<li><p>Create a deployment
<code>kubectl run test --image=test:test8970</code>
It won't go to docker registry to pull the image. It will bring up the pod instantly.
<a href="https://i.stack.imgur.com/yKGIw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yKGIw.png" alt="enter image description here"></a></p></li>
<li><p>And if <strong>image is not present on local machine</strong> it will try to pull from docker registry and fail with <strong>ErrImagePull</strong> error.
<a href="https://i.stack.imgur.com/1hAcD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1hAcD.png" alt="enter image description here"></a></p></li>
<li><p>Also if you change the <strong>imagePullPolicy: Never</strong>. It will never look for the registry to pull the image and will fail if image is not found with error <strong>ErrImageNeverPull</strong>.
<a href="https://i.stack.imgur.com/JjhVo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JjhVo.png" alt="enter image description here"></a></p></li>
</ol>

<pre><code>kind: Deployment
metadata:
  labels:
    run: test
  name: test
spec:
  replicas: 1
  selector:
    matchLabels:
      run: test
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: test
    spec:
      containers:
      - image: test:test8070
        name: test
        imagePullPolicy: Never
</code></pre>
