<p>I have a running pod that was created with the following <code>pod-definition.yaml</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
    name: microservice-one-pod-name
    labels:
        app: microservice-one-app-label
        type: front-end
spec:
    containers:
    - name: microservice-one
      image: vismarkjuarez1994/microserviceone
      ports:
      - containerPort: 2019
</code></pre>
<p>I then created a Service using the following <code>service-definition.yaml</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>kind: Service
apiVersion: v1
metadata:
  name: microserviceone-service
spec:
  ports:
    - port: 30008
      targetPort: 2019
      protocol: TCP
  selector:
    app: microservice-one-app-label
  type: NodePort
</code></pre>
<p>I then ran <code>kubectl describe node minikube</code> to find the Node IP I should be connecting to -- which yielded:</p>
<pre class="lang-sh prettyprint-override"><code>Addresses:
  InternalIP:  192.168.49.2
  Hostname:    minikube
</code></pre>
<p>But I get no response when I run the following curl command:</p>
<pre class="lang-sh prettyprint-override"><code>curl 192.168.49.2:30008
</code></pre>
<p>The request also times out when I try to access <code>192.168.49.2:30008</code> from a browser.</p>
<p>The pod logs show that the container is up and running. Why can't I access my Service?</p>

<p>The problem is that you are trying to access your service at the <code>port</code> parameter which is the internal port at which the service will be exposed, even when using <code>NodePort</code> type.</p>
<p>The parameter you were searching is called <code>nodePort</code>, which can optionally be specified together with <code>port</code> and <code>targetPort</code>. Quoting the <a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport" rel="nofollow noreferrer">documentation</a>:</p>
<blockquote>
<p>By default and for convenience, the Kubernetes control plane will
allocate a port from a range (default: <code>30000-32767</code>)</p>
</blockquote>
<p>Since you didn't specify the <code>nodePort</code>, one in the range was automatically picked up. You can check which one by:</p>
<pre><code>kubectl get svc -owide
</code></pre>
<p>And then access your service externally at that port.</p>
<p>As an alternative, you can change your service definition to be something like:</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: microserviceone-service
spec:
  ports:
    - port: 30008
      targetPort: 2019
      nodePort: 30008
      protocol: TCP
  selector:
    app: microservice-one-app-label
  type: NodePort
</code></pre>
<p>But take in mind that you may need to delete your service and create it again in order to change the <code>nodePort</code> allocated.</p>
