<p>As described in the <a href="https://microk8s.io/docs/working" rel="noreferrer">doc</a> (based <a href="https://stackoverflow.com/questions/55549522/how-to-configure-kubernetes-microk8s-to-use-local-docker-images">on</a>). </p>

<p>I am on Ubuntu as a host OS.</p>

<pre><code>docker --version
</code></pre>

<blockquote>
  <p>Docker version 18.09.6, build 481bc77</p>
</blockquote>

<pre><code>microk8s 1.14/beta
</code></pre>

<hr>

<p>Enable local registry for <code>microk2s</code>:</p>

<pre><code>microk8s.enable registry
</code></pre>

<p>Checking:</p>

<pre><code>watch microk8s.kubectl get all --all-namespaces
</code></pre>

<blockquote>
  <p>container-registry   pod/registry-577986746b-v8xqc 1/1     Running            0          36m</p>
</blockquote>

<p>Then:</p>

<p>Edit:</p>

<pre><code>sudo vim /etc/docker/daemon.json
</code></pre>

<p>Add this content:</p>

<pre><code>{
  "insecure-registries" : ["127.0.0.1:32000"]
}
</code></pre>

<p>Restart:</p>

<pre><code>sudo systemctl restart docker
</code></pre>

<p>Double checking, see if  insecure is applied:</p>

<pre><code>docker info | grep -A 2 Insecure
</code></pre>

<blockquote>
<pre><code>Insecure Registries:
 127.0.0.1:32000
 127.0.0.0/8
WARNING: No swap limit support
</code></pre>
</blockquote>

<p>Tag:</p>

<pre><code>docker tag my-registry/my-services/my-service:0.0.1-SNAPSHOT 127.0.0.1:32000/my-service
</code></pre>

<p>Checking:</p>

<pre><code>docker images
</code></pre>

<blockquote>
  <p>127.0.0.1:32000/my-service latest e68f8a7e4675 19 hours ago 540MB</p>
</blockquote>

<p>Pushing:</p>

<pre><code>docker push 127.0.01:32000/my-service
</code></pre>

<p>I see my image here: <a href="http://127.0.0.1:32000/v2/_catalog" rel="noreferrer">http://127.0.0.1:32000/v2/_catalog</a></p>

<p>In <code>deployment-local.yml</code> I have, now the proper image:</p>

<pre><code>...spec:
  containers:
    - name: my-service-backend
      image: 127.0.0.1:32000/my-service
      imagePullPolicy: Always ...
</code></pre>

<p>Then applying:</p>

<pre><code>envsubst &lt; ./.local/deployment-local.yml | microk8s.kubectl apply -f -
</code></pre>

<p>I see: <code>ContainerCreating</code></p>

<p>By: <code>microk8s.kubectl describe pods my-service-deployment-f85d5dcd5-cmd5</code></p>

<p>In the Events section:</p>

<pre><code>Events:
  Type     Reason     Age                 From                     Message
  ----     ------     ----                ----                     -------
  Normal   Scheduled  107s                default-scheduler        Successfully assigned default/my-service-deployment-f85d5dcd5-z75tr to my-desktop
  Normal   Pulling    25s (x4 over 106s)  kubelet, my-desktop  Pulling image "127.0.0.1:32000/my-service"
  Warning  Failed     25s (x4 over 106s)  kubelet, my-desktop  Failed to pull image "127.0.0.1:32000/my-service": rpc error: code = Unknown desc = failed to resolve image "127.0.0.1:32000/my-service:latest": no available registry endpoint: failed to do request: Head https://127.0.0.1:32000/v2/my-service/manifests/latest: http: server gave HTTP response to HTTPS client
  Warning  Failed     25s (x4 over 106s)  kubelet, my-desktop  Error: ErrImagePull
  Normal   BackOff    10s (x5 over 105s)  kubelet, my-desktop  Back-off pulling image "127.0.0.1:32000/my-service"
  Warning  Failed     10s (x5 over 105s)  kubelet, my-desktop  Error: ImagePullBackOff
