1

I have my services split into Cloud Run services, say e.g. in a blog application I have user, post and comment services.

For each service I get a separate http endpoint on deploy, but what I want is to have api.mydomain.com act as a gateway for accessing all of them via their respective routes (/user*, /post*, etc).

Is there a standard (i.e. GCP-managed and serverless-ey) way to do this?

Things I've tried/thought of and their issues:

  • Firebase hosting with rewrites - this is the 'suggested' solution, but it's not very flexible and more problematically I think this leads to double wrapping CDNs on every request. Correct me if wrong, but Cloud Run endpoints use a CDN already, then you have Firebase hosting running through fastly. Seems silly to be needlessly adding cost and latency like that.
  • nginx on a constantly running instance - works ok but not managed and not serverless; requires scaling interventions
  • nginx on Cloud Run - this seems like it would have highly variable performance since there are (a) two possible cold starts, and (b) again double wrapping CDN.
  • using Cloud LB/CDN directly - seemingly not supported with Cloud Run

Any ideas? For me this kind of makes Cloud Run unusable for microservices. Hopefully there's a way around it.

  • 1
    Howdy ... the answer I would use here is Cloud Endpoints ... see https://cloud.google.com/endpoints/docs/ ... this allows you to have one API gateway with many separate services routed as the path url. – Kolban Dec 22 '19 at 16:15
  • I wrote an [article on this](https://medium.com/google-cloud/secure-cloud-run-cloud-functions-and-app-engine-with-api-key-73c57bededd1). You can find clues in it. If not, make your question more focused on your issue. – guillaume blaquiere Dec 22 '19 at 19:29
  • Hi both -- yes I had seen a some info around on using Cloud Endpoints but what I encountered was this article: https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-run , which made me a little confused. Is Cloud Endpoints a fully managed and abstracted service, or is it a container that I run on Cloud Run with my Swagger definition? – G. Claude Rann Dec 22 '19 at 22:01
  • 1
    You could write a minimal router in your language of choice (e.g. Go with gorilla/mux) in Cloud Run that proxies to your other Cloud Run services, which will be lighter weight compared to nginx. HTTP(S) LB & Cloud CDN will have support for Cloud Run backends in earlier 2020, and a simple app router will be a low-investment workaround until then (I am the PM for Cloud CDN). Hope that helps guide you. – elithrar Dec 22 '19 at 22:13
  • As mentioned, Cloud Endpoints in Cloud Run is a viable alternative for what you are trying to achieve. However, you might also consider using App Engine Here you have a couple of links that might help you: [Microservices in App Engine](https://cloud.google.com/appengine/docs/standard/python/microservices-on-app-engine) and [App Engine Microservices blog entry](https://medium.com/google-cloud/node-python-and-go-microservices-in-a-single-google-app-engine-project-54aac3d60225) – Jose V Jan 22 '20 at 11:23

0 Answers0