<p>I want to be able to deploy several, single pod, apps and access them on a single IP address leaning on Kubernetes to assign the ports as they are when you use a <code>NodePort</code> service.</p>

<p>Is there a way to use <code>NodePort</code> with a load balancer?</p>

<p>Honestly, NodePort might work by itself, but GKE seems to block direct access to the nodes. There doesn't seem to be firewall controls like on their unmanaged VMs.</p>

<p>Here's a service if we need something to base an answer on. In this case, I want to deploy 10  these services which are different applications, on the same IP, each publicly accessible on a different port, each proxying port 80 of the nginx container.</p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: foo-svc
spec:
  selector:
    app: nginx
  ports:
    - name: foo
      protocol: TCP
      port: 80
  type: NodePort
</code></pre>

Coder1
<blockquote>
  <p>GKE seems to block direct access to the nodes.</p>
</blockquote>

<p>GCP allows creating the FW rules that allow incoming traffic either to 'All Instances in the Network' or 'Specified Target Tags/Service Account' in your VPC Network. </p>

<p>Rules are persistent <em>unless</em> the opposite is specified under the organization's policies.</p>

<p>Node's external IP address can be checked at Cloud Console --> Compute Engine --> VM Instances or with <code>kubectl get nodes -o wide</code>.</p>

<p>I run GKE (managed k8s) and can access all my assets externally.
I have opened all the needed ports in my setup. below is the quickest example.</p>

<p>Below you can find my setup:</p>

<pre><code>$ kubectl get nodes -o wide 
NAME        AGE   VERSION           INTERNAL-IP   EXTERNAL-IP
gke--mnnv   43d   v1.14.10-gke.27   10.156.0.11   34.89.x.x   
gke--nw9v   43d   v1.14.10-gke.27   10.156.0.12   35.246.x.x

kubectl get svc -o wide
NAME     TYPE        CLUSTER-IP    EXTERNAL-IP  PORT(S)                         SELECTOR
knp-np   NodePort    10.0.11.113   &lt;none&gt;       8180:30008/TCP 8180:30009/TCP   app=server-go

$ curl 35.246.x.x:30008/test
Hello from ServerGo. You requested: /test 
</code></pre>

<p>That is why it looks like a bunch of <code>NodePort</code> type <code>Services</code> would be sufficient (each one serves requests for particular <code>selector</code>)</p>

<p>If for some reason it's not possible to set up the FW rules to allow traffic directly to your Nodes it's possible to configure GCP TCP LoadBalancer.</p>

<p>Cloud Console --> Network Services --> Load Balancing --> Create LB --> TCP Load Balancing.</p>

<p>There you can select your GKE Nodes (or pool of nodes) as a 'Backend' and specify all the needed ports for the 'Frontend'. For the Frontend you can Reserve Static IP right during the configuration and specify 'Port' range as two port numbers separated by a dash (assuming you have multiple ports to be forwarded to your node pool). Additionally, you can create multiple 'Frontends' if needed.</p>

<p>I hope that helps. </p>
