Repository navigation
Replies: 5 comments
|
The Can you explain why the We have Fault Injection now and when were discussing it yesterday, we think we will rename the "Entry" stage to "Fault" stage but if it's useful to change where the "Fault Injection" should happen, it would make sense to keep the "Entry" stage. Also, to be clear, this issue is for implementing ordering (and possibly allow multiple ext-proc filters) first but design in a way that we can add ordering to order filter like transformation (which is a dynamic module) |
We shouldn't reuse this annotation as it serves a different purpose (it's used to determine precedence during policy merging) - kgateway/api/annotations/policy.go Line 16 in b7f4988 I think that |
let's add this under each provider type, instead of top level of GatewayExtension, since we might not want to have filter stage configurable on all types (e.g. extauth) |
|
Thanks for the feedback @andy-fong @jenshu. Based on the feedback,
Based on the above decisions, we would simply need the apiVersion: gateway.kgateway.dev/v1alpha1
kind: GatewayExtension
metadata:
name: extproc-service
spec:
extProc:
grpcService:
backendRef:
name: extproc-svc
port: 9091
filterStage:
stage: AuthN
predicate: Before
weight: 10And depending on the use case and the GatewayExtension provider type, we can add support for |
|
this looks good to me! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Currently, the position of all the HTTP filters in the Envoy filter chain is hardcoded in kgateway and is not provided as a user-configurable. There have been feature requests to make filter positioning configurable, particularly for filters like ExtProc (#13230) and transformation. Rather than special casing a solution for individual filters, this proposal outlines a general design that enables configurable stage positioning across all HTTP filters.
The suggestion is to add a new
filterStagefield onGatewayExtensionfor extension backed filters (since the Envoy filter is built from the extension, not the policy) and on individualTrafficPolicysub-policy structs for native filters (since those have no separate extension resource and a singleTrafficPolicycan configure multiple filters needing independent positioning).This field configures three dimensions: which stage in the chain (
Entry,AuthN,AuthZ,RateLimit,Route), placement relative to that stage (Before,During,After), and which filter chain to target (DownstreamorUpstream).Per the feedback on #13459, we can expose a minimal, curated set of stages rather than all internal stages. Additional stages can be added later without breaking changes.
EntryAuthNAuthZRateLimitRouteGatewayExtension backed filters (ExtProc, ExtAuth)
Per the feedback on #13459, the
filterStageshould be added toGatewayExtension(notTrafficPolicy) so that a singleGatewayExtensionalways produces the same filter regardless of which policies reference it.When
filterStageis omitted, each extension type keeps its current default (e.g., ExtProc defaults to After AuthZ, ExtAuth defaults to During AuthN). Within the same stage, the existingkgateway.dev/policy-weightannotation controls relative ordering of multiple extensions of the same type within the same stage.Also each GatewayExtension is a distinct resource that produces its own filter instance, so two ExtProc GatewayExtensions at different stages naturally become two separate filters in the chain.
TrafficPolicy native filters (Transformation, Fault Injection, Header Mutation)
For filters configured directly on
TrafficPolicy, thefilterStagefield is added to each individual sub-policy struct. This is necessary because a singleTrafficPolicycan configure multiple filters simultaneously and each may need independent positioning.Not every sub-policy needs to have this field. Only those where repositioning has clear use cases:
filterStage?transformationfaultInjectionheaderModifierscorsrbacbasicAuth,apiKeyAuthcsrf,buffer,compressionWhen two TrafficPolicies with transformation (or any other sub-policy) target the same resource, they are merged into a single filter instance. Only one
filterStagesurvives. The higher-priority policy's value wins, consistent with how all other fields are resolved during merge. You cannot produce two separate filter instances at different stages by merging two TrafficPolicies. This is fundamentally different from GatewayExtension backed filters, where each extension is a separate resource that naturally produces its own filter instance.Upstream HTTP filter chain
The
chainfield onFilterStageConfigallows placing filters in Envoy's upstream HTTP filter chain (Router -> upstream_http_filters), which executes after an upstream host has been selected.The same
stageenum can be reused (though only Entry and Route are semantically meaningful in the upstream context).All reactions