Closed eguzki closed 8 months ago
Attention: 353 lines
in your changes are missing coverage. Please review.
Comparison is base (
12b3aa3
) 0.55% compared to head (6405744
) 0.38%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Nice to see ideas around this. Wondering if there's a set of Gateway API related instructions that would make sense outside of Kuadrant as well, and thus maybe should live in a separate x-context?
Nice one @eguzki!
Giving it a try.
kuadrantctl generate gatewayapi httproute --oas petstore-openapi.yaml
Error: required flag(s) "gateway", "namespace", "public-host", "service-name" not set
Maybe I've missed something...
---
openapi: "3.0.3"
info:
title: "Pet Store API"
version: "1.0.0"
x-kuadrant:
route:
name: "petstore"
namespace: "petstore"
hostnames:
- example.com
parentRefs:
- name: istio-ingressgateway
namespace: istio-system
servers:
- url: https://example.io/v1
paths:
/cat:
x-kuadrant: ## Path level Kuadrant Extension
enable: true
backendRefs:
- name: petstore
port: 80
namespace: petstore
rate_limit:
rates:
- limit: 1
duration: 10
unit: second
counters:
- request.headers.x-forwarded-for
get: # Added to the route and rate limited
operationId: "getCat"
responses:
405:
description: "invalid input"
post: # NOT added to the route
x-kuadrant: ## Operation level Kuadrant Extension
enable: false
backendRefs:
- name: petstore
port: 80
namespace: petstore
rate_limit:
rates:
- limit: 2
duration: 10
unit: second
counters:
- request.headers.x-forwarded-for
operationId: "postCat"
responses:
405:
description: "invalid input"
/dog:
get: # Added to the route and rate limited
x-kuadrant: ## Operation level Kuadrant Extension
enable: true
backendRefs:
- name: petstore
port: 80
namespace: petstore
rate_limit:
rates:
- limit: 3
duration: 10
unit: second
counters:
- request.headers.x-forwarded-for
operationId: "getDog"
responses:
405:
description: "invalid input"
post: # Added to the route and NOT rate limited
x-kuadrant: ## Operation level Kuadrant Extension
enable: true
backendRefs:
- name: petstore
port: 80
namespace: petstore
operationId: "postDog"
responses:
405:
description: "invalid input"
/mouse:
get: # NOT added to the route
operationId: "getMouse"
responses:
405:
description: "invalid input"
Wondered if we could also look at a sample script to use this against api-poc-petstore
?
Nice one @eguzki!
Giving it a try.
kuadrantctl generate gatewayapi httproute --oas petstore-openapi.yaml Error: required flag(s) "gateway", "namespace", "public-host", "service-name" not set
Maybe I've missed something...
--- openapi: "3.0.3" info: title: "Pet Store API" version: "1.0.0" x-kuadrant: route: name: "petstore" namespace: "petstore" hostnames: - example.com parentRefs: - name: istio-ingressgateway namespace: istio-system servers: - url: https://example.io/v1 paths: /cat: x-kuadrant: ## Path level Kuadrant Extension enable: true backendRefs: - name: petstore port: 80 namespace: petstore rate_limit: rates: - limit: 1 duration: 10 unit: second counters: - request.headers.x-forwarded-for get: # Added to the route and rate limited operationId: "getCat" responses: 405: description: "invalid input" post: # NOT added to the route x-kuadrant: ## Operation level Kuadrant Extension enable: false backendRefs: - name: petstore port: 80 namespace: petstore rate_limit: rates: - limit: 2 duration: 10 unit: second counters: - request.headers.x-forwarded-for operationId: "postCat" responses: 405: description: "invalid input" /dog: get: # Added to the route and rate limited x-kuadrant: ## Operation level Kuadrant Extension enable: true backendRefs: - name: petstore port: 80 namespace: petstore rate_limit: rates: - limit: 3 duration: 10 unit: second counters: - request.headers.x-forwarded-for operationId: "getDog" responses: 405: description: "invalid input" post: # Added to the route and NOT rate limited x-kuadrant: ## Operation level Kuadrant Extension enable: true backendRefs: - name: petstore port: 80 namespace: petstore operationId: "postDog" responses: 405: description: "invalid input" /mouse: get: # NOT added to the route operationId: "getMouse" responses: 405: description: "invalid input"
Wondered if we could also look at a sample script to use this against
api-poc-petstore
?
Checkout the httproute-kuadrant-extensions
branch before make install
. You are compiling and old version of the command.
d'oh! 🤦
What
Kuadrant extensions for the OpenAPI Specification (OAS) 3.x to generate:
kuadrantctl generate gatewayapi httproute
to create Gateway API HTTPRoute from OpenAPI Specification (OAS) 3.x powered with kuadrant extensionskuadrantctl generate kuadrant ratelimitpolicy
command generates an Kuadrant RateLimitPolicy from your OpenAPI Specification (OAS) 3.x powered with kuadrant extensions.kuadrantctl generate kuadrant authpolicy
to create kuadrant Auth Policy from OpenAPI Specification (OAS) 3.x powered with kuadrant extensions #46 #50Info level kuadrant extension
Kuadrant extension that can be added at the info level of the OpenAPI spec.
Path level kuadrant extension
Kuadrant extension that can be added at the path level of the OpenAPI spec. This configuration at the path level is the default when there is no operation level configuration.
Operation level kuadrant extension
Kuadrant extension that can be added at the operation level of the OpenAPI spec. Same schema as path level kuadrant extension.
Verification Steps
httproute-kuadrant-extensions
bin/kuadrantctl
pathGET /cat
POST /cat
GET /dog
POST /dog
GET /mouse
Create the HTTPRoute using the CLI
Create the Rate Limit Policy
Test OpenAPI endpoints
GET /cat
-> It should return 200 Ok and be rate limited (1 req / 10 seconds)POST /cat
-> Not added to the HTTPRoute. It should return 404 Not FoundGET /dog
-> It should return 200 Ok and be rate limited (3 req / 10 seconds)POST /dog
-> It should return 200 Ok and NOT rate limitedGET /mouse
-> Not added to the HTTPRoute. It should return 404 Not Found