Hi Freark, would this be a concrete example of what you're trying to accomplish?
* Application 1 has an external IP address of
198.51.100.2 and is available to external customers on http://198.51.100.2:80.* Application 2 has an external IP address of
198.51.100.3 and is available to external customers on http://198.51.100.3:80.
VMs in an instance group are running Applications 1 and 2 on internal ports like:
* Application 1 runs on port 8081.
* Application 2 runs on port 8082.
It's true that GCP Network Load Balancing and GCP Internal Load Balancing do not support port mapping because neither of those load balancers are proxies; they're both “pass through” load balancers. Whatever ports are set on the forwarding rule are used on the instance.
We do have three types of load balancers that act as proxies, and these do support accepting traffic on ports that are different from the ports to which the traffic is delivered on the backend. Our current proxy based load balancer offerings are:
- HTTP(S) Load Balancing: Forwarding rules accept traffic on ports 80 and 443
- SSL Proxy Load Balancing: Forwarding rules accept traffic on these ports: 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222
- TCP Proxy Load Balancing: Forwarding rules accept traffic on these ports: 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222
If you can use those ports as your “inputs,” you can direct traffic to arbitrary TCP ports on the backend instances. To do this:
- For the instance group, you configure one or more named ports[1]. Each named port maps a name of your choice to a TCP port number.
You could, for example, set two named ports on the same instance group, one named port for each application:
Named Port: app-1, Port: TCP 8081
Named Port: app-2, Port: TCP 8082
- For each backend service (all three of the proxy load balancers listed above use backend services), you “subscribe to” a named port [2].
One backend service on the first load balancer uses the named port app-1.
One backend service on the second load balancer uses the named port app-2.
For HTTP(S) Load Balancing, it's possible to have multiple backend services attached to the same URL map. The URL map is effectively the main configuration for the load balancer. For all other types of load balancers that use backend services, including TCP Proxy and SSL Proxy, “the load balancer” is to one and only one backend service, though it might have multiple forwarding rules that point to it.
I hope this helps clarify a few things!
References:
2: --port-name flag: