<p>I deployed a kubernetes loadbalancer on google cloud.</p>

<pre><code>$kubectl expose deployments nginx --port 80 --type LoadBalancer
$kubectl get services
NAME         TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP      10.31.240.1    &lt;none&gt;        443/TCP        9m
nginx        LoadBalancer   10.31.253.32   35.188.14.5   80:30787/TCP   1m
</code></pre>

<p>Notice the nginx port has 80 and 30787. What does these two ports mean?</p>

drdot
<blockquote>
  <p>Notice the nginx port has 80 and 30787. What does these two ports mean?</p>
</blockquote>

<p>A <code>kubectl describe service nginx</code> would likely be more explanatory, but the tl;dr is that 80 is the port from inside the cluster, and 30787 is the <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer"><code>NodePort</code></a> pointing to port 80 of that Service. The <code>NodePort</code> is required because in order for whatever load balancer is running on <code>35.188.14.5</code> to connect into the cluster, it needs a TCP/IP port that it can use, since it (hopefully!) cannot use <code>10.31.253.32:80</code> to otherwise communicate with that Service the way things inside the CNI boundary do.</p>
