Is it possible to have multiple cloud run services behind 1 endpoint gateway?

2,196 views
Skip to first unread message

elin...@mediciventures.com

unread,
Jul 1, 2019, 3:45:32 PM7/1/19
to Google Cloud Endpoints
Howdy!

So, I am just confirming what I've found here already, but it appears that right now. Google cloud endpoints does not support the ability to have 2 cloud run services behind 1 gateway. Is that correct or am I still misguided?

Resources found so far:



Thanks for the help!
~Erik L.

Mike McDonald

unread,
Jul 1, 2019, 4:08:04 PM7/1/19
to elin...@mediciventures.com, Google Cloud Endpoints
If you're deploying ESP as a sidecar you can only have a single backend service. If you're deploying ESP to a gateway (currently running on Cloud Run), you can deploy multiple backend services and forward to them.


# Specify a backend to handle all routes, paths will be appended to the base path
x-google-backend:
  address: https://backend-hash-uc.a.run.app

paths:
  /hello:
    get:
      summary: Greet a user
      operationId: hello
  /goodbye:
    get:
      summary: Bid a user goodbye
      operationId: goodbye
      # Per operation overrides
      # Path is overwritten and path parameters are specified as query params
      x-google-backend:
        address: https://backend2-hash-uc.a.run.app/goodbye


Thanks,
--Mike





--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/dd7367ee-0768-4060-b134-de39bc73fba4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Michael McDonald | Product Manager, Serverless | mpmcd...@google.com | 1-844-THE-FIRE 

Erik Lindblom

unread,
Jul 2, 2019, 10:56:58 PM7/2/19
to Mike McDonald, Google Cloud Endpoints

That is exactly what I was looking for, and that worked, thank you!

 

Doc wise, I am totally missing something. I don’t see that laid out in the docs in as simple of a way as you have it here.

 

~Erik Lindblom




CONFIDENTIALITY NOTICE: This message is intended only for the use and review of the individual or entity to which it is addressed and may contain information that is privileged and confidential. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message solely to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify sender immediately by telephone or return email. Thank you.

Mike McDonald

unread,
Jul 3, 2019, 11:54:53 AM7/3/19
to elin...@mediciventures.com, Google Cloud Endpoints
Yeah, that's because I didn't really have a good place to explain theses types of interactions given the current state of Endpoints. I'll see if I can find somewhere good to put them.

https://cloud.google.com/endpoints/docs/openapi/openapi-extensions#x-google-backend has some information on the details of x-google-backend but again, lacks the interaction between different types (also, path_translation overrides aren't in production yet).

Thanks,
--Mike

Solomon Leung

unread,
Jul 8, 2019, 11:22:00 PM7/8/19
to Google Cloud Endpoints
HI Mike,

Thanks for the demo ! 
If we going to pass parameters to other backend services, has it been supported?

is below configuration correct ?
=================================
e.g.
/programe/{pid}/language/{lid}
    ....
    parameters:
          - name: programme_id
            in: path
            description: Programme ID
            required: true
            schema:
              type: integer
              format: int64
          - name: language_id
            in: path
            description: Language ID
            required: true
            schema:
              type: string
            format: str
          - name: programme_id
            in: path
            description: Programme ID
            required: true
            schema:
              type: integer
              format: int64
          - name: language_id
            in: path
            description: Language ID
            required: true
            schema:
              type: string
            format: str
  x-google-backend:
    address: https://backend-hash-uc.a.run.app
/programe/{pid}/language/{lid}
      .....
=================================

    /programme/{programme_id}/language/{language_id}:
    /programme/{programme_id}/language/{language_id}:
Thanks for the help !
Solomon

    /programme/{programme_id}/language/{language_id}:
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

Mike McDonald

unread,
Jul 9, 2019, 1:59:15 PM7/9/19
to Solomon Leung, Google Cloud Endpoints
This isn't currently supported on a per-operation basis, but hopefully will be soon. It'll look like this:

