<p>I have created 2 pods within the same cluster. One service is initialized as</p>
<pre><code>kubectl create deployment my-web --image=nginx --port=80
kubectl expose deployment my-web --target-port=80 --type=NodePort
</code></pre>
<p>to my understanding, this creates a deployment with one pod <code>my-web-&lt;string&gt;</code> and exposes a port. With <code>kubectl describe services my-web</code>, I find that the following information:</p>
<pre><code>Port:                     &lt;unset&gt;  80/TCP
TargetPort:               80/TCP
NodePort:                 &lt;unset&gt;  32004/TCP
Endpoints:                10.244.0.10:80
</code></pre>
<p>testing pod:</p>
<pre><code>kubectl run test-pod --image=nginx --restart=Never
</code></pre>
<p>this creates another pod and I try to curl the nginx of my-web pod with the command <code>curl 10.244.0.10:32004</code>. That request times out. But somehow it works when I use <code>curl 10.244.0:80</code>. Why is that? I thought the service was exposed on port 32004 outside the my-web pod?</p>
<p>Please also let me know what IP and port to curl from my host machine to access the my-web pod. I am running the cluster from minikube on MacOS.</p>
<p>Thanks for the help!</p>
<p>I try to curl the nginx of my-web pod with the command <code>curl 10.244.0.10:32004</code>. That request times out. But somehow it works when I use <code>curl 10.244.0:80</code>.</p>

loud_mouth
<p>NodePort is used to access a service within the cluster scope.
You might create a firewall rule that allows TCP traffic on your node port. Create a firewall rule that allows TCP traffic on port 32004.
On Ubuntu you can do something like:</p>
<blockquote>
<p>sudo ufw allow 32004/tcp</p>
</blockquote>
<p>And check port status with:</p>
<blockquote>
<p>sudo ufw status</p>
</blockquote>
<p>Once you are sure the port is opened you can curl the ip:port</p>
<pre><code>curl http://10.244.0.10:32004
</code></pre>
<p>For further info check the <a href="https://kubernetes.io/docs/tasks/access-application-cluster/service-access-application-cluster/" rel="nofollow noreferrer">Kubernetes official documentation.</a></p>
