Skip to content
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

API: HTTP Filter ordering #2993

Merged
merged 31 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6d7b9dc
add filter ordering API
zhaohuabing Mar 21, 2024
e4e11cc
envoy HTTP filter ordering API
zhaohuabing Mar 21, 2024
fd26a09
add validation
zhaohuabing Mar 21, 2024
93e88d0
remove router
zhaohuabing Mar 21, 2024
59b4cc4
remove maxItem
zhaohuabing Mar 25, 2024
913a159
address comments
zhaohuabing Mar 25, 2024
ccc5180
Merge branch 'main' into filter-order
zhaohuabing Mar 25, 2024
dcc1063
fix json tag
zhaohuabing Mar 25, 2024
5ff23ef
fix gen
zhaohuabing Mar 25, 2024
50caf0a
Merge branch 'main' into filter-order
zhaohuabing Mar 25, 2024
8afa438
Merge branch 'main' into filter-order
zirain Mar 25, 2024
0956189
fix gen
zhaohuabing Mar 26, 2024
87748b9
address comments
zhaohuabing Mar 26, 2024
f9d315d
minor wording
zhaohuabing Mar 26, 2024
3780166
minor wording
zhaohuabing Mar 26, 2024
1d0e35d
Merge branch 'main' into filter-order
zhaohuabing Mar 26, 2024
e405951
fix gen
zhaohuabing Mar 26, 2024
f42aaa5
fix gen
zhaohuabing Mar 26, 2024
7371b69
minor wording
zhaohuabing Mar 26, 2024
11ab05a
fix gen
zhaohuabing Mar 26, 2024
a99b413
address comments
zhaohuabing Mar 26, 2024
73688ca
fix gent
zhaohuabing Mar 26, 2024
0a53710
Merge branch 'main' into filter-order
zhaohuabing Mar 26, 2024
0d76bfc
Merge branch 'main' into filter-order
zhaohuabing Mar 26, 2024
b2ba887
address comments
zhaohuabing Apr 12, 2024
9a12f9f
Merge branch 'main' into filter-order
zhaohuabing Apr 12, 2024
ade4707
kube gen
zhaohuabing Apr 12, 2024
e8291a0
Merge remote-tracking branch 'upstream/main' into filter-order
zhaohuabing Apr 16, 2024
d68ee22
address comments
zhaohuabing Apr 16, 2024
321b5ab
address comments
zhaohuabing Apr 17, 2024
7673385
Merge branch 'main' into filter-order
zirain Apr 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,46 @@ type EnvoyProxySpec struct {
//
// +optional
Shutdown *ShutdownConfig `json:"shutdown,omitempty"`

// FilterOrder defines the order of filters in the Envoy proxy's HTTP filter chain.
//
// +optional
FilterOrder []FilterOrder `json:"filterOrder,omitempty"`
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
}

// FilterOrder defines the order of filters in the Envoy proxy's HTTP filter chain.
// The order of filters is determined by the order field, where the filter with
// the lowest order value is applied first.
// If unspecified, the default order of filters is applied.
// Default order of filters:
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
// - envoy.filters.http.cors 0
// - envoy.filters.http.ext_authz 100
// - envoy.filters.http.basic_authn 200
// - envoy.filters.http.oauth2 300
// - envoy.filters.http.jwt_authn 400
// - envoy.filters.http.fault 500
// - envoy.filters.http.local_ratelimit 600
// - envoy.filters.http.rate_limit 700
type FilterOrder struct {
Filter EnvoyFilter `json:"filter"`
Order uint32 `json:"order"`
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
}

// EnvoyFilter defines the type of Envoy HTTP filter.
// +kubebuilder:validation:Enum=envoy.filters.http.cors;envoy.filters.http.ext_authz;envoy.filters.http.basic_authn;envoy.filters.http.oauth2;envoy.filters.http.jwt_authn;envoy.filters.http.fault;envoy.filters.http.local_ratelimit;envoy.filters.http.rate_limit;envoy.filters.http.routerfilters.http.router
type EnvoyFilter string
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved

const (
EnvoyFilterCORS EnvoyFilter = "envoy.filters.http.cors"
EnvoyFilterExtAuthz EnvoyFilter = "envoy.filters.http.ext_authz"
EnvoyFilterBasicAuthn EnvoyFilter = "envoy.filters.http.basic_authn"
EnvoyFilterOAuth2 EnvoyFilter = "envoy.filters.http.oauth2"
EnvoyFilterJWTAuthn EnvoyFilter = "envoy.filters.http.jwt_authn"
EnvoyFilterFault EnvoyFilter = "envoy.filters.http.fault"
EnvoyFilterLocalRateLimit EnvoyFilter = "envoy.filters.http.local_ratelimit"
EnvoyFilterRateLimit EnvoyFilter = "envoy.filters.http.rate_limit"
)

