Search code examples
google-cloud-platformgoogle-cloud-load-balancer

Why are backend ports automatically changing to be the same on a GCP load balancer?


I have a cluster on GCP with multiple deployments on it. The deployments are exposed with NodePort services. I'm setting up a HTTP(S) load balancer with the aim of routing from frontend to backend services, one domain to one deployment.

The issue is that when I'm saving the load balancer the backend services I've defined are suddenly both pointing to the same port. Which results in both defined domains pointing to the same service.

https://i.sstatic.net/zb3CZ.png This is how it's setup, with two backend services.

https://i.sstatic.net/VFMzN.png This is how the host and path rules are defined.

https://i.sstatic.net/BkCKb.png When editing the "Port numbers" in the "first-backend-service" and saving the load balancer, the port numbers in the "second-backend-service" will be changed to the same as was defined in the "first-backend-service".

I've tried using two load balancers, one for each service with the same result.


Solution

  • You might be using the same named port for all the backend services. The instance group comes with the default Named port. As your are using same name port, when you are changing it reverting back to the configured one.

    You can configure your custom named port and map it to your desired port by selecting Instance group --> details-->edit group using 'add item' you can add port name and port number as per your requirement and later use it in the backend services. Edit the "Port name" and "Port numbers" numbers.

    So for your scenario you can create different port name with different ports number in your instance group and apply one each to the backend services:

    • http1: 3000
    • http2: 3001