<p>We have a requirement to connect from a POD in GKE to service running on a VM on it's internal IP address. </p>

<p><a href="https://i.stack.imgur.com/nPr6k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nPr6k.png" alt="enter image description here"></a></p>

<p>The K8s cluster and the VM are on different network so we setup VPC Peering between these nets: </p>

<p><a href="https://i.stack.imgur.com/Ncviz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ncviz.png" alt="enter image description here"></a></p>

<p>As how to point to an external IP, we applied a service without a selector as discussed here: </p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors</a></p>

<p>The POD should connect to the internal IP of the VM through this service, the service and endpoint description is: </p>

<p>kubectl describe svc vm-proxy</p>

<pre><code>Name:              vm-proxy
Namespace:         test-environment
Labels:            &lt;none&gt;
Annotations:       &lt;none&gt;
Selector:          &lt;none&gt;
Type:              ClusterIP
IP:                10.59.251.146
Port:              &lt;unset&gt;  8080/TCP
TargetPort:        8080/TCP
Endpoints:         10.164.0.10:8080
Session Affinity:  None
Events:            &lt;none&gt;
</code></pre>

<p>Whereby the Endpoint, the internal IP of the VM is, en the 
Service IP is allocated by K8s. </p>

<p>The pod simply sets up an http connection to the IP of the Service, but connection is re-fused. (Connection timeout eventually). </p>

<p>The use case is pretty straightforward, and documented on k8s documentation, giving the example of connecting to a DB running on a VM. However it doesn't work in our case, and we are not sure if our setup is wrong or this is simply not possible, using an internal IP of a VM. </p>

<p>I reproduced your issue and it worked fine for me. This is what I did:</p>

<ol>
<li>Create 2 networks (one of them (demo) on 172.16.0.0/16, the other one is my default network, set on 10.132.0.0/20).</li>
<li>Set up VPC peering.</li>
<li>Created a VM in demo network. It got assigned 172.16.0.2</li>
<li>Created the service as you described (with the endpoint pointing to 172.16.0.2).</li>
<li>curl from the pod to the service IP and got 200!</li>
</ol>

<p>If the steps are right, but your configuration is not working, I'd like to know your network IP ranges. Both of them.</p>
