How to configure kubernetes for gateway aggregation pattern?

11/25/2018

I would like to configure a gateway to aggregate multiple individual requests into a single request as this link. However, my use case allows user to create additional services.

A user submit a request:

POST http://gatway_ip/cards/foo

The diagram as follows:

   +------------------+    +-----------------+     +-----------------+
   |                  |    |                 |     |                 |
   |   transactions   |    |   User info     |     |   dynamic info  |
   |                  |    |                 |     |                 |
   +------------------+    +-----------------+     +-----------------+
          |                         |                       |
          +----------+     +--------+                       |
                     |     |                                |
                     |     |                                |
                +----v-----v---+                            |
                |              |                            |
                |  /cards/foo  <----------------------------+
                |              |
                +--------------+
                       |
                       |
                       |
                       +
                     User

User can start/stop dynamic info on demand. The gateway merges json response from various services. For example:

transactions:

{"amount": 4000}

user info:

{ "name": "foo" }

dynamic info:

{ "wifeName": "bar" }

Gateway responses is:

{
    "amount": 4000,
    "name": "foo",
    "wifeName": "bar"
}

As far as I know:

  • The sample solution on Microsoft website defines a fixed backend.
  • Kubernetes ingress only allows routing for incoming requests.

Is there any solution for a gateway aggregation with dynamic back-end ?

Edited

Work around 1

Refer to NVIDIA configurations for nginx auto-reload, we can take advantages of of Kubernetes ConfigMap, the steps as follows:

  • Create a backend.json configuration which is loaded by a lua on event init_by_lua* (* is block or file)
  • Configure ConfigMap to backend.json and use inotify for monitor ConfigMap changes
  • Provides a API which sends request to Kubernetes ConfigMap API for user to change configuration. Thus, nginx gateway will auto-reload

However, this link claims that inotify will not work because shared storage was a fuse filesystem

-- lotusirous
gateway
kubernetes
rest

0 Answers