<p>I am using <a href="https://github.com/kubernetes-client/python" rel="nofollow noreferrer">the official Python Kubernetes client</a> to create Pods dynamically:</p>

<pre><code>kube_api.create_namespaced_pod(body=pod_spec, namespace='default')
</code></pre>

<p>However it looks like Kubernetes tries to pull the image assuming my local registry is using <code>v1</code>:</p>

<blockquote>
  <p>Failed to pull image
  "localhost:5000/foo:bar": rpc error: code
  = Unknown desc = Error while pulling image: Get <a href="http://localhost:5000/v1/repositories/foo/images" rel="nofollow noreferrer">http://localhost:5000/v1/repositories/foo/images</a>: dial
  tcp 127.0.0.1:5000: getsockopt: connection refused</p>
</blockquote>

<p>This doesn't work, as my local registry is using <code>v2</code> and apparently it is not backward compatible.</p>

<p>To fix this I see two solutions: </p>

<ul>
<li><p>Changing Kubernetes' (or Docker's?) config to change the API to v2. I've been searching a lot but can't find how to do that.</p></li>
<li><p>Creating a <code>v1</code> registry. But I couldn't find any docker image for it, and this sounds like a bad solution as <code>v1</code> is deprecated.</p></li>
</ul>

MasterScrat
<p>The error message appears to indicate the problem is not with the API version - docker was not even able to connect to your registry (<em>dial tcp 127.0.0.1:5000: getsockopt: connection refused</em>).</p>

<p>This means that your registry is simply not reachable at the given address, most likely because it is not on the same host.</p>

<p>Note that if you are running k8s in anything other than minikube (where everything is on the same host), you probably have multiple hosts and a 'local' registry is not a solution at all - you would have to have a copy of that registry on every host that is part of your cluster.</p>

<p>If you are running minikube (or otherwise have just a single host where kubernetes runs AND that's the same host where you ran the registry), check that the registry is actually on port 5000 and that the port is exposed to the host network (if you started it with a <code>docker</code> command, it should have been with <code>-p 5000:5000</code> option).</p>
