google application load balancer configure to redirect traffic to cloudrun
This is a common pattern used in application load balancer setup where we can configure a custom DNS then route traffic via application load balancer to our cloud run via network group endpoint.
Create cloud run app
Let's create a simple cloud run application first and call it crtest (cloud run test).
Create load balancer
To get started, lets create our network, by going to VPC network, create a VPC name called "lb-network". Subnet creation mode set it to custom. Then in the new subnet enter
a) Name - lb-subnet
b) Select region
c) IP address 10.1.2.0/24
Click done and create to create this.
Next, goto load balancing and click "Create Load balancer" and select Application Load Balancer.
For public facing or internal - select Internal. Click "next".
Then selet "Cross region or single region deployment", choose "Best for regional workload and click "Configure". We are half way through with our load balancer.
Configuring application load balancer
Let's set the name to serverless-lb.
Select the network lb_network.
Configure front end services
In front end configuration, enter a name, we will call this "ALB-serverless-frontend".
For protocol we will select HTTP and for the subnet we select - "lb-subnet". IP version we will set it to IPv4 and IP address is Ephemeral. Port is 80.
Configure backend services
In the backend configuration, select "Create or select backend service" and select "create a backend service.
For backend service type, select Serverless network endpoint group. Leave protocol unchange. In the backend select new backend and create serverless network endpoint group.
The region, select the your region.
For serverless network endpoint group type, select Cloud Run. Here, you will select "crtest" that we created earlier. Click create when done.
Next we will configure routing rules.
Select Simple host and path rule. Then proceed to select service from backend list.
Review the configuration.
In this step here, click on "Review and finalize". And when ready click "Create".
Comments