type ProxyTelemetry struct {
// AccessLogs defines accesslog parameters for managed proxies.
// If unspecified, will send default format to stdout.
Expand Down
20 changes: 20 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,41 @@ spec:
items:
type: string
type: array
filterOrder:
description: FilterOrder defines the order of filters in the Envoy
proxy's HTTP filter chain.
items:
description: 'FilterOrder defines the order of filters in the Envoy
proxy''s HTTP filter chain. The order of filters is determined
by the order field, where the filter with the lowest order value
is applied first. If unspecified, the default order of filters
is applied. Default order of filters: - envoy.filters.http.cors 0
- envoy.filters.http.ext_authz 100 - envoy.filters.http.basic_authn 200
- envoy.filters.http.oauth2 300 - envoy.filters.http.jwt_authn 400
- envoy.filters.http.fault 500 - envoy.filters.http.local_ratelimit 600
- envoy.filters.http.rate_limit 700'
properties:
filter:
description: EnvoyFilter defines the type of Envoy HTTP filter.
enum:
- envoy.filters.http.cors
- envoy.filters.http.ext_authz
- envoy.filters.http.basic_authn
- envoy.filters.http.oauth2
- envoy.filters.http.jwt_authn
- envoy.filters.http.fault
- envoy.filters.http.local_ratelimit
- envoy.filters.http.rate_limit
- envoy.filters.http.routerfilters.http.router
type: string
order:
format: int32
type: integer
required:
- filter
- order
type: object
type: array
logging:
default:
level:
Expand Down
27 changes: 27 additions & 0 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,17 @@ _Appears in:_
| `priority` | _integer_ | false | Priority of the EnvoyExtensionPolicy. If multiple EnvoyExtensionPolices are applied to the same TargetRef, extensions will execute in the ascending order of the priority i.e. int32.min has the highest priority and int32.max has the lowest priority. Defaults to 0. |


#### EnvoyFilter

_Underlying type:_ _string_

EnvoyFilter defines the type of Envoy HTTP filter.

_Appears in:_
- [FilterOrder](#filterorder)



#### EnvoyGateway


Expand Down Expand Up @@ -957,6 +968,7 @@ _Appears in:_
| `extraArgs` | _string array_ | false | ExtraArgs defines additional command line options that are provided to Envoy. More info: https://www.envoyproxy.io/docs/envoy/latest/operations/cli#command-line-options Note: some command line options are used internally(e.g. --log-level) so they cannot be provided here. |
| `mergeGateways` | _boolean_ | false | MergeGateways defines if Gateway resources should be merged onto the same Envoy Proxy Infrastructure. Setting this field to true would merge all Gateway Listeners under the parent Gateway Class. This means that the port, protocol and hostname tuple must be unique for every listener. If a duplicate listener is detected, the newer listener (based on timestamp) will be rejected and its status will be updated with a "Accepted=False" condition. |
| `shutdown` | _[ShutdownConfig](#shutdownconfig)_ | false | Shutdown defines configuration for graceful envoy shutdown process. |
| `filterOrder` | _[FilterOrder](#filterorder) array_ | false | FilterOrder defines the order of filters in the Envoy proxy's HTTP filter chain. |



Expand Down Expand Up @@ -1126,6 +1138,21 @@ _Appears in:_
| `path` | _string_ | true | Path defines the file path used to expose envoy access log(e.g. /dev/stdout). |


#### FilterOrder



FilterOrder defines the order of filters in the Envoy proxy's HTTP filter chain. The order of filters is determined by the order field, where the filter with the lowest order value is applied first. If unspecified, the default order of filters is applied. Default order of filters: - envoy.filters.http.cors 0 - envoy.filters.http.ext_authz 100 - envoy.filters.http.basic_authn 200 - envoy.filters.http.oauth2 300 - envoy.filters.http.jwt_authn 400 - envoy.filters.http.fault 500 - envoy.filters.http.local_ratelimit 600 - envoy.filters.http.rate_limit 700

_Appears in:_
- [EnvoyProxySpec](#envoyproxyspec)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `envoyFilters` | _[EnvoyFilter](#envoyfilter)_ | true | |
| `order` | _integer_ | true | |


#### GRPCExtAuthService


Expand Down
Loading