dendog
dendog

Reputation: 3328

Configuring Cloud Run services and GCS Buckets with a load balancer

I would like to setup a HTTPS load balancer to serve both static content from a storage bucket and also point to a number of cloud run services.

The setup I am trying to achieve looks like the following:

// prod
api.example.com/serviceA -> cloud run: serviceA
api.example.com/serviceB -> cloud run: serviceB
cdn.example.com/cat.jpg -> storage bucket: cats

// dev
api-dev.example.com/serviceA -> cloud run: serviceA
api-dev.example.com/serviceB -> cloud run: serviceB
cdn-dev.example.com/cat.jpg -> storage bucket: cats-dev

The dev & prod environments are separated by projects in my case.

I have followed this guide as to how to setup this configuration.

However I am unable to resolved the various services. It is not 100% clear how the following elements interact:

Please help!

Upvotes: 1

Views: 832

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75715

Sure, it can be confusing!

  • URL Map: it's plugged on the Load Balancer to route a URL to a backend (Bucket, (un)Managed instance group (MIG), Network Endpoint Group (NEG)). For example the /static/ is routed to a bucket, the others to a serverless NEG
  • URL Mask: it's plugged on the serverless NEG. You can define a template on the URL Name to extract the service name (and tag) from the URL itself. It requires to have a dependency between your site structure and your Cloud Run service naming.

Summary

The URL Map is the first pass routing to the serverless NEG. The serverless NEG apply the URL mask to route the request to the correct service.

Custom domain mapping

On a single Cloud Run service you can apply a custom domain to reach it directly. In this case, you have no load balancing, you reach directly only one service deployed on Cloud Run.

I hope to be clear!!

Upvotes: 3

Related Questions