Skip to content

Latest commit

 

History

History
192 lines (146 loc) · 9.4 KB

File metadata and controls

192 lines (146 loc) · 9.4 KB

Adding a Flex Gateway API Instance

Add a New API

  1. Navigate to Anypoint Platform > API Manager.

  2. In API Administration, click Add and select Add new API.

  3. Select Flex Gateway.

  4. Select a connected Flex Gateway you have installed and registered from the list under Select a gateway.

    Note

    If you don’t see a Flex Gateway listed, or you see a Flex Gateway but its status is Not Running, See Install Flex Gateway and Register and Run in Connected Mode for more information.

  5. Click Next.

  6. Configure the downstream configuration settings:

    Managed Flex Gateway
    Self-Managed Flex Gateway (Connected Mode)
  7. Click Next.

  8. Configure one of the following upstream configurations:

  9. Click Next.

Multiple Upstream Services for Flex Gateway Running in Connected Mode

Flex Gateway version 1.5.x or later supports API instances that expose multiple upstream services through a single consumer endpoint.

Flex Gateway manages request traffic by using different routes that can each direct traffic to multiple upstream services. Flex Gateway directs traffic to the routes by using the route order and the individual route’s rules. Additionally, you can add a weighted percentage to each upstream service within a route to manage the percentage of requests sent to the upstream service.

In the following diagram, different routes manage requests to flight information databases and to a customer service application. Route one has two upstream services defined, which direct 70% of requests to a stable database and 30% of requests to a beta database.

Flex Gateway manages the traffic to multiple upstreams

Limits

Limit Value Notes

Upstreams per API

{upstreams-per-api}

Each API supports {upstreams-per-api} upstreams. The {upstreams-per-api} upstreams can consist of a combination of different routes.

Routes per API

{routes-per-api}

Each API supports {routes-per-api} routes.

Upstreams per route

10

Headers per route rule

10

Routes

Each API instance supports up to {routes-per-api} routes and each route can support up to 10 upstream services. Configure what requests a route can receive by defining route rules and a route order. At least one route per API instance is required.

Before adding additional routes, enter an optional Route label for clarity.

You can add additional routes by clicking Add Route, and you can delete routes by clicking the Trash Can icon (2%). If only one route is defined, you cannot delete that route.

Route Rules

You can direct requests to different routes by using route rules.

To view and edit route rules, click Route Rules.

All rules are optional. If a rule does not have a value, that rule is ignored. For example, not specifying a host means that the route can service any host if the request meets the other route rules. Not defining any rule means that the route can service every request.

Different routes can support the same upstream services. If you cannot capture all requests for a particular set of upstream services in a single route rule set, you can define multiple routes with different rules for full coverage.

Only requests that meet all of the rules defined in the ruleset are directed to that route. If a request does not meet the rules for any route, Flex Gateway returns a 404 error code.

Flex Gateway supports the following route rules:

Method

Defines the types of request methods that the route can service.

You can select multiple methods for each route. Only requests that are one of the defined methods are directed to this route.

To select the supported methods:

  1. Expand the Method drop down list.

  2. Select all supported methods.

  3. Collapse the drop down list.

Path

Defines the request path that the route can service.

You can define only one “URI Template Regex" path for a route. Only requests with the defined path are sent to this route.

To define the Path rule:

  1. Enter your path template in the Path configuration field.

Host

Defines the request host that the route can service.

You can define only one host URL for each route. Only requests made from the defined host are sent to this route.

To define the Host rule:

  1. Enter your host in the Host configuration field.

Header

Defines what headers and regular expression value must be present for this route to service the request.

For this rule, you define the header name and a regular expression value. Only requests that meet all of the specified header requirements are sent to this route. Additional headers present in the request that are not specifically defined in the rules are ignored.

You can define up to 10 headers.

To define the Headers rule:

  1. Click Add header, if this is not your first header.

  2. Enter the header name in the first box.

  3. Enter the header’s regular expresion value in the second box.

    Note
    To delete a header, click the Trash Can icon (2%).

Route Order

In addition to using route rules, Flex Gateway directs requests to different routes by using the top to bottom order of how the routes appear on the page.

Flex Gateway directs requests to the first route if the request meets the route rules.

To define the route order, use the up and down arrows to arrange the routes.

Route ordering is very important when a request can meet the route rules of multiple routes. You should order the routes with more complex route rules first. If you do not define a route order, routes are ordered in the order they were created.

For example, in a configuration in which route one has the GET method defined as a rule and route two has no route rules defined, all GET requests are sent to route one and all other requests are sent to route two. If the route order was reversed and route one had no route rules, Flex Gateway would direct all requests to route one before any GET requests could reach route two.

Upstream Services

You can use multiple upstream services in a single route to direct requests to similar services. For example, to test the performance of a new beta upstream service without sending all traffic to the new service, you can direct half of the traffic to a stable upstream service and half to the new upstream service.

Each API instance route can support up to {upstreams-per-api} upstream services, but at least one upstream service is required for each route.

What upstream service within the route each request is sent to is random and independent of any previous request. The upstream Weight defines the percentage chance of a request being sent to a particular upstream service.

Because any upstream service within a route can receive any request, all upstream services within the same route must adhere to the same API contract.

You can add an upstream service by clicking Add Upstream, and you can delete an upstream service by clicking the Trash Can icon (2%). If only one upstream service is defined, you cannot delete it.

Configure the following fields for each upstream service:

Field Name Description Required Notes

Upstream URL

URL to access for the proxy or API. This must end with a /.

Yes

For example, you can use the URL of your API asset in Exchange.

Upstream Label

Label for the upstream service

No

If you have multiple upstream service instances, add a label to each one to differentiate it from the others.

TLS

TLS context used for the outbound traffic to the upstream service

No

Configure a TLS Context for Flex Gateway before adding a TLS context to your API. Add a TLS context by clicking Add TLS Context.

Weight

Percentage of requests to send to that upstream service

Yes

This value is configurable only if you have multiple upstream services. The sum of all upstream weights must equal 100%.

Notes

  • Although OpenAPI Specification (OAS) 3.0 is supported, the callback feature is not. To work around this issue, either handle the callback outside of the Mule runtime engine domain or use an OAS 3.0 specification that doesn’t use callbacks.