-
Notifications
You must be signed in to change notification settings - Fork 826
feat: add admission control functionality #7529
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
Closed
Closed
Changes from all commits
Commits
Show all changes
25 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 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,119 @@ | ||
| // 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 defines the admission control policy to be applied. | ||
| // This configuration probabilistically rejects requests based on the success rate | ||
| // of previous requests in a configurable sliding time window. | ||
| // All fields are optional and will use Envoy's defaults when not specified. | ||
| // | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.successRateThreshold) || (self.successRateThreshold >= 1 && self.successRateThreshold <= 100)",message="successRateThreshold must be between 1 and 100" | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.maxRejectionProbability) || (self.maxRejectionProbability >= 0 && self.maxRejectionProbability <= 100)",message="maxRejectionProbability must be between 0 and 100" | ||
| type AdmissionControl struct { | ||
| // SamplingWindow defines the time window over which request success rates are calculated. | ||
| // Defaults to 30s if not specified. | ||
| // | ||
| // +optional | ||
| SamplingWindow *gwapiv1.Duration `json:"samplingWindow,omitempty"` | ||
|
|
||
| // SuccessRateThreshold 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 | ||
| SuccessRateThreshold *uint32 `json:"successRateThreshold,omitempty"` | ||
|
|
||
| // Aggression controls the rejection probability curve. A value of 1 means a linear | ||
| // increase in rejection probability as the success rate decreases. Higher values | ||
| // result in more aggressive rejection at higher success rates. | ||
| // Envoy requires aggression to be greater than 0 and clamps values below 1 to 1. | ||
| // Defaults to 1 if not specified. | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:Minimum=1 | ||
| Aggression *uint32 `json:"aggression,omitempty"` | ||
|
|
||
| // RPSThreshold 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 | ||
| RPSThreshold *uint32 `json:"rpsThreshold,omitempty"` | ||
|
|
||
| // MaxRejectionProbability 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 | ||
| MaxRejectionProbability *uint32 `json:"maxRejectionProbability,omitempty"` | ||
|
|
||
| // SuccessCriteria defines what constitutes a successful request for both HTTP and gRPC. | ||
| // | ||
| // +optional | ||
| SuccessCriteria *AdmissionControlSuccessCriteria `json:"successCriteria,omitempty"` | ||
| } | ||
|
|
||
| // 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 { | ||
| // HTTPSuccessStatus defines HTTP status codes that are considered successful. | ||
| // | ||
| // +optional | ||
| HTTPSuccessStatus []HTTPStatus `json:"httpSuccessStatus,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 { | ||
|
aburan28 marked this conversation as resolved.
|
||
| // GRPCSuccessStatus 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 | ||
| GRPCSuccessStatus []GRPCSuccessCode `json:"grpcSuccessStatus,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
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.