-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamic config update via xDS Management Server (#373)
Signed-off-by: Renuka Fernando <[email protected]>
- Loading branch information
1 parent
f28024e
commit 1a68686
Showing
32 changed files
with
2,005 additions
and
249 deletions.
There are no files selected for viewing
This file contains 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 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,104 @@ | ||
syntax = "proto3"; | ||
|
||
package ratelimit.config.ratelimit.v3; | ||
|
||
option java_package = "io.envoyproxy.ratelimit.config.ratelimit.v3"; | ||
option java_outer_classname = "RlsConfigProto"; | ||
option java_multiple_files = true; | ||
option go_package = "github.com/envoyproxy/go-control-plane/ratelimit/config/ratelimit/v3;ratelimitv3"; | ||
|
||
// [#protodoc-title: Rate limit service configuration] | ||
// A management server which supports ADS (Aggregated Discovery Service - SotW or delta protocol) can apply | ||
// rate limit service configuration using the message type RateLimitConfig. The ADS client within the rate limit service | ||
// will stream Discovery Request with the resource type URL "type.googleapis.com/ratelimit.config.ratelimit.v3.RateLimitConfig". | ||
// The ADS management server should respond stream of Discovery Response with the same type URL and array of RateLimitConfigs | ||
// within resources of the Discovery Response. | ||
|
||
// Rate limit configuration for a single domain. | ||
message RateLimitConfig { | ||
// Name of the rate limit configuration. This should be unique for each configuration. | ||
string name = 1; | ||
|
||
// Domain name for the rate limit configuration. | ||
string domain = 2; | ||
|
||
// List of rate limit configuration descriptors. | ||
repeated RateLimitDescriptor descriptors = 3; | ||
} | ||
|
||
// Rate limit configuration descriptor. | ||
message RateLimitDescriptor { | ||
// Key of the descriptor. | ||
string key = 1; | ||
|
||
// Optional value of the descriptor. | ||
string value = 2; | ||
|
||
// Rate limit policy of the descriptor. | ||
RateLimitPolicy rate_limit = 3; | ||
|
||
// List of sub rate limit descriptors. | ||
repeated RateLimitDescriptor descriptors = 4; | ||
|
||
// Mark the descriptor as shadow. When the values is true, rate limit service allow requests to the backend. | ||
bool shadow_mode = 5; | ||
} | ||
|
||
// Rate-limit policy. | ||
message RateLimitPolicy { | ||
// Unit of time for the rate limit. | ||
RateLimitUnit unit = 1; | ||
|
||
// Number of requests allowed in the policy within `unit` time. | ||
uint32 requests_per_unit = 2; | ||
|
||
// Mark the rate limit policy as unlimited. All requests are allowed to the backend. | ||
bool unlimited = 3; | ||
|
||
// Optional name for the rate limit policy. Name the policy, if it should be replaced (dropped evaluation) by | ||
// another policy. | ||
string name = 4; | ||
|
||
// List of rate limit policies, this rate limit policy will replace (drop evaluation) | ||
// For more information: https://github.com/envoyproxy/ratelimit/tree/0b2f4d5fb04bf55e1873e2c5e2bb28da67c0643f#replaces | ||
// Example: https://github.com/envoyproxy/ratelimit/tree/0b2f4d5fb04bf55e1873e2c5e2bb28da67c0643f#example-7 | ||
repeated RateLimitReplace replaces = 5; | ||
} | ||
|
||
// Replace specifies the rate limit policy that should be replaced (dropped evaluation). | ||
// For more information: https://github.com/envoyproxy/ratelimit/tree/0b2f4d5fb04bf55e1873e2c5e2bb28da67c0643f#replaces | ||
message RateLimitReplace { | ||
// Name of the rate limit policy, that is being replaced (dropped evaluation). | ||
string name = 1; | ||
} | ||
|
||
// Identifies the unit of of time for rate limit. | ||
enum RateLimitUnit { | ||
// The time unit is not known. | ||
UNKNOWN = 0; | ||
|
||
// The time unit representing a second. | ||
SECOND = 1; | ||
|
||
// The time unit representing a minute. | ||
MINUTE = 2; | ||
|
||
// The time unit representing an hour. | ||
HOUR = 3; | ||
|
||
// The time unit representing a day. | ||
DAY = 4; | ||
} | ||
|
||
// [#protodoc-title: Rate Limit Config Discovery Service (RLS Conf DS)] | ||
|
||
// Return list of all rate limit configs that rate limit service should be configured with. | ||
service RateLimitConfigDiscoveryService { | ||
rpc StreamRlsConfigs(stream envoy.service.discovery.v3.DiscoveryRequest) | ||
returns (stream envoy.service.discovery.v3.DiscoveryResponse) { | ||
} | ||
|
||
rpc FetchRlsConfigs(envoy.service.discovery.v3.DiscoveryRequest) | ||
returns (envoy.service.discovery.v3.DiscoveryResponse) { | ||
} | ||
} |
This file contains 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 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,11 @@ | ||
FROM golang:1.18 AS build | ||
WORKDIR /xds-server | ||
|
||
COPY . . | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/xds-server -v main/main.go | ||
|
||
FROM alpine:3.16 AS final | ||
RUN apk --no-cache add ca-certificates && apk --no-cache update | ||
COPY --from=build /go/bin/xds-server /bin/xds-server | ||
ENTRYPOINT [ "/bin/xds-server" ] |
This file contains 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,17 @@ | ||
# Example Rate-limit Configuration SotW xDS Server | ||
|
||
This is an example of a trivial xDS V3 control plane server similar to the example server in [go-control-plane](https://github.com/envoyproxy/go-control-plane/tree/main/internal/example). It serves sample Rate limit configuration. You can run the example using the project top-level docker-compose-example.yml, e.g.: | ||
|
||
```bash | ||
export CONFIG_TYPE=GRPC_XDS_SOTW | ||
docker-compose -f docker-compose-example.yml --profile xds-config up --build --remove-orphans | ||
``` | ||
|
||
The docker-compose builds and runs the example server along with Rate limit server. The example server serves a configuration defined in [`resource.go`](resource.go). If everything works correctly, you can follow the [examples in project top-level README.md file](../../README.md#examples). | ||
|
||
## Files | ||
|
||
- [main/main.go](main/main.go) is the example program entrypoint. It instantiates the cache and xDS server and runs the xDS server process. | ||
- [resource.go](resource.go) generates a `Snapshot` structure which describes the configuration that the xDS server serves to Envoy. | ||
- [server.go](server.go) runs the xDS control plane server. | ||
- [logger.go](logger.go) is the logger. |
This file contains 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,20 @@ | ||
module github.com/envoyproxy/ratelimit/examples/xds-sotw-config-server | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/envoyproxy/go-control-plane v0.10.3-0.20230127155013-72157d335c8f | ||
google.golang.org/grpc v1.52.0 | ||
) | ||
|
||
require ( | ||
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect | ||
github.com/cncf/xds/go v0.0.0-20220314180256-7f1daf1720fc // indirect | ||
github.com/envoyproxy/protoc-gen-validate v0.9.1 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
golang.org/x/net v0.4.0 // indirect | ||
golang.org/x/sys v0.3.0 // indirect | ||
golang.org/x/text v0.5.0 // indirect | ||
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect | ||
google.golang.org/protobuf v1.28.1 // indirect | ||
) |
Oops, something went wrong.