<p>I have following service configuration:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: web-srv
spec:
  type: NodePort
  selector:
    app: userapp
    tier: web
  ports:
    - protocol: TCP
      port: 8090
      targetPort: 80
      nodePort: 31000
</code></pre>

<p>and an nginx container is behind this service. Although I can access to the service via <code>nodePort</code>, service is not accessible via <code>port</code> field. I'm able to see the configs with <code>kubectl</code> and Kubernetes dashboard but <code>curl</code>ing to that port (e.g. <code>curl http://192.168.0.100:8090</code>) raises a <strong>Connection Refused</strong> error.</p>

<p>I'm not sure what is the problem here. Do I need to make sure any proxy services is running inside the Node or Container?</p>

<p>Get the IP of the kubernetes service and then hit 8090; it will work.
nodePort implies that the service is bound to the node at port 31000.</p>

<p>These are the 3 things that will work:</p>

<pre><code>curl &lt;node-ip&gt;:&lt;node-port&gt;        # curl &lt;node-ip&gt;:31000
curl &lt;service-ip&gt;:&lt;service-port&gt;  # curl &lt;svc-ip&gt;:8090
curl &lt;pod-ip&gt;:&lt;target-port&gt;       # curl &lt;pod-ip&gt;:80
</code></pre>

<p>So now, let's look at 3 situations:</p>

<p><strong>1. You are inside the kubernetes cluster (you are a pod)</strong></p>

<p><code>&lt;service-ip&gt;</code> and <code>&lt;pod-ip&gt;</code> and <code>&lt;node-ip&gt;</code> will work.</p>

<p><strong>2. You are on the node</strong></p>

<p><code>&lt;service-ip&gt;</code> and <code>&lt;pod-ip&gt;</code> and <code>&lt;node-ip&gt;</code> will work.</p>

<p><strong>3. You are outside the node</strong></p>

<p>Only <code>&lt;node-ip&gt;</code> will work assuming that <code>&lt;node-ip&gt;</code> is reachable.</p>
