<p>After building a docker image named my-http I can create a deployment from it with</p>
<blockquote>
<p>kubectl create deploy http-deployment --image=my-http</p>
</blockquote>
<p>This will not pull the image because imagePullPolicy is Always.</p>
<p>So then run</p>
<blockquote>
<p>kubectl edit deploy http-deployment</p>
</blockquote>
<p>and change the imagePullPolicy to Never, then it runs.</p>
<p>But for automation purposes I've created a yaml to create the deployment and set the imagePullPolicy at the same time.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: http-deployment
spec:
    replicas: 3
    selector:
      matchLabels:
        app: http
    template:
      metadata:
        labels:
          app: http
      spec:
        containers:
        - name: my-http
          image: my-http
          imagePullPolicy: Never
          ports:
          - containerPort: 8080
</code></pre>
<p>Then apply -f and the pods start running but after a while a Crashloopbackoff starts with the message</p>
<blockquote>
<p>container image my-http already present on machine</p>
</blockquote>
<p>Apparently it has something to do with the container port but what to use for that port to get it running? There is no container running...</p>
<p>edit: the image already present is just informational, this is the last line in the pod description</p>
<blockquote>
<p>Warning  BackOff    7s (x8 over 91s)    kubelet, minikube  Back-off
restarting failed container</p>
</blockquote>

<p>If you using kubernetes cluster your images only available on the nodes that you build the images.</p>
<p>You have to push images to container registries then the kubernetes will try to pull the image to node that will running the container.</p>
<p>If you want to run the container in the nodes that you build the images you have to use NodeSelector, or PodAffinity.</p>
<p><a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/</a></p>
