-
Notifications
You must be signed in to change notification settings - Fork 738
api: add bandwidth limit #8630
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
api: add bandwidth limit #8630
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
21f9a59
api: bandwidth limit
kkk777-7 6d6457c
api: fix response trailers and add cel
kkk777-7 c29f0d9
Merge branch 'main' into feat-bandwidth-api
kkk777-7 1632e87
api: redesign BandwidthLimitSpec with separate request/response configs
kkk777-7 d4f6314
Merge branch 'main' into feat-bandwidth-api
kkk777-7 ee25b2a
define bandwidth limit value and update crd comments
kkk777-7 6c9e730
update crd comments
kkk777-7 f8d9ff5
update cel validation test
kkk777-7 56e7fca
Merge branch 'main' into feat-bandwidth-api
kkk777-7 295c0aa
remove ptr
kkk777-7 89b187a
Merge branch 'main' into feat-bandwidth-api
kkk777-7 dcc60b3
update: define bandwidth limit unit
kkk777-7 9a271b7
fix: cel test
kkk777-7 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
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,92 @@ | ||
| // 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 ( | ||
| "k8s.io/apimachinery/pkg/api/resource" | ||
| ) | ||
|
|
||
| // BandwidthLimitSpec defines the desired state of BandwidthLimit. | ||
| // | ||
| // +kubebuilder:validation:XValidation:rule="has(self.request) || has(self.response)",message="at least one of request or response must be specified" | ||
| type BandwidthLimitSpec struct { | ||
| // Request configures bandwidth limits for traffic sent to the backend. | ||
| // | ||
| // +optional | ||
| Request *BandwidthLimitRequestConfig `json:"request,omitempty"` | ||
|
|
||
| // Response configures bandwidth limits for traffic sent from the backend. | ||
| // | ||
| // +optional | ||
| Response *BandwidthLimitResponseConfig `json:"response,omitempty"` | ||
| } | ||
|
|
||
| // BandwidthLimitRequestConfig defines the bandwidth limit configuration for the request direction. | ||
| type BandwidthLimitRequestConfig struct { | ||
| // Limit specifies the bandwidth limit as a bytes-per-unit throughput rate. | ||
| Limit BandwidthLimitValue `json:"limit"` | ||
| } | ||
|
|
||
| // BandwidthLimitResponseConfig defines the bandwidth limit configuration for the response direction. | ||
| type BandwidthLimitResponseConfig struct { | ||
| // Limit specifies the bandwidth limit as a bytes-per-unit throughput rate. | ||
| Limit BandwidthLimitValue `json:"limit"` | ||
|
|
||
| // ResponseTrailers configures the trailer headers appended to responses | ||
| // when bandwidth limiting introduces delays. | ||
| // | ||
| // +optional | ||
| ResponseTrailers *BandwidthLimitResponseTrailers `json:"responseTrailers,omitempty"` | ||
|
kkk777-7 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| // BandwidthLimitValue defines the bandwidth limit value and its time unit. | ||
| type BandwidthLimitValue struct { | ||
| // Value specifies the bandwidth limit. | ||
| // | ||
| // +kubebuilder:validation:XIntOrString | ||
| // +kubebuilder:validation:Pattern="^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$" | ||
| Value resource.Quantity `json:"value"` | ||
|
|
||
| // Unit specifies the time unit for the bandwidth limit (e.g. Second, Minute, Hour). | ||
| Unit BandwidthLimitUnit `json:"unit"` | ||
| } | ||
|
|
||
| // BandwidthLimitResponseTrailers defines the trailer headers appended to responses. | ||
| type BandwidthLimitResponseTrailers struct { | ||
| // Prefix is prepended to each trailer header name. | ||
| // If not set, no prefix is added and the trailers are named as-is. | ||
| // For example, setting "x-eg" produces trailers such as "x-eg-bandwidth-request-delay-ms", | ||
| // while leaving it unset produces "bandwidth-request-delay-ms". | ||
| // | ||
| // The following four trailers can be added: | ||
| // "bandwidth-request-delay-ms" is delay time in milliseconds it took for the request stream transfer | ||
| // including request body transfer time and the time added by the filter. | ||
| // "bandwidth-response-delay-ms" is delay time in milliseconds it took for the response stream transfer | ||
| // including response body transfer time and the time added by the filter. | ||
| // "bandwidth-request-filter-delay-ms" is delay time in milliseconds in request stream transfer added by the filter. | ||
| // "bandwidth-response-filter-delay-ms" is delay time in milliseconds that added by the filter. | ||
| // | ||
| // +optional | ||
| Prefix *string `json:"prefix,omitempty"` | ||
|
zhaohuabing marked this conversation as resolved.
|
||
| } | ||
|
|
||
| // BandwidthLimitUnit specifies the intervals for setting bandwidth limits. | ||
| // Valid BandwidthLimitUnit values are "Second", "Minute", "Hour". | ||
| // | ||
| // +kubebuilder:validation:Enum=Second;Minute;Hour | ||
| type BandwidthLimitUnit string | ||
|
|
||
| // BandwidthLimitUnit constants. | ||
| const ( | ||
| // BandwidthLimitUnitSecond specifies the bandwidth limit interval to be 1 second. | ||
| BandwidthLimitUnitSecond BandwidthLimitUnit = "Second" | ||
|
|
||
| // BandwidthLimitUnitMinute specifies the bandwidth limit interval to be 1 minute. | ||
| BandwidthLimitUnitMinute BandwidthLimitUnit = "Minute" | ||
|
|
||
| // BandwidthLimitUnitHour specifies the bandwidth limit interval to be 1 hour. | ||
| BandwidthLimitUnitHour BandwidthLimitUnit = "Hour" | ||
| ) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.