<p>I am using Docker for Windows (docker-desktop) which ships with a small single node kubernetes instance. I have a scenario where my pods needs to communicate with some external services running on the same localhost(windwos 10 machine), but outside of the k8s cluster.</p>

<p>I know that I can use <code>kubernetes.docker.internal</code> from within the cluster to reach my <code>node/localhost</code>. But unfortunately the pods has some default connection string within the image which I don't want to change - say the pods are by default trying to connect to a dns string - "my-server". So in my scenario, I want to define a K8s service with name "my-server" which has an Endpoint reference to kubernetes.docker.internal so that the kube-proxy will route that correctly to my localhost which is my windows 10 machine.</p>

<p>Is this somehow possible? I have already checked <a href="https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-mapping-external-services" rel="nofollow noreferrer">this</a> solution, but it talks about external services running on some other node or cloud. I am also considering the local machine hostname as an ExternalName, but this is not entirely reliable in dns resolution for my usecase. So I really want to use the <code>kubernetes.docker.internal</code> as a service endpoint. Any thoughts?</p>

<p>One trick I've used was to forward an internal IP address back to 127.0.0.1
It worked perfectly.</p>
<pre class="lang-sh prettyprint-override"><code># linux
sudo iptables -t nat -A OUTPUT -p all -d 10.0.100.100 -j DNAT --to-destination 127.0.0.1

# osx 
sudo ifconfig lo0 alias 10.0.100.100
</code></pre>