paths:
  /programe/{pid}/language/{lid}:
    get:
      x-google-backend:
        # path_translation: CONSTANT_ADDRESS   # this is inferred when we parse the file, but can be overridden as below
    post:
      x-google-backend:
        # override path_translation, hopefully will be supported shortly
        address: https://foo.com   # note that it's the base server
        path_translation: APPEND_PATH_TO_ADDRESS

Alternatively, you might be able to use the existing behavior of a single backend handling all requestss:

x-google-backend:
  # anything that isn't explicitly overridden with an x-google-backend below uses this
  address: https://foo.com   # note that it's the base server
  # path_translation: APPEND_PATH_TO_ADDRESS   # inferred
paths:
  /programe/{pid}/language/{lid}:
    get:
      x-google-backend:
        # path_translation: CONSTANT_ADDRESS   # inferred
    post:
      ...
     

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.


--
Michael McDonald | Product Manager, Serverless | mpmcd...@google.com | 1-844-THE-FIRE 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/81fc08b6-abe7-4d7b-9608-90ddf9a54959%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Solomon Leung

unread,
Jul 10, 2019, 11:52:11 PM7/10/19
to Google Cloud Endpoints
HI Mike,

Thanks for recommendation ~ and looking forward to the feature rollout !

Cheers,
Solomon

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.


--
Michael McDonald | Product Manager, Serverless | mpmcd...@google.com | 1-844-THE-FIRE 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

Mike McDonald

unread,
Jul 11, 2019, 4:35:00 PM7/11/19
to Solomon Leung, Google Cloud Endpoints
Ok, I think that this is rolled out now. Mind trying it out?

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.


--
Michael McDonald | Product Manager, Serverless | mpmcd...@google.com | 1-844-THE-FIRE 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.


--
Michael McDonald | Product Manager, Serverless | mpmcd...@google.com | 1-844-THE-FIRE 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/4d809544-5cbd-47ae-981c-bcd6ffa3141d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Erik Lindblom

unread,
Jul 15, 2019, 3:54:58 PM7/15/19
to Mike McDonald, Solomon Leung, Google Cloud Endpoints

I’ve just tested it out and it seems to be working for me. Awesome that this just got rolled out, thank you!

 

From: 'Mike McDonald' via Google Cloud Endpoints <google-clou...@googlegroups.com>


Reply-To: Mike McDonald <mpmcd...@google.com>
Date: Thursday, July 11, 2019 at 2:35 PM
To: Solomon Leung <solomo...@tvb.com>
Cc: Google Cloud Endpoints <google-clou...@googlegroups.com>

--
You received this message because you are subscribed to a topic in the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-cloud-endpoints/DehPzXAOzxI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/CANC_gMoUcD%2BMxS2pgPt5odHWeVa%2BQVhA%2B1_Qs5uGMyRc5kGDzg%40mail.gmail.com.


For more options, visit https://groups.google.com/d/optout.

Vipluv Aga

unread,
Jul 6, 2020, 3:09:05 AM7/6/20
to Google Cloud Endpoints
I have been trying to do exactly the same thing  as you describe but with App engine. According to the docs - it all seems to be rolled out --- but i am not getting anywhere
I even deployed two different endpoints and two differetn app engines as backend. However, whatever I do, the endpoint keeps routing all the traffic to the app engine that is the default service
As the idea is to have a prod and preprod version, all the relative paths after the base path are the same (in app engine they are served by a flask app)

My example is --
for the
opean-api.yaml 

swagger: "2.0"
info
:
  title
: "ecoserve"
  description
: "Send user data "
  version
: "1.0.0"
host
: "ecoserve-dot-solex-mvp-2.appspot.com"
x
-google-endpoints:
 
- name: "ecoserve-dot-solex-mvp-2.appspot.com"
   allowCors
: True
x
-google-backend:
    address
: "https://solex-mvp-2.oa.r.appspot.com"

And this is the app 
service: default
runtime
: custom
env
: flex
entrypoint
: gunicorn -t 600 -c gunicorn.conf.py -b :$PORT main:app

runtime_config
:
   python_version
: 3.6
resources
:
  cpu
: 4
  memory_gb
: 15.6
automatic_scaling
:
  min_num_instances
: 1
  max_num_instances
