<p>I have a Pod that occasionally needs to call itself by its own host-name.   I have a Deployment set up that ultimately creates the Pod, and a Service in place.  I'm able to use the service name from a different Pod within my cluster, but the Pod cannot call itself using its host-name.  This is something that works with Minikube v0.17.1 with Kubernetes version 1.5.3, but upgrading either Minikube or the Kubernetes version seems to break things.  This also works on our deployed / server version of Kubernetes.</p>

<p>Did something change that I need to take account of in my Pod / Service setup?  How do I go about getting past this?</p>

<h2>How things should work</h2>

<p>Running Minikube version 0.17.1:</p>

<p>Start Minikube:</p>

<pre><code>$ minikube start
Starting local Kubernetes cluster...
Starting VM...
SSH-ing files into VM...
Setting up certs...
Starting cluster components...
Connecting to cluster...
Setting up kubeconfig...
Kubectl is now configured to use the cluster.

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"2017-01-12T04:57:25Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"1970-01-01T00:00:00Z", GoVersion:"go1.7.3", Compiler:"gc", Platform:"linux/amd64"}

$ minikube version
minikube version: v0.17.1
</code></pre>

<p>Deploy minimal test images (yaml definition below): </p>

<pre><code>kubectl apply -f deploy_python.yaml
</code></pre>

<p>Exec into the python2 image, and verify connection to python image:</p>

<pre><code>$ kubectl exec -it python2-1281934109-k015g bash
root@python2-1281934109-k015g:/# curl python:12345 --connect-timeout 10
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;title&gt;Directory listing for /&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Directory listing for /&lt;/h1&gt;
&lt;hr&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=".dockerenv"&gt;.dockerenv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="bin/"&gt;bin/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="boot/"&gt;boot/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="dev/"&gt;dev/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="etc/"&gt;etc/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="home/"&gt;home/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="lib/"&gt;lib/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="lib64/"&gt;lib64/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="media/"&gt;media/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="mnt/"&gt;mnt/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="opt/"&gt;opt/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="proc/"&gt;proc/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="root/"&gt;root/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="run/"&gt;run/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="sbin/"&gt;sbin/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="srv/"&gt;srv/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="sys/"&gt;sys/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="tmp/"&gt;tmp/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="usr/"&gt;usr/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="var/"&gt;var/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Exec into python image and verify connection to self:</p>

<pre><code>$ kubectl exec -it python-2555691705-5j0f9 bash
root@python-2555691705-5j0f9:/# curl python:12345 --connect-timeout 10
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;title&gt;Directory listing for /&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Directory listing for /&lt;/h1&gt;
&lt;hr&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=".dockerenv"&gt;.dockerenv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="bin/"&gt;bin/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="boot/"&gt;boot/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="dev/"&gt;dev/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="etc/"&gt;etc/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="home/"&gt;home/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="lib/"&gt;lib/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="lib64/"&gt;lib64/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="media/"&gt;media/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="mnt/"&gt;mnt/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="opt/"&gt;opt/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="proc/"&gt;proc/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="root/"&gt;root/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="run/"&gt;run/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="sbin/"&gt;sbin/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="srv/"&gt;srv/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="sys/"&gt;sys/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="tmp/"&gt;tmp/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="usr/"&gt;usr/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="var/"&gt;var/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>That's a success.  By creating a Deployment and a Service, I'm able to make requests to the referenced Pod from any other Pod in the cluster.</p>

<h2>The way it works in newer versions</h2>

<p>(Stop and delete running Minikube.)<br>
Start Minikube, specifying Kubernetes version 1.7.0:</p>

<pre><code>$ minikube start --kubernetes-version=v1.7.0
Starting local Kubernetes cluster...
Starting VM...
SSH-ing files into VM...
Downloading localkube binary
137.48 MB / 137.48 MB [============================================] 100.00% 0s
Setting up certs...
Starting cluster components...
Connecting to cluster...
Setting up kubeconfig...
Kubectl is now configured to use the cluster.

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"2017-01-12T04:57:25Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.0", GitCommit:"d3ada0119e776222f11ec7945e6d860061339aad", GitTreeState:"clean", BuildDate:"2017-06-30T10:17:58Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<p>Deploy minimal test images (yaml definition below):</p>

<pre><code>$ kubectl apply -f deploy_python.yaml
service "python" created
deployment "python" created
deployment "python2" created
</code></pre>

<p>Exec into python 2 image, and verify connection to python image:</p>

<pre><code>$ kubectl exec -it python2-380393367-ztgkq bash
root@python2-380393367-ztgkq:/# curl python:12345 --connect-timeout 10
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;title&gt;Directory listing for /&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Directory listing for /&lt;/h1&gt;
&lt;hr&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=".dockerenv"&gt;.dockerenv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="bin/"&gt;bin/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="boot/"&gt;boot/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="dev/"&gt;dev/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="etc/"&gt;etc/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="home/"&gt;home/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="lib/"&gt;lib/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="lib64/"&gt;lib64/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="media/"&gt;media/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="mnt/"&gt;mnt/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="opt/"&gt;opt/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="proc/"&gt;proc/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="root/"&gt;root/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="run/"&gt;run/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="sbin/"&gt;sbin/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="srv/"&gt;srv/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="sys/"&gt;sys/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="tmp/"&gt;tmp/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="usr/"&gt;usr/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="var/"&gt;var/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Exec into python image and attempt connection to self:</p>

<pre><code>$ kubectl exec -it python-2168884431-gls2j bash
root@python-2168884431-gls2j:/# curl python:12345 --connect-timeout 10
curl: (28) Connection timed out after 10000 milliseconds
</code></pre>

<p>Yaml file, deploy_python.yaml:</p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: python
spec:
  selector:
    app: python
  ports:
  - port: 12345
    targetPort: 12345
    name: http
---    
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: python
  labels:
    app: python
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: python
    spec:
      containers:
      - image: python
        name: python
        command: ["python"]
        args: ["-m", "http.server", "12345" ]
        ports:
        - containerPort: 12345
---    
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: python2
  labels:
    app: python2
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: python2
    spec:
      containers:
      - image: python
        name: python2
        command: ["python"]
        args: ["-m", "http.server", "12345" ]
        ports:
        - containerPort: 12345
</code></pre>

<p>This is a known bug in newer versions of kubernetes / minikube and is being tracked here: </p>

<p><a href="https://github.com/kubernetes/kubernetes/issues/20475" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/20475</a></p>

<p>The current accepted workaround (<a href="https://github.com/kubernetes/kubernetes/issues/20475#issuecomment-190995739" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/20475#issuecomment-190995739</a>) is to ssh into your minikube vm and run a specific ip link command.</p>

<pre><code>minikube ssh
sudo ip link set docker0 promisc on 
</code></pre>

<p>I have tested this workaround and it seems to work for me.</p>
