<p>I running Kubernetes cluster on premises, initialized using KubeAdm. I configured <a href="https://kubernetes.io/docs/concepts/cluster-administration/networking/#flannel" rel="noreferrer">flannel</a> networking plugin.</p>

<p>When I exposing service as a NodePort, I'm not able to receive external IP. What do I miss?</p>

<p><a href="https://i.stack.imgur.com/TRjmN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TRjmN.png" alt="enter image description here"></a></p>

<p>My deployment yaml looks as the following:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: testapp
  labels:
    run: testapp
spec:
  type: NodePort
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
    name: http
  - port: 443
    protocol: TCP
    name: https
  selector:
    run: testapp
---------
apiVersion: apps/v1
kind: Deployment
metadata:
  name: testapp
spec:
  selector:
    matchLabels:
      run: testapp
  replicas: 2
  template:
    metadata:
      name: testapp
      labels:
        run: testapp
    spec:
      containers:
        - image: [omitted]
          name: testapp
          ports:
          - containerPort: 80
             livenessProbe:
               httpGet:
               path: /api/health
               port: 80
</code></pre>

<p><strong>Environment details:</strong></p>

<p>Kubernetes version:</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.3", GitCommit:"d2835416544f298c919e2ead3be3d0864b52323b", GitTreeState:"clean", BuildDate:"2018-02-07T12:22:21Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.3", GitCommit:"d2835416544f298c919e2ead3be3d0864b52323b", GitTreeState:"clean", BuildDate:"2018-02-07T11:55:20Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<p>Running Ubuntu Server 16.04 on vSphere VM (on-prem).</p>

<p>You would not get an external IP when exposing service as a nodeport. Exposing Service on a Nodeport means that your service would be available on externally via the NodeIP of any node in the cluster at a random port between 30000-32767(default behaviour) . </p>

<p>In your case , the port on which your service is exposed is port 31727. </p>

<p>Each of the nodes in the cluster proxy that port (the same port number on every Node) into the pod where your service is launched.</p>

<p>Easiest way to see this using</p>

<pre><code>kubectl describe service &lt;service-name&gt;
</code></pre>

<p>Check for detail of the Nodeport in the result above. </p>

<p>Later get any the node Ip of any of the nodes in the cluster using</p>

<pre><code>kubectl get nodes -o wide
</code></pre>

<p>You can now access your service externally using <code>&lt;Node-IP&gt;:&lt;Node-Port&gt;</code></p>

<p>Additionally, if you want a fixed Node port, you can specify that in the yaml. </p>

<p>PS: Just make sure you add a security rule on your nodes to allow traffic on the particular port.</p>
