Step 3: Create a load balancer

In this step, you create anApplication Load Balancerto distribute the traffic to backend instances hosted on Cloud Run.In the load balancer configuration, you define the routing rules, whichdetermine how the load balancer directs the traffic. Routing rules include hostrules and path matches, which constitute the configuration components of an externalApplication Load Balancer'sURL map.

Note that to complete this step, you must have a valid domain name or avalid self-managed certificate.

Create a load balancer for the Cloud Run service

  1. In the Google Cloud console, go to theLoad balancing page.

    Go to Load balancing

  2. ClickCreate load balancer.

  3. In theType of load balancer section, clickApplication Load Balancer (HTTP/HTTPS), and then clickNext.

  4. In thePublic facing or internal section, clickPublic facing (external), and then clickNext.

  5. In theGlobal or single region deployment section, clickBest for global workloads, and then clickNext.

  6. In theLoad balancer generation section, clickGlobal external Application Load Balancer, and then clickNext.

  7. ClickConfigure.

  8. In theLoad Balancer name field, entergemini-streamlit-app-lb.

  9. Configure the load balancer by completing theFrontend configuration,Backend configuration, andRouting rules sections.

Frontend Configuration

  1. Specify the followingFrontend configuration:

    • Name: Entergemini-streamlit-app-frontend.

    • Protocol: SelectHTTPS (includes HTTP/2 and HTTP/3).

    • Network Service Tier: Set theIP address byreserving a new external static IP address. While reserving the new IP address, specifygenai-app-ip as theName.

    • Certificate: Perform the following steps to create a new Google-managed certificate:

      1. ClickCreate a new certificate.

      2. Specify the following details:

        • Name: Entermy-genai-app-certificate.

        • Create mode: ClickCreate Google-managed certificate.

        • Domains: Enter the domain name for provisioning the certificate.

      3. ClickCreate.

      For more information about Google-managed SSL certificates, seeUse Google-managed SSL certificates.

    • Select theEnable HTTP to HTTPS redirect checkbox.
  2. ClickDone.

  3. ClickBackend configuration to configure the backend.

Backend configuration

  1. Click theBackend services & backend buckets list and then clickCEnter the following details:

    • Name: Entergemini-streamlit-app-backend.

    • Backend type: ClickServerless network endpoint group.

    • Backends: On theNew Backend card, perform the following steps:

      1. Click theServerless network endpoint groups list, and then clickCreate serverless network endpoint group.

      2. Enter the following details:

        • Name: Enterstreamlit-app-neg.

        • Region: Selectus-central1.

        • Serverless network endpoint group type: SelectCloud Run.

        • Select service: Select thegemini-streamlit-cloudrun Cloud Run service.

      3. ClickCreate.

      4. ClickDone.

  2. Clear theEnable Cloud CDN checkbox.

  3. In thePolicy name box, enterdefault-security-policy-gemini-app-backend.

  4. ClickCreate, and then clickOK.

  5. ClickRouting rules to configure the routing rules.

Routing rules

  1. ClickAdvanced host and path rule.

  2. In theHost and path rules section, click(Default) Route traffic to backend "" for any unmatched hosts, and then enter the following details:

  3. ClickDone.

  4. ClickAdd host and path rule to add a new rule.

  5. UnderNew host and path rule, enter the following details:

  6. ClickDone.

  7. ClickReview and finalize to review the configuration and create the load balancer.

Review and finalize

  1. Review the load balancer configuration.

  2. To create the load balancer, clickCreate.

Add the IP address to the domain DNS records

Update the DNS records of your domain to point to the reserved IP address that wascreated for your load balancer. You might have to contact the administratorof your domain to complete this step.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.