: 4

         
endpoints_api_service
:
  name
: ecoserve-dot-solex-mvp-2.appspot.com
  rollout_strategy
: managed
 
#config_id: 2020-06-14r0


The above works fine (included with jWT for authorisation etc)

Then i deployed the preprod version 

swagger: "2.0"
info
:
  title
: "apipreprod"
  description
: "Send user data for pv plant design simulation and receive results"
  version
: "1.1"
host
: "apipreprod-dot-solex-mvp-2.appspot.com"
x
-google-endpoints:
 
- name: "apipreprod-dot-solex-mvp-2.appspot.com"
   allowCors
: True
x
-google-backend:
    address
: "https://app-preprod-dot-solex-mvp-2.oa.r.appspot.com"

And the app engine at app-preprod is 
app-preprod.yaml

service: app-preprod
runtime
: custom
env
: flex
entrypoint
: gunicorn -t 600 -c gunicorn.conf.py -b :$PORT main:app

runtime_config
:
   python_version
: 3.6
resources
:
  cpu
: 1
  memory_gb
: 4
automatic_scaling
:
  min_num_instances
: 1
  max_num_instances
: 2

endpoints_api_service
:
  name
: apipreprod-dot-solex-mvp-2.appspot.com
  rollout_strategy
: managed
 
#config_id: 2020-07-05r0
   
   



As a test I made some changes in the Flask App and only deployed it to the preprod app engine (app-preprod-dot....). However, the results that are coming by doing a Postman post to 
is the same as if i had made a request to 



Is there some issue with the ESP if an App Engine instance is the backend? what are some other ways of creating differetn versions of the API  --- i dont necessarily want to change the names of the methods .- but only the backend. 






To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.


 

--

Michael McDonald | Product Manager, Serverless | mpmcd...@google.com | 1-844-THE-FIRE 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.


 

--

Michael McDonald | Product Manager, Serverless | mpmcd...@google.com | 1-844-THE-FIRE 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.


 

--

Michael McDonald | Product Manager, Serverless | mpmcd...@google.com | 1-844-THE-FIRE 

--
You received this message because you are subscribed to a topic in the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-cloud-endpoints/DehPzXAOzxI/unsubscribe.

To unsubscribe from this group and all its topics, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

Kristian Drucker

unread,
Jul 6, 2020, 3:45:24 AM7/6/20
to Google Cloud Endpoints
Hi,

I see that you are trying to access multiple Cloud Run instances from behind a single ESP GW. We did the same thing but for gRPC and works without any issues. I would have a look at the following proto files which specify how to configure backends. https://github.com/googleapis/googleapis/blob/master/google/api/backend.proto https://github.com/googleapis/googleapis/blob/ca1372c6d7bcb199638ebfdb40d2b2660bab7b88/google/api/service.proto. The service configuration is the Cloud Endpoint config. An example on to how it should look is https://cloud.google.com/endpoints/docs/grpc/get-started-cloud-run-anthos#creating_the_grpc_api_spec on step 5. I am aware that this is for gRPC, but should work for OpenAPI too.

Kristian

Teju Nareddy

unread,
Jul 6, 2020, 1:28:01 PM7/6/20
to Google Cloud Endpoints
Unfortunately, I am unsure if you can route to multiple backends using App Engine flexible. For App Engine Flex, ESP runs in "sidecar" mode. It will direct all requests to a single backend.

"Gateway" mode is only supported in App Engine Standard, Cloud Run, and Cloud Functions. In this mode, you can redirect the request to different backends.

If this is a hard requirement for you, you may be able to follow the App Engine Standard tutorial (even though you are using App Engine Flex). It should work with Flex, but it takes a lot more configuration.

Wayne Zhang

unread,
Jul 6, 2020, 1:49:14 PM7/6/20
to Teju Nareddy, Google Cloud Endpoints
As I see it,   Vipluv is trying to deploy ESP as side-car mode,  one AppEng service for one backend.   The "default" app engine service is for prod backend,  and "preprod" service  is for the "preprod" backend.  This should work in AppEng Flex.  

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/e7f21028-9047-4156-88ca-e9654e9329c4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages