Skip to content

Implement api-spec plugin and support api level wasm configuration for all plugins #601

Open
@johnlanni

Description

@johnlanni

Why do you need it?

The api we are talking about here is "business api".

There are several differences between business api and route api:

  1. Intent
  • business api: Use to specific business functions such as trading, pricing, etc.
  • route api: Used to determine which service to proxy the request to if it meets certain conditions.
  1. Config model standards
  • business api: Swagger, OAS3, gRPC/Dubbo IDL etc.
  • route api: Ingress API, Gateway API, etc.
  1. Granularity
  • business api: One business function is mapped to one api.
  • route api: One service backend is mapped to some apis.

We want to implement business api level strategy, for example:

  1. Apply transform plugin to the pricing api to implement mapping of price fields.
  2. Apply key-rate-limit plugin to the trading api to limit transactions per second per user.

How could it be?

  • Implement a plugin which can binding business apis to a route (or service in the feature), plugin's configuration maybe like:
apiVersion: extensions.higress.io/v1alpha1
kind: WasmPlugin
metadata:
  name: api-spec
  namespace: higress-system
spec:
  url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/api-spec:1.0.0
  matchRules:
  - ingress:
    - default/foo
    config:
      name: petStore
      basePath: /v1
      spec:
        '/pet/{petId}':
            get:
              tags:
                - pet
              operationId: getPetById
            post:
              tags:
                - pet
              operationId: updatePetWithForm
  • We can control the acl of operationId of router
apiVersion: extensions.higress.io/v1alpha1
kind: WasmPlugin
metadata:
  name: api-acl
  namespace: higress-system
spec:
  url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/api-acl:1.0.0
  matchRules:
  - ingress:
    - default/foo
    config:
      allow:
      - getPetById
#     deny:
#     - updatePetWithForm
  • We can enable additional plugins when matching API's tag and operationId of specific routes:
apiVersion: extensions.higress.io/v1alpha1
kind: WasmPlugin
metadata:
  name: request-transform
  namespace: higress-system
spec:
  url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/transformer:1.0.0
  matchRules:
  - api:
    - updatePetWithForm
    ingress:
    - default/foo
    config:
      type: request
      rules:
      - operate: map
        querys:
        - key: petId
           value: petid
  - apiTag:
    - pet
    ingress:
    - default/foo    
    config:
      type: request
      rules:
      - operate: remove
        headers:
        - key: x-test-id

Other related information

part of #535

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions