3

I am running several gcloud services which have assigned urls automatically in following format:

https://SERVICE_NAME-XXXXXXX-ew.a.run.app/

This is not particularly easy to work with and to pass these URLs to clients. Alternative is to use the custom domain, but this needs hardcoding subdomains within DNS records (as far as I understand) and I would like to avoid that and use the default URLs.

What is the best practice to work with these URLs? I can imagine keeping some mapping of service->URL and passing it to clients, but I would like to avoid reinventing the wheels.

Vojtěch
  • 11,312
  • 31
  • 103
  • 173
  • 2
    My 2 cents ... I'm assuming that the URL is composed of SERVICE_NAME + Project ID. If I am creating a service then I would expect this URL to be constant for the lifetime of my service. I'd then create a DNS entry that uses CNAME to act as an alias. So instead of exposing: https://billing-kolban-12345-ew.a.run.app I would expose: https://billing.api.mycompany.com where we have a CNAME map. For best possible experience, think further about leveraing API management such as Apigee or CloudEndponts as a proxy to your service. – Kolban May 29 '20 at 15:44
  • Are all your services in the same region? – guillaume blaquiere May 29 '20 at 19:57

2 Answers2

5

Edit: I've released an external tool called runsd that lets you do this. Check it out: https://github.com/ahmetb/runsd


Thanks for this question! The "Service discovery by name" for Cloud Run is very much an active area of work. Though, there are no active timelines we can share yet.

You can see a prototype of me running this on Cloud Run here: https://twitter.com/ahmetb/status/1233147619834118144

APIs like Google Cloud Service Directory linked are geared more towards custom/DIY service discovery you might want to build to your RPC stack such as gRPC. It's more of a managed domain name directory, that you can integrate with your RPC.

If you are interested in participating an alpha for this feature in the future, drop me an email at ahmetb at google.

ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214
  • Hi, thanks for answering, I would be happy for participation! I would like to use the cross-region discovery. – Vojtěch Jun 02 '20 at 20:44
4

You can use a beta service Service Directory.

At service deployment

  • Create your service with a name and the URL as metadata

In your code

  • Request the service metadata with its name, and get the URL
  • Use the url

You can't use the endpoint feature of the service because your don't have IP/Port.

However, for now, there is client library and you have to use API directly.

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76
  • This looks promising! They state: `Service Directory allows clients to resolve services via DNS, HTTP, and gRPC.` – however it is nowhere to find how to query it via HTTP – which is what one needs in mobile app. – Vojtěch May 30 '20 at 05:38
  • HTTP? you mean without SSL? Why it's not possible with mobile? – guillaume blaquiere May 30 '20 at 12:08
  • I just copied what they write - ofc I would like to use HTTP with SSL. But I didn't find any way to call it from apps via HTTP. – Vojtěch Jun 02 '20 at 20:46