higress-group/higress
Implement api-spec plugin and support api level wasm configuration for all plugins
Open
#601 opened on Oct 24, 2023
area/apimarea/pluginhelp wantedlevel/challengesig/apim
Repository metrics
- Stars
- (9,036 stars)
- PR merge metrics
- (Avg merge 7d 9h) (18 merged PRs in 30d)
Description
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:
- 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.
- Config model standards
business api: Swagger, OAS3, gRPC/Dubbo IDL etc.route api: Ingress API, Gateway API, etc.
- 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:
- Apply transform plugin to the pricing api to implement mapping of price fields.
- 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
tagandoperationIdof 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