Domain Mapping to point to a tag inside a service on Cloud Run

right now I'm deploying to cloud run and run

gcloud run deploy myapp --tag pr123 --no-traffic

I can then access the app via

https://pr123---myapp-jo5dg6hkf-ez.a.run.app

Now I would like to have a custom domain mapping going to this tag. I know how to point a custom domain to the service but I don't know how to point it to the tagged version of my service.

Can I add labels to the DomainMapping that would cause the mapping to got this version of my cloud run service? Or is there a routeName, eg. myapp#pr123 that would do the trick there?

In the end I would like to have

https://pr123.dev.mydomain.com

being the endpoint for this service.

Upvotes: 2

Views: 1141

Answers (2)

I ended up building the loadbalancer with a network endpoint group (as suggested). For further reference, here is my terraform snippet to create it. The part is then the traffic tag you assign to your revision.

resource "google_compute_region_network_endpoint_group" "api_neg" {
  name                  = "api-neg"
  network_endpoint_type = "SERVERLESS"
  region                = "europe-west3"
  cloud_run {
    service  = data.google_cloud_run_service.api_dev.name
    url_mask = "<tag>.preview.mydomain.com"
  }
}

Upvotes: 1

guillaume blaquiere
guillaume blaquiere

Reputation: 75735

With a custom domain, you configure a DNS to point to a service, not a revision/tag of the service. So, you can't by this way.

The solution is to use a load balancer with a serverless NEG. The most important is to define the URL mask that you want to map the tag and service from the URL which is received by the Load Balancer.

Upvotes: 3

Related Questions