<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
<h3>Quick answer:</h3>

<p>If you create a service of type <code>LoadBalancer</code> it will create all the resources needed by the <code>Nodeport</code> as well. It does not create the actual service, it simply implement all the features needed.</p>

<p>You can think to the types of services as a hierarchy, each time it adds a new functionality, but you need the previous one.</p>

<hr>

<h3>Explanation:</h3>

<p>Quoting from official documentation:</p>

<blockquote>
  <p>LoadBalancer: Exposes the Service externally using a cloud provider’s load balancer. NodePort and ClusterIP Services, to which the external load balancer routes, are automatically created.</p>
</blockquote>

<p>If you create or expose a Noteport it will be assigned as well a ClusterIp.</p>

<blockquote>
  <p>NodePort: Exposes the Service on each Node’s IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You’ll be able to contact the NodePort Service, from outside the cluster, by requesting :</p>
</blockquote>

<p>Just for the sake of completeness when creating a service a new resource of type endpoint is created as well that is totally managed by Kubernetes and should not be manually modified:</p>

<blockquote>
  <p>ClusterIP: Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default ServiceType</p>
</blockquote>

<p>Endpoints:</p>

<blockquote>
  <p>Endpoints is a collection of endpoints that implement the actual service.
       Example: Name: "mysvc", Subsets: [ { Addresses: [{"ip": "10.10.1.1"},
       {"ip": "10.10.2.2"}], Ports: [{"name": "a", "port": 8675}, {"name": "b",
       "port": 309}] }, { Addresses: [{"ip": "10.10.3.3"}], Ports: [{"name": "a",
       "port": 93}, {"name": "b", "port": 76}] }, ]</p>
</blockquote>
