I'm trying to create an active/passive cluster in GCP, and I'm looking at using the native load balancer to achieve this. For example, I want the load balancer to only forward traffic to a particular set of nodes (the standby nodes) only if the main set of nodes (the active nodes) fails the health check. I would have thought this would be possible, but I can't see any option which would allow me to achieve this. From what I can tell, only round robin load balancing is possible, or am I missing something?
Round robin load-balancing is used only for compute instances with in the same Managed Instance Group(MIG). If you want to have control over balancing modes, you need to put the active and passive nodes in separate nodes and regions/zones. Again, why bother with activie/passive nodes, when you can make your active nodes highly available by deploying them across multiple zones and regions? The GLB will pick the healthy active nodes.
If you think you still need active/passive nodes, as far as I know, GCP doesn't provide the exact feature you are asking, but I think you might get close by tweaking the
capacity setting property of the GLB backend services resource. For instance, you can set the cpu utilization and capacity of standby nodes to almost zero(but not zero) and set it to 100% on active nodes. This way, the load balancer will send all or most of traffic to active nodes, only when active nodes fail, it will route traffic to passive nodes. Since GLB is also geo-based, you might put your active nodes in a MIG closer to the clients.
Reference - Google global HTTP load balancer documentation
I couldn't find such a feature in GCP. However, if using an HTTPs LB, I can only think of having 2 set of IMG, and setting the capacity setting in the backend. So, one IMG will have 100% to receive all the requests and the second IMG set to 0%.
You will need to monitor the health check of the IMG or instance and if some are unhealthy, then you can change the capacity settings for both groups using APIs calls. You will need to have a cron job to monitor and a script that will be run the APIs call.
Alternatively, you can try setting autohealing, so the instance that unhealthy gets repaired, as this is a better and easier way to recover unhealthy instances.
If this is not what you are looking for, then you can submit a Feature Request here for Load Balancing.