mvhatch
mvhatch

Reputation: 157

Is it possible to map the same url structure to multiple cloud run services?

I have multiple services that all reside under the same subdomain that can only be distinguished by the path in a given URL. However, the path in the URL is NOT the name of the service. Is there a way to create a URL map/mask to route traffic correctly to my services if I were to use cloud run? For example:

subdomain.example.com/path1 and subdomain.example.com/path2 might map to services foo and bar respectively. I understand that I can use a URL map that routes path1 to foo and path2 to bar, but I'd also like to send traffic to specific revisions of each service. URL masks allow you to specify a tag, so I could have specific staging URLs as <tag>-subdomain.example.com/path1 and <tag>-subdomain.example.com/path2, but I don't know how configure a URL mask when only the the tag is variable. How would I route traffic for:

<tag>-subdomain.example.com/path1 => foo-svc (revision=tag)

subdomain.example.com/path1 => foo-svc

<tag>-subdomain.example.com/path2 => bar-svc (revision=tag)

subdomain.example.com/path2 => bar-svc

I'm open to deploying a separate cloud run services foo-<tag>-svc and bar-<tag>-svc alongside foo-svc and bar-svc if that makes things easier.

Upvotes: 3

Views: 1394

Answers (1)

John Hanley
John Hanley

Reputation: 81444

Is it possible to map the same url structure to multiple cloud run services?

Using only Google Cloud Run and Custom Domains, no

Combining Google Cloud HTTPS Load Balancers, yes.

If you add a load balancer, Cloud Run becomes a backend.

Using the load balancer allows you to use URL Maps to direct traffic to the backends. This also add many additional features. This link shows how to set everything up.

Setting up a load balancer with Cloud Run

Upvotes: 2

Related Questions