-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kuadrant extensions #43
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #43 +/- ##
========================================
- Coverage 0.55% 0.38% -0.18%
========================================
Files 13 17 +4
Lines 538 783 +245
========================================
Hits 3 3
- Misses 535 780 +245 ☔ View full report in Codecov by Sentry. |
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? |
paths: | ||
/cat: | ||
x-kuadrant: ## Path level Kuadrant Extension | ||
enable: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if the default should be false and if "enable" is the most descriptive label.
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 |
Checkout the |
d'oh! 🤦 |
OAS server path as base path for matchers
bump go 1.21.x
Publish binary on release
Kuadrant extension enhancements
Generate Authpolicy from OpenAPI 3.0.X
kuadrant authpolicy command: support apikey
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 RateLimitPolicyfrom 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 Generate Authpolicy from OpenAPI 3.0.X #46 kuadrant authpolicy command: support apikey #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
git clone https://github.com/Kuadrant/kuadrantctl.git cd kuadrantctl git checkout httproute-kuadrant-extensions
bin/kuadrantctl
pathGET /cat
POST /cat
GET /dog
POST /dog
GET /mouse
bin/kuadrantctl generate gatewayapi httproute --oas petstore-openapi.yaml | kubectl apply -n petstore -f -
bin/kuadrantctl generate kuadrant ratelimitpolicy --oas petstore-openapi.yaml | kubectl apply -n petstore -f -
GET /cat
-> It should return 200 Ok and be rate limited (1 req / 10 seconds)curl --resolve example.com:9080:127.0.0.1 -v "http://example.com:9080/cat"
POST /cat
-> Not added to the HTTPRoute. It should return 404 Not Foundcurl --resolve example.com:9080:127.0.0.1 -v -X POST "http://example.com:9080/cat"
GET /dog
-> It should return 200 Ok and be rate limited (3 req / 10 seconds)curl --resolve example.com:9080:127.0.0.1 -v "http://example.com:9080/dog"
POST /dog
-> It should return 200 Ok and NOT rate limitedcurl --resolve example.com:9080:127.0.0.1 -v -X POST "http://example.com:9080/dog"
GET /mouse
-> Not added to the HTTPRoute. It should return 404 Not Foundcurl --resolve example.com:9080:127.0.0.1 -v -X POST "http://example.com:9080/mouse"