<p>I have a node outside of my Kubernetes cluster running a web service that I need to access from inside a Pod. The documentation mentions using a Service without a Selector here:
<a href="http://kubernetes.io/docs/user-guide/services/" rel="noreferrer">http://kubernetes.io/docs/user-guide/services/</a></p>

<p>So I created a service like so:</p>

<pre><code>{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
        "name": "my-service"
    },
    "spec": {
        "ports": [
            {
                "protocol": "TCP",
                "port": 8082,
                "targetPort": 8082
            }
        ]
    }
}
</code></pre>

<p>Then created my endpoint:</p>

<pre><code>{
    "kind": "Endpoints",
    "apiVersion": "v1",
    "metadata": {
        "name": "my-service"
    },
    "subsets": [
        {
            "addresses": [
                { "ip": "128.115.198.7" }
            ],
            "ports": [
                { "port": 8082 }
            ]
        }
    ]
}
</code></pre>

<p>Test App:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: ta-p
spec:
  restartPolicy: Never
  containers:
  - name: ta-c
    image: "centos:7"
    command: ["/bin/bash","-c", "sleep 100000"]
  nodeSelector:
    node: "kube-minion-1"
</code></pre>

<p>Remote into Pod doing:</p>

<pre><code>kubectl exec ta-p -c ta-c -i --tty -- /bin/bash
</code></pre>

<p>Then whenever I <code>kubectl exec</code> into a container in my pod and try to ping or curl my-service like so:</p>

<pre><code>curl http://my-service/api/foo
</code></pre>

<p>it times out. I have verified DNS is setup and working correctly. However, I have even tried using the IP address directly bound to the service:</p>

<pre><code>curl http://10.0.124.106:8082/api/foo
</code></pre>

<p>Anyone have any suggestions?</p>

<p>Note: A better way to solve this now is using <code>externalName</code> on the Service. This will add a <code>CNAME</code> record to the internal Kubernetes DNS:
<a href="https://github.com/kubernetes/community/blob/master/contributors/design-proposals/network/service-external-name.md" rel="nofollow noreferrer">https://github.com/kubernetes/community/blob/master/contributors/design-proposals/network/service-external-name.md</a></p>

<p>This feature was shipped with Kubernetes 1.4.</p>