</code></pre>

<p>Seems like my-service is stuck there.</p>

<p><strong>Q: What could be the reason?</strong></p>

<p><strong>UPDATE:</strong>
 changing all to <code>localhost</code> helped, meaning I could see now in the browser: <a href="http://localhost:32000/v2/_catalog" rel="noreferrer">http://localhost:32000/v2/_catalog</a> . </p>

<pre><code>{"repositories":["my-service"]}
</code></pre>

<p>But it worked only in Firefox.. weird. In chrome is pending..</p>

<p>Still:</p>

<pre><code>Events:
  Type     Reason          Age                    From                    Message
  ----     ------          ----                   ----                    -------
  Normal   Scheduled       161m                   default-scheduler       Successfully assigned default/my-service-deployment-6d4c5587df-72xvd to my-laptop
  Normal   Pulling         160m (x4 over 161m)    kubelet, my-laptop  Pulling image "localhost/my-service"
  Warning  Failed          160m (x4 over 161m)    kubelet, my-laptop  Failed to pull image "localhost/my-service": rpc error: code = Unknown desc = failed to resolve image "localhost/my-service:latest": no available registry endpoint: failed to do request: Head https://localhost/v2/my-service/manifests/latest: dial tcp 127.0.0.1:443: connect: connection refused
  Warning  Failed          160m (x4 over 161m)    kubelet, my-laptop  Error: ErrImagePull
  Warning  Failed          159m (x6 over 161m)    kubelet, my-laptop  Error: ImagePullBackOff
  Normal   BackOff         131m (x132 over 161m)  kubelet, my-laptop  Back-off pulling image "localhost/my-service"
  Normal   SandboxChanged  22m                    kubelet, my-laptop  Pod sandbox changed, it will be killed and re-created.
  Normal   Pulling         21m (x4 over 22m)      kubelet, my-laptop  Pulling image "localhost/my-service"
  Warning  Failed          21m (x4 over 22m)      kubelet, my-laptop  Failed to pull image "localhost/my-service": rpc error: code = Unknown desc = failed to resolve image "localhost/my-service:latest": no available registry endpoint: failed to do request: Head https://localhost/v2/my-service/manifests/latest: dial tcp 127.0.0.1:443: connect: connection refused
  Warning  Failed          21m (x4 over 22m)      kubelet, my-laptop  Error: ErrImagePull
  Warning  Failed          20m (x6 over 22m)      kubelet, my-laptop  Error: ImagePullBackOff
  Normal   BackOff         2m22s (x87 over 22m)   kubelet, my-laptop  Back-off pulling image "localhost/my-service"
</code></pre>

<p>Seems it tries to connect by https.. </p>

<p>-- </p>

<p>Ok.. had to add the port for the yml image: part. will accept the answer below. Thanks.</p>

ses
<p>In microk8s is a big different between <strong>localhost</strong> and <strong>127.0.0.1</strong>. As you mentioned, you were based on <a href="https://stackoverflow.com/questions/55549522/how-to-configure-kubernetes-microk8s-to-use-local-docker-images">this</a> Stack case and there user were using <strong>localhost</strong>.</p>

<p>The main issue here is error <code>no available registry endpoint: failed to do request:</code>. It means microk8s cannot find endpoint.</p>

<p>If you will run commend below, you will have the same output</p>

<pre><code>$ cat /var/snap/microk8s/current/args/containerd-template.toml | grep endpoint

endpoint = ["https://registry-1.docker.io"]
endpoint = ["http://localhost:32000"]
</code></pre>

<p>As you see in microk8s endpoint is <strong>localhost</strong> not 127.0.0.1</p>

<p>Please change image in deployment-local.yaml </p>

<pre><code>...spec:
  containers:
    - name: my-service-backend
      image: localhost/my-service
      imagePullPolicy: Always ...
</code></pre>

<p>Let me know if you will occur any other issues.</p>

<p>In my case I did not need tag and push image again with localhost, only change in YAML was required.</p>
