<p>so I need to connect to the python kubernetes client through a pod. I've been trying to use <code>config.load_incluster_config()</code>, basically following the example from <a href="https://github.com/kubernetes-client/python/blob/master/examples/in_cluster_config.py" rel="noreferrer">here</a>. However it's throwing these errors. </p>

<pre><code>  File "/Users/myname/Library/Python/2.7/lib/python/site-packages/kubernetes/config/incluster_config.py", line 93, in   load_incluster_config
  cert_filename=SERVICE_CERT_FILENAME).load_and_set()
  File "/Users/myname/Library/Python/2.7/lib/python/site- packages/kubernetes/config/incluster_config.py", line 45, in load_and_set
  self._load_config()
  File "/Users/myname/Library/Python/2.7/lib/python/site-packages/kubernetes/config/incluster_config.py", line 51, in _load_config
  raise ConfigException("Service host/port is not set.")
</code></pre>

<p>I'm using Python 2.7 and Minikube 
Any hints or suggestions would be really appreciated. thank you.</p>

<blockquote>
  <p>so I need to connect to that pod somehow through the python api</p>
</blockquote>

<p>I am pretty sure you misunderstood <a href="https://stackoverflow.com/a/51035715/225016">my answer</a>, and/or I misunderstood your question. One should only use <code>load_incluster_config</code> when ... in-cluster ... otherwise it will attempt to use <code>/var/run/secrets/kubernetes.io/etcetc</code> and not find them (above and beyond the missing env-var in the actual error you cited above). However, if you had guarded the <code>load_incluster_config()</code> with the <code>if os.getenv('KUBERNETES_SERVICE_HOST'):</code> as suggested, then it wouldn't run that code and this question here wouldn't be a problem.</p>

<p>If you have built a docker image, but <em>did not deploy it into kubernetes</em>, then that wasn't clear.</p>

<hr>

<p>If you just want to use the python api to <em>access</em> the cluster, but not from <em>within</em> the cluster, <code>config.load_kube_config()</code> is in fact the correct method call, but you will absolutely need to provide a working <code>kubeconfig</code>, whether at <code>/root/.kube/config</code> or at another place specified by the env-var <code>KUBECONFIG</code> (I mean, usually; I haven't specifically looked into the python library to see if that env-var is honored).</p>
