<p>I am on Windows and used Docker Desktop to deploy a local Kubernetes cluster using WSL 2. I tried to deploy a pod and expose it through a NodePort service so I could access it outside the cluster, but it is not working.</p>
<p>Here are the commands to reproduce the scenario:</p>
<pre><code>kubectl create deployment echoserver --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment echoserver --type=NodePort --port=8080
</code></pre>
<p>Trying to open <code>NODE_IP:EXPOSED_PORT</code> in the browser or running the netcat command <code>nc NODE_IP EXPOSED_PORT</code> and trying to send a message (from either WSL or Windows) does not work.</p>
<ul>
<li><code>NODE_IP</code> is the internal IP of the Docker Desktop K8S node (obtained by seeing the <code>INTERNAL-IP</code> column on the command <code>kubectl get nodes -o wide</code>)</li>
<li><code>EXPOSED_PORT</code> is the node port exposed by the service (obtained by seeing the field <code>NodePort</code> on command <code>kubectl describe service echoserver</code>)</li>
</ul>
<p>Opening the URL on the browser should be met with <a href="https://i.stack.imgur.com/G8hPk.jpg" rel="nofollow noreferrer">this</a> page. However, you will get a generic error response saying the browser couldn't reach the URL.</p>
<p>Sending a message with the netcat command should be met with a 400 Bad Request response, as it will not be a properly formatted HTTP request. However, you will not get any response at all or the TCP connection may not even be made in the 1st place.</p>
<p>Trying to communicate with the service and/or the pod from inside the cluster, for example, through another pod, works perfectly.
Using the command <code>kubectl port-forward deployment/echoserver 2311:8080</code> to port forward the deployment locally and then either accessing <code>localhost:2311</code> in the browser or through netcat also work perfectly (in both WSL and Windows).</p>

Tiago Silva
<p>If you want to access it not using localhost you should use your <code>&lt;windows_hosts's_IP:NodePort&gt;</code>.</p>
<p>So having your deployment and service deployed:</p>
<pre><code>$kubectl get svc,deploy
NAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
service/echoserver   NodePort    10.105.169.2   &lt;none&gt;        8080:31570/TCP   4m12s
service/kubernetes   ClusterIP   10.96.0.1      &lt;none&gt;        443/TCP          5m3s

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/echoserver   1/1     1            1           4m19s
</code></pre>
<p>You can either access it by using <code>localhost:31570</code> or &lt;windows_hosts's_IP:NodePort&gt;.</p>
<p>In my case <code>192.168.0.29</code> is my Windows host's IP:</p>
<pre><code>curl.exe 192.168.0.29:31570
CLIENT VALUES:
client_address=192.168.65.3
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://192.168.0.29:8080/
</code></pre>
