<p>I have a deployment on Minikube for a .Net Core 5 API that is not returning response when I try to invoke it from Postman. When I run a GET from Postman to the exposed port (32580) and endpoint <code>http:// localhost:32580/api/platforms/</code> I get:</p>
<pre><code>Error: getaddrinfo ENOTFOUND
</code></pre>
<p>Oddly enough I was previously getting a <code>Connection refused</code> (before I restarted my Docker desktop). The container works perfectly when I use Docker but once I deployed it to Kubernetes context it no longer works.</p>
<p>I am unsure how exactly I can debug the container and get more meaningful error detail.</p>
<p>I have tried the following:</p>
<ol>
<li>Checking status of Deployment (platforms-depl)</li>
</ol>
<hr />
<pre><code>NAME             READY   UP-TO-DATE   AVAILABLE   AGE 
hello-minikube   1/1     1            1           134d
ping-google      0/1     1            0           2d2h
platforms-depl   1/1     1            1           115m
</code></pre>
<ol start="2">
<li>Checking status of Pod (platforms-depl-84d7f5bdc6-sgxcp)</li>
</ol>
<hr />
<pre><code>NAME                              READY   STATUS             RESTARTS   AGE 
hello-minikube-6ddfcc9757-6mfmf   1/1     Running            21         134d
ping-google-5f84d66fcc-kbb7j      0/1     ImagePullBackOff   151        2d2h
platforms-depl-84d7f5bdc6-sgxcp   1/1     Running            1          115m
</code></pre>
<ol start="3">
<li>Running <code>kubectl describe pod platforms-depl-84d7f5bdc6-sgxcp</code> gives below output (truncated):</li>
</ol>
<hr />
<pre><code>Status:       Running
IP:           172.17.0.3
IPs:
  IP:           172.17.0.3
Controlled By:  ReplicaSet/platforms-depl-84d7f5bdc6
Containers:
  platformservice:
    Container ID:   docker://a73ce2dc737206e502df94066247299a6dcb6a038087d0f42ffc6e3b9dd194dd
    Image:          golide/platformservice:latest
    Image ID:       docker-pullable://golide/platformservice@sha256:bbed5f1d7238d2c466a6782333f8512d2e464f94aa64d8670214646a81b616c7      
    Port:           &lt;none&gt;
    Host Port:      &lt;none&gt;
    State:          Running
      Started:      Tue, 28 Sep 2021 15:12:22 +0200
    Ready:          True
    Restart Count:  0
    Environment:    &lt;none&gt;
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-rl5kf (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
</code></pre>
<ol start="4">
<li><p>When I run <code>docker ps</code> I cannot see the container and it also doesn't appear in the list of running containers in VS Code Docker/Containers extension.</p>
</li>
<li><p><code>kubectl get services</code> gives me the following:</p>
</li>
</ol>
<hr />
<pre><code>NAME                    TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE 
hello-minikube          NodePort    10.99.23.44    &lt;none&gt;        8080:31378/TCP   134d
kubernetes              ClusterIP   10.96.0.1      &lt;none&gt;        443/TCP          134d
paymentsapi             NodePort    10.111.243.3   &lt;none&gt;        5000:30385/TCP   108d
platformnpservice-srv   NodePort    10.98.131.95   &lt;none&gt;        80:32580/TCP     2d2h
</code></pre>
<p>Then tried pinging the ClusterIP:</p>
<pre><code>Pinging 10.98.131.95 with 32 bytes of data:
Request timed out.
Request timed out.
 
Ping statistics for 10.98.131.95:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), 
</code></pre>
<p>What am I missing?</p>
<p>I read in suggestions I have to exec into the pod so that I get meaningful output but I'm not sure of the exact commands to run. I tried:</p>
<pre><code>kubectl exec POD -p platforms-depl-84d7f5bdc6-sgxcp
</code></pre>
<p>only to get error:</p>
<pre><code>kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Error from server (NotFound): pods &quot;POD&quot; not found
</code></pre>
<p>My environment Docker Linux containers with WSL2 on Windows 10.</p>
<p>What am I missing?</p>

