-
Notifications
You must be signed in to change notification settings - Fork 826
feat: add admission control to BackendTrafficPolicy #8872
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
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
ae64948
add admission control functionality
aburan28 fead370
add admission control functionality crds
aburan28 ed7451d
fix the lint errors
aburan28 31febb0
fix: address CI lint and gen-check failures for admission control
aburan28 0fca7f5
incorporate some feedback
aburan28 ce38d07
update helm template test outputs after merge with upstream/main
aburan28 eef4e1a
use envoy defaults
aburan28 24f177b
use envoy defaults
aburan28 37b648f
add out files
aburan28 a75dfac
add testdata gen
aburan28 4988451
regenerate crds
aburan28 3f7d253
setup admission control as http upstream filter
aburan28 3696a2c
change to aggression
aburan28 566c3a9
change to aggression
aburan28 a16039d
fix: resolve rebase conflicts and regenerate testdata
aburan28 807a476
fix: address review feedback for admission control
aburan28 6545ecc
Merge branch 'main' into adam--add-admission-control
aburan28 97fc2da
test: regenerate admission-control testdata
aburan28 ead9d6d
test: regenerate helm-template snapshots and extension docs
aburan28 2a8a41a
Merge remote-tracking branch 'upstream/main' into adam--add-admission…
aburan28 a65fc3d
fix(admission-control): use new() instead of ptr.To to satisfy forbid…
aburan28 a98b9e2
address review feedback: revert HCM filter ordering, hoist gRPC code …
aburan28 7b7bfdb
Remove namespace from admission control targetRef
aburan28 16fc1f4
Address admission control review feedback
aburan28 80c8975
Merge branch 'main' into adam--add-admission-control
jukie 42a3dd0
Merge branch main into adam--add-admission-control
jukie d59ae24
Release note
jukie d9e91ff
CEL filtering for route types
jukie 5b98d84
feedback
jukie ee5eba3
Merge branch 'main' into admission-control
jukie 9962371
regen
jukie da89291
lint
jukie af4336f
Merge branch 'main' into admission-control
jukie c820084
trim statuscode field names
jukie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // Copyright Envoy Gateway Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // The full text of the Apache license is available in the LICENSE file at | ||
| // the root of the repo. | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" | ||
| ) | ||
|
|
||
| // AdmissionControl configures health-based load shedding for upstream backends. | ||
| // | ||
| // Envoy tracks recent upstream responses over a sliding sampling window. When the | ||
| // observed success rate drops below the configured threshold, Envoy | ||
| // probabilistically rejects new requests before forwarding them upstream. This can | ||
| // reduce pressure on degraded backends and give them time to recover. | ||
| // | ||
| // All fields are optional. When omitted, Envoy's admission control defaults are used. | ||
| // | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.minSuccessRate) || (self.minSuccessRate >= 1 && self.minSuccessRate <= 100)",message="minSuccessRate must be between 1 and 100" | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.maxRejectionPercent) || (self.maxRejectionPercent >= 0 && self.maxRejectionPercent <= 100)",message="maxRejectionPercent must be between 0 and 100" | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.samplingWindow) || duration(self.samplingWindow) >= duration('1s')",message="samplingWindow must be at least 1s" | ||
| type AdmissionControl struct { | ||
| // SamplingWindow defines the time window over which request success rates are calculated. | ||
| // Must be at least 1s; Envoy truncates the window to whole seconds and uses it as the | ||
| // denominator in RPS calculations, so sub-second values would produce a zero denominator. | ||
| // Defaults to 30s if not specified. | ||
| // | ||
| // +optional | ||
| SamplingWindow *gwapiv1.Duration `json:"samplingWindow,omitempty"` | ||
|
|
||
| // MinSuccessRate is the lowest request success rate, as a percentage in the | ||
| // range [1, 100], at which the filter will not reject requests. Defaults to 95 if | ||
| // not specified. Envoy rejects values below 1%, so values lower than 1 are not allowed. | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:Minimum=1 | ||
| // +kubebuilder:validation:Maximum=100 | ||
| MinSuccessRate *uint32 `json:"minSuccessRate,omitempty"` | ||
|
|
||
| // RejectionAggression controls how steeply the rejection probability rises | ||
| // as the observed success rate falls below MinSuccessRate. A value of 1 | ||
| // produces a linear curve; higher values reject more aggressively for a | ||
| // given drop in success rate. Must be greater than 0; values below 1 are | ||
| // clamped to 1. Defaults to 1. | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:Minimum=1 | ||
| RejectionAggression *uint32 `json:"rejectionAggression,omitempty"` | ||
|
|
||
| // MinRequestRate defines the minimum requests per second below which requests will | ||
| // pass through the filter without rejection. Defaults to 0 if not specified. | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:Minimum=0 | ||
| MinRequestRate *uint32 `json:"minRequestRate,omitempty"` | ||
|
|
||
| // MaxRejectionPercent represents the upper limit of the rejection probability, | ||
| // expressed as a percentage in the range [0, 100]. Defaults to 80 if not specified. | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:Minimum=0 | ||
| // +kubebuilder:validation:Maximum=100 | ||
| MaxRejectionPercent *uint32 `json:"maxRejectionPercent,omitempty"` | ||
|
|
||
| // SuccessCriteria defines what constitutes a successful request for both HTTP and gRPC. | ||
| // | ||
| // +optional | ||
| SuccessCriteria *AdmissionControlSuccessCriteria `json:"successCriteria,omitempty"` | ||
| } | ||
|
jukie marked this conversation as resolved.
|
||
|
|
||
| // AdmissionControlSuccessCriteria defines the criteria for determining successful requests. | ||
| type AdmissionControlSuccessCriteria struct { | ||
| // HTTP defines success criteria for HTTP requests. | ||
| // | ||
| // +optional | ||
| HTTP *HTTPSuccessCriteria `json:"http,omitempty"` | ||
|
|
||
| // GRPC defines success criteria for gRPC requests. | ||
| // | ||
| // +optional | ||
| GRPC *GRPCSuccessCriteria `json:"grpc,omitempty"` | ||
| } | ||
|
|
||
| // HTTPSuccessCriteria defines success criteria for HTTP requests. | ||
| type HTTPSuccessCriteria struct { | ||
| // StatusCodes defines HTTP status codes that are considered successful. | ||
| // | ||
| // +optional | ||
| StatusCodes []HTTPStatus `json:"statusCodes,omitempty"` | ||
| } | ||
|
|
||
| // GRPCSuccessCode defines gRPC status codes as defined in | ||
| // https://github.com/grpc/grpc/blob/master/doc/statuscodes.md#status-codes-and-their-use-in-grpc. | ||
| // +kubebuilder:validation:Enum=Ok;Cancelled;Unknown;InvalidArgument;DeadlineExceeded;NotFound;AlreadyExists;PermissionDenied;ResourceExhausted;FailedPrecondition;Aborted;OutOfRange;Unimplemented;Internal;Unavailable;DataLoss;Unauthenticated | ||
| type GRPCSuccessCode string | ||
|
|
||
| const ( | ||
| GRPCSuccessCodeOk GRPCSuccessCode = "Ok" | ||
| GRPCSuccessCodeCancelled GRPCSuccessCode = "Cancelled" | ||
| GRPCSuccessCodeUnknown GRPCSuccessCode = "Unknown" | ||
| GRPCSuccessCodeInvalidArgument GRPCSuccessCode = "InvalidArgument" | ||
| GRPCSuccessCodeDeadlineExceeded GRPCSuccessCode = "DeadlineExceeded" | ||
| GRPCSuccessCodeNotFound GRPCSuccessCode = "NotFound" | ||
| GRPCSuccessCodeAlreadyExists GRPCSuccessCode = "AlreadyExists" | ||
| GRPCSuccessCodePermissionDenied GRPCSuccessCode = "PermissionDenied" | ||
| GRPCSuccessCodeResourceExhausted GRPCSuccessCode = "ResourceExhausted" | ||
| GRPCSuccessCodeFailedPrecondition GRPCSuccessCode = "FailedPrecondition" | ||
| GRPCSuccessCodeAborted GRPCSuccessCode = "Aborted" | ||
| GRPCSuccessCodeOutOfRange GRPCSuccessCode = "OutOfRange" | ||
| GRPCSuccessCodeUnimplemented GRPCSuccessCode = "Unimplemented" | ||
| GRPCSuccessCodeInternal GRPCSuccessCode = "Internal" | ||
| GRPCSuccessCodeUnavailable GRPCSuccessCode = "Unavailable" | ||
| GRPCSuccessCodeDataLoss GRPCSuccessCode = "DataLoss" | ||
| GRPCSuccessCodeUnauthenticated GRPCSuccessCode = "Unauthenticated" | ||
| ) | ||
|
|
||
| // GRPCSuccessCriteria defines success criteria for gRPC requests. | ||
| type GRPCSuccessCriteria struct { | ||
| // StatusCodes defines gRPC status codes that are considered successful. | ||
| // Status codes are defined in https://github.com/grpc/grpc/blob/master/doc/statuscodes.md#status-codes-and-their-use-in-grpc. | ||
| // | ||
| // +optional | ||
| StatusCodes []GRPCSuccessCode `json:"statusCodes,omitempty"` | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.