API YAML Definition with Upstream Definition and Main/Sandbox Upstreams #369
Replies: 8 comments 1 reply
-
|
Is this a customized one that we're going to maintain in the gateway? Or are we going to accept standard openapi specification in the |
Beta Was this translation helpful? Give feedback.
-
|
How do we handle backend security in a multiple-upstream configuration? For example: upstreams:
# First upstream
- urls:
- http://prod-backend-1:5000/api/v2
weight: 80
# Second upstream
- urls:
- http://sandbox-backend-1:5000/api/v2
weight: 20 |
Beta Was this translation helpful? Give feedback.
-
|
Suggestion for sandbox and main vhosts: version: api-platform.wso2.com/v1alpha1
kind: http/rest
metadata:
name: Weather-API
version: v1.0
spec:
context: /weather
vhosts: # Optional
main: api.weather.com # Optional - if not configured, default vhost config is used
sandbox: sandbox-api.weather.com # Optional - if not configured, API will not be deployed with the sandbox vhost (sandbox endpoint can't be accessed)
upstreamDefinitions: # Suggestion 3: Define upstreams with names. This is for advance usacase.
- name: my-upstream-1
loadBalancer:
strategy: ROUND_ROBIN
timeout:
connect: 5s
request: 30s
idle: 60s
retry:
attempts: 3
conditions: [5xx, timeout, connection-failure]
backoff: exponential
upstreams: # Multiple upstreams
- urls:
- http://prod-backend-1:5000/api/v2
weight: 80
- urls:
- http://sandbox-backend-1:5000/api/v2
weight: 20
upstream: # API Level upstream |
Beta Was this translation helpful? Give feedback.
-
Discussion notesAttendees: Pubudu Gunatilaka, Thivindu Paranayapa, Nimsara Fernando, Nuwan Dias, Rakhitha Ranathunge, Piyumal Kularathna, Tharsanan Kurukulasingam, Thenujan Nagaratnam, Arshardh Ifthikar, Renuka Fernando, Osura Viduranga, Malintha Amarasinghe Notes:
New changes: version: api-platform.wso2.com/v1alpha1 # Suggestion 1: Change the version
kind: HttpRestApi
metadata: # Suggestion 2: Move name and version to metadata section
name: weather-api # name is the identifier.
spec:
version: v1.0.0
displayName: Weather API # in CLI and UI: displayName is shown as the name.
context: /weatherUpdated the suggested API YAML here #369 (comment). |
Beta Was this translation helpful? Give feedback.
-
|
There's a problem with the existing definition. We may need to bring the kind or duplicate the field in One possible solution is maintaining the accepted Async and HTTP data as structs and try to parse the spec we received based on the kind. If there's a validation error then we can reject the request at the earliest or proceed otherwise. When finalizing the openapi for the gateway-controller, please consider the async apis as well as the gateway is not going to support only @malinthaprasan @renuka-fernando FYI [1] https://swagger.io/docs/specification/v3_0/data-models/inheritance-and-polymorphism/ |
Beta Was this translation helpful? Give feedback.
-
Discussion notesWith a discussion with Malintha and Renuka we decided to change the kind and apiVersion as follows version: gateway.api-platform.wso2.com/v1alpha1 # Suggestion 1: Change the version
kind: RestApi
metadata: # Suggestion 2: Move name and version to metadata section
name: weather-api # name is the identifier.
spec:
version: v1.0.0
displayName: Weather API # in CLI and UI: displayName is shown as the name.
context: /weather |
Beta Was this translation helpful? Give feedback.
-
Discussion notesspec:
displayName: Weather API # Suggestion 12: in CLI and UI: displayName is shown as the name.
version: v1.0 # Suggestion 10: Move API version here
context: /weather
upstreamDefinitions: # Suggestion 3: Define upstreams with names. This is for advance usacase.
- name: my-upstream-1
loadBalancer:
strategy: ROUND_ROBIN
timeout:
connect: 5s
request: 30s
idle: 60s
retry:
attempts: 3
conditions: [5xx, timeout, connection-failure]
backoff: exponential
upstreams: # Multiple upstreams
- url: http://prod-backend-1:5000/api/v2
weight: 80
- url: http://sandbox-backend-1:5000/api/v2
weight: 20
upstream: # API Level upstream
main: # Suggestion 4: Changed to single URL. If multiple URLs are needed, use upstreamDefinitions.
url: http://prod-backend:5000/api/v2 # Suggestion 5: Use one of "url" or "ref"
sandbox:
ref: my-upstream-1
vhosts:
main:
default: "*"
sandbox:
default: "sandbox-*"
operations:Default Gateway Config
|
Beta Was this translation helpful? Give feedback.
-
|
When nothing is specified in GW config: gatewayConfig:
vhosts:
main
default: "*"
sandbox:
default: "sandbox-*"When there's only one vhost: gatewayConfig:
vhosts:
main
default: "*.wso2.com"
sandbox:
default: "sandbox-*.wso2.com"When there are multiple vhosts: gatewayConfig:
vhosts:
main
domains:
- *.wso2.com
- *.foo.com
default: "*.wso2.com"
sandbox:
domains:
- sandbox-*.wso2.com
- sandbox-*.foo.com
default: "sandbox-*.wso2.com"
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Suggested API YAML
Gateway Config
Suggestions Summary
api-platform.wso2.com/v1alpha1to indicate it's part of a specific API platform.nameandversionunder ametadatasection to better organizeupstreamDefinitionsfor better reusability and advanced configurations.upstreamfor simplicity. If multiple URLs are needed, useupstreamDefinitions.urlorrefunder upstreams.|HttpRestApi.specsince in k8s CRDs, version is usually part of the spec.nameas the identifier in metadata.displayNamefor showing the name in CLI and UI.Beta Was this translation helpful? Give feedback.
All reactions