<p>First thing which is worth to note that generally minikube has a lot of possible <a href="https://minikube.sigs.k8s.io/docs/drivers/" rel="nofollow noreferrer">drivers to choose from</a> - in my case I found the <code>docker</code> drive to be most easiest to use.</p>
<p>My setup is:</p>
<ul>
<li>WSL2</li>
<li>Docker Desktop with <a href="https://docs.docker.com/desktop/windows/wsl/" rel="nofollow noreferrer">Docker Desktop WLS 2 backend enabled</a></li>
</ul>
<p>I used following command to start minikube: <code>minikube start --driver=docker</code>.
If you are using other driver I suggest moving to the <code>docker</code> one.</p>
<p>Answering your question:</p>
<p><em>What am I missing ?</em></p>
<p>By setting nodePort service type you are exposing your deployment / replica set using node IP address which not accessible from Windows host (when using <code>docker</code> driver). It's because all Kubernetes cluster resources are setup inside Docker container, which is isolated.</p>
<p>However, minikube offers simple solution to make available specified nodePort service to your Windows host. <a href="https://minikube.sigs.k8s.io/docs/commands/service/" rel="nofollow noreferrer">Just run <code>minikube service</code> command which will create a tunnel</a>. Let's check it.</p>
<p>You setup <code>platformnpservice-srv</code> service so you need to use this name in <code>minikube service</code> command instead of <code>testmini</code> which I used:</p>
<pre><code>minikube service --url testmini
🏃  Starting tunnel for service testmini.
|-----------|----------|-------------|------------------------|
| NAMESPACE |   NAME   | TARGET PORT |          URL           |
|-----------|----------|-------------|------------------------|
| default   | testmini |             | http://127.0.0.1:33849 |
|-----------|----------|-------------|------------------------|
http://127.0.0.1:33849
❗  Because you are using a Docker driver on linux, the terminal needs to be open to run it.
</code></pre>
<p>Note the last sentence - we need to keep this terminal window to be open, otherwise the tunnel won't be established.
Now, on my Windows host, in the browser I'm opening: <code>http://127.0.0.1:33849/api/platforms</code> website. The output is following:</p>
<pre><code>[{&quot;id&quot;:1,&quot;name&quot;:&quot;Dot Net&quot;,&quot;publisher&quot;:&quot;Microsoft&quot;,&quot;cost&quot;:&quot;Free&quot;},{&quot;id&quot;:2,&quot;name&quot;:&quot;Linux&quot;,&quot;publisher&quot;:&quot;Ubuntu&quot;,&quot;cost&quot;:&quot;Free&quot;},{&quot;id&quot;:3,&quot;name&quot;:&quot;Kubernetes&quot;,&quot;publisher&quot;:&quot;CNCF&quot;,&quot;cost&quot;:&quot;Free&quot;},{&quot;id&quot;:4,&quot;name&quot;:&quot;SQL Express&quot;,&quot;publisher&quot;:&quot;Microsoft&quot;,&quot;cost&quot;:&quot;Free&quot;}]
</code></pre>
<p>Voila! Seems that everything is working properly.</p>
<p>Also, other notes:</p>
<blockquote>
<p>tried pinging the ClusterIP</p>
</blockquote>
<p>The ClusterIP is <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">internal address which is only accessible from the cluster</a>, so you can't ping it from Windows host neither WSL2.</p>
<blockquote>
<p><em>kubectl exec POD -p platforms-depl-84d7f5bdc6-sgxcp</em></p>
</blockquote>
<p>As output suggests, you need to <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#exec" rel="nofollow noreferrer">specify command you want to exec on the pod</a>. If you just want to get bash shell, use the following:</p>
<pre><code>kubectl exec -it platforms-depl-84d7f5bdc6-sgxcp -- sh
</code></pre>
