We have a requirement to connect from a POD in GKE to service running on a VM on it's internal IP address.
The K8s cluster and the VM are on different network so we setup VPC Peering between these nets:
As how to point to an external IP, we applied a service without a selector as discussed here:
https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors
The POD should connect to the internal IP of the VM through this service, the service and endpoint description is:
kubectl describe svc vm-proxy
Name: vm-proxy
Namespace: test-environment
Labels: <none>
Annotations: <none>
Selector: <none>
Type: ClusterIP
IP: 10.59.251.146
Port: <unset> 8080/TCP
TargetPort: 8080/TCP
Endpoints: 10.164.0.10:8080
Session Affinity: None
Events: <none>
Whereby the Endpoint, the internal IP of the VM is, en the Service IP is allocated by K8s.
The pod simply sets up an http connection to the IP of the Service, but connection is re-fused. (Connection timeout eventually).
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.
I reproduced your issue and it worked fine for me. This is what I did:
If the steps are right, but your configuration is not working, I'd like to know your network IP ranges. Both of them.