We can divert traffic from a single load balancer IP to nodePort services. We could do this scenario using the Load Balancer service on Kubernetes as well. However we are doing this using the Google cloud way.

The node port services are as follows

The respective end points are

Reserve a static public IP for the load balancer

networkandcode@cloudshell:~ gcloud compute addresses create loadbalancer-frontend --region us-central1

Note that we can only reserve one static IP per region with free trial account

Create a Load Balancer for the staging application

Similarly one more for production, however the difference is that we would be using the port 30200 for production

So we now have two load balancers

We could now access the staging and production front ends using the load balancer IP and nodePort, however the output would be the same for both, as we haven’t done any customization to the application itself

Let’s add DNS entries for this Public IP, note that this is an illustration, in reality the DNS settings have to be changed at the DNS provider end too

Click Cloud DNS

So we could now access the staging application at frontend.guestbook.example.com:30100 and the production one at frontend.guestbook.example.com:30200. However it won’t work here as we have used fake domains just for illustration

--end-of-post--