使用Google ESP代理多个服务

问题描述 投票:0回答:1

我一直在审查Google Cloud Extensible Service Proxy,它有望成为无服务器的NGINX实例,但是我不确定如何通过它代理到应用程序引擎中运行的多个服务,并且本质上将其用作网关。似乎需要使用庞大的JSON配置中的主机和指向端点服务名称的环境变量,并且在这种约束下,我看不出它如何代理多个服务。

google-cloud-platform google-cloud-endpoints
1个回答
0
投票

我的理解是,您可以使用Cloud Run托管Endpoints ESP。然后,这将为您提供一个可访问的URL,但如果需要,可以启动足够的ESP实例。然后向其注册的Open API规范文档将包含与要公开的服务的每个实例相对应的路径。然后,对于每个路径,您将定义一个x-google-backend,指向每个路径将要针对的服务URL。

编辑:yaml文件看起来会像这样:

info:
  title: Cloud Endpoints with API Keys
  description: Sample API on Cloud Endpoints with multiple App Engine with IAP backend
  version: 1.0.0
host: <ENDPOINT_URL>
schemes:
  - https
produces:
  - application/json
paths:
  /hello-gae1:
    get:
      summary: Greet a user from App Engine
      operationId: hello_gae
      x-google-backend:
        address: https://<PROJECT_ID>.appspot.com
      parameters:
        - in: query
          name: name
          required: false
          type: string
      responses:
        '200':
          description: A successful response
          schema:
            type: string
  /hello-gae2:
    get:
      summary: Greet a user from App Engine
      operationId: hello_gae
      x-google-backend:
        address: https://<SERVICE-dot-PROJECT_ID>.appspot.com
      parameters:
        - in: query
          name: name
          required: false
          type: string
      responses:
        '200':
          description: A successful response
          schema:
            type: string
  /hello-gae3:
    get:
      summary: Greet a user from App Engine
      operationId: hello_gae
      x-google-backend:
        address: https://<SERVICE-dot-PROJECT_ID>.appspot.com
      parameters:
        - in: query
          name: name
          required: false
          type: string
      responses:
        '200':
          description: A successful response
          schema:
            type: string
securityDefinitions:
  # This section configures basic authentication with an API key.
  api_key:
    type: "apiKey"
    name: "key"
    in: "query"

参考:

© www.soinside.com 2019 - 2024. All rights reserved.