<p>I have an internal service that is created via the first cmd. Then i run kubectl expose on that service that is created.</p>

<pre><code>kubectl -n XXX create -f service.yml
kubectl -n XXX get svc
NAME                                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                            AGE
foo                           ClusterIP   10.152.183.41    &lt;none&gt;        8089/TCP


kubectl -n XXX expose service foo --type=NodePort --name=foo-ext
kubectl -n XXX get svc
NAME                                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                            AGE
foo                           ClusterIP   10.152.183.41    &lt;none&gt;        8089/TCP                                                                           29m
foo-ext                   NodePort    10.152.183.177   &lt;none&gt;        8089:30406/TCP
</code></pre>

<p>Where the external ip is  I would have figured kubectl expose would have assigned an external ip to the external service, is there an additional flag i need to pass?</p>

BLang
<p>According to the <a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport" rel="nofollow noreferrer">Kubernetes docs</a>:</p>

<blockquote>
  <p>If you set the type field to NodePort, the Kubernetes master will allocate a port from a range specified by --service-node-port-range flag (default: 30000-32767), and each Node will proxy that port (the same port number on every Node) into your Service. </p>
</blockquote>

<p>So, Kubernetes will ensure that the same port number is exposed on all nodes that are hosting this service. The external IP, in this case, is the IP address of the node.</p>

<p>Whereas Kubernetes says this about <a href="https://kubernetes.io/docs/concepts/services-networking/service/#external-ips" rel="nofollow noreferrer">External IPs</a>:</p>

<blockquote>
  <p>If there are external IPs that route to one or more cluster nodes, Kubernetes services can be exposed on those externalIPs. Traffic that ingresses into the cluster with the external IP (as destination IP), on the service port, will be routed to one of the service endpoints. <strong><code>externalIPs</code></strong> are not managed by Kubernetes and are the responsibility of the cluster administrator.</p>
</blockquote>

<p>The downside to a <code>NodePort</code> type of service is that, by itself, it's not a scalable approach and lacks service discoverability.</p>

<p>If you want to expose a service through a single IP address to consumers outside of your Kubernetes cluster, you may want to look into <a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer" rel="nofollow noreferrer"><code>LoadBalancer</code></a> type of service if have a public cloud or hybrid cloud Kubernetes deployment, or you may want to look into <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer"><code>Ingress</code></a> if you have an on-premises Kubernetes deployment.</p>
