<p>I have been following this guide:
<a href="https://medium.com/javarevisited/kubernetes-step-by-step-with-spring-boot-docker-gke-35e9481f6d5f" rel="nofollow noreferrer">https://medium.com/javarevisited/kubernetes-step-by-step-with-spring-boot-docker-gke-35e9481f6d5f</a></p>

<p>Which has the following line:</p>

<pre><code>   kubectl expose deployment userapi --type=LoadBalancer --port 80 --target-port 8080
</code></pre>

<p>I can access this service by just going to its external IP without specifying the nodeport. I am not sure why this is. I thought I would need to do externalip:nodeport.</p>

<p>Thank you</p>

FranktheTank
<p>Kubernetes services are hierarchical. A nodePort service will contain a clusterIP service. A loadBalancer service will contain a nodePort service.</p>
<p>If you execute your command <code>kubectl expose deployment userapi --type=LoadBalancer --port 80 --target-port 8080</code> Kubernetes will create a service named <code>userapi</code>. Now in order to see the full (generated) yaml for this service simply do: <code>kubectl get svc userapi -o yaml</code>. You will see that Kubernetes automatically asigned a nodePort to your type:loadBalancer service.</p>
<blockquote>
<p><code>NodePort</code>: Exposes the Service on each Node’s IP at a static port (the NodePort). A <code>ClusterIP</code> Service, to which the <code>NodePort</code> Service routes, is automatically created. You’ll be able to contact the <code>NodePort</code> Service, from outside the cluster, by requesting <code>&lt;NodeIP&gt;:&lt;NodePort&gt;</code>.</p>
<p><code>LoadBalancer</code>: Exposes the Service externally using a cloud provider’s load balancer. <code>NodePort</code> and <code>ClusterIP</code> Services, to which the external load balancer routes, are automatically created.</p>
</blockquote>
