2
votes

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.

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: billing-kolban-12345-ew.a.run.app I would expose: 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
Are all your services in the same region?guillaume blaquiere

2 Answers

3
votes

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


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.

2
votes

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.