In this step, you create an Application Load Balancer
to distribute the traffic to backend instances hosted on Cloud Run.
In the load balancer configuration, you define the routing rules, which
determine how the load balancer directs the traffic. Routing rules include host
rules and path matches, which constitute the configuration components of an external
Application Load Balancer's URL map. Note that to complete this step, you must have a valid domain name or a
valid self-managed certificate. In the Google Cloud console, go to the Load balancing page. Click Create load balancer. In the Type of load balancer section, select Application Load Balancer (HTTP/HTTPS), and then click Next. In the Public facing or internal section, select Public facing (external), and then click Next. In the Global or single region deployment section, select Best for global workloads, and then click Next. In the Load balancer generation section, select Global external Application Load Balancer, and then click Next. Click Configure. In the Load Balancer name field, enter To configure the load balancer, complete the Frontend configuration, Backend configuration, and Routing rules sections. In the Frontend configuration section, enter the following details: Certificate: To create a new Google-managed certificate, follow these steps: Specify the following details: Click Create.
For more information, see Use Google-managed SSL certificates. Select the Enable HTTP to HTTPS redirect checkbox. Click Done. Click Backend configuration to continue. Enter the following details for the backend service: In the Backends section, on the New Backend card, create a serverless network endpoint group (NEG): Enter the following details: Click Create. Click Done to add the new backend to the backend service. Clear the Enable Cloud CDN checkbox. In the Policy name box, enter Click Create, and then click OK. Click Routing rules to continue. In the Host and path rules section, edit the default rule for any unmatched hosts: Backend: Select Click Done. Click Add host and path rule to add a new rule. Under New host and path rule, enter the following details: Path Matcher: Copy the following URL map configuration: Replace the following: PROJECT_ID: Your Google Cloud project ID. PRIORITY: Specify the priority of the backend service by
which the route rules are evaluated. In this scenario, set this to any
value because you created only one backend service. Click Done. Click Review and finalize to continue. Update your domain's DNS records to point to the IP address that you reserved for the load balancer. You might need to contact your domain administrator to complete this step.Create a load balancer for the Cloud Run service
gemini-streamlit-app-lb
.Frontend configuration
gemini-streamlit-app-frontend
genai-app-ip
.
my-genai-app-certificate
Backend configuration
gemini-streamlit-app-backend
streamlit-app-neg
us-central1
gemini-streamlit-cloudrun
Cloud Run service.default-security-policy-gemini-app-backend
.Routing rules
gemini-streamlit-app-backend
.
defaultService: projects/PROJECT_ID/global/backendServices/gemini-streamlit-app-backend
name: matcher1
routeRules:
- matchRules:
- prefixMatch: /gemini-streamlit-app
priority: PRIORITY
routeAction:
weightedBackendServices:
- backendService: projects/PROJECT_ID/global/backendServices/gemini-streamlit-app-backend
weight: 100
Review and finalize
Add the IP address to the domain DNS records
Step 3: Create a load balancer
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-23 UTC.