Skip to content

Commit

Permalink
Rate Limit Service config in EnvoyGateway API
Browse files Browse the repository at this point in the history
* Defines the configuration needed to enable as well
as connect the rate limit service to a redis database backend
* This will be required to be set by the infrastructure admin
if the app developers want the global rate limiting feature using
`RateLimitFilter`

Relates to envoyproxy#670

Signed-off-by: Arko Dasgupta <arko@tetrate.io>
  • Loading branch information
arkodg committed Jan 6, 2023
1 parent 5b79437 commit 740b1c8
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
48 changes: 48 additions & 0 deletions api/config/v1alpha1/envoygateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ type EnvoyGatewaySpec struct {
//
// +optional
Provider *Provider `json:"provider,omitempty"`

// RateLimit defines the configuration associated with the Rate Limit service
// deployed by Envoy Gateway required to implement the Global Rate limiting
// functionality. The specific rate limit service used here is the reference
// implementation in Envoy. For more details visit https://github.com/envoyproxy/ratelimit.
//
// +optional
RateLimit *RateLimit `json:"rateLimit,omitempty"`
}

// Gateway defines the desired Gateway API configuration of Envoy Gateway.
Expand Down Expand Up @@ -86,6 +94,46 @@ type FileProvider struct {
// TODO: Add config as use cases are better understood.
}

// RateLimit defines the configuration associated with the Rate Limit Service
// using for Global Rate Limiting.
type RateLimit struct {
// Backend holds the configuration associated with the
// database backend used by the rate limit service to store
// state associated with global ratelimiting.
Backend *RateLimitDatabaseBackend `json:"backend"`
}

// RateLimitDatabaseBackend defines the configuration associated with
// the database backend used by the rate limit service.
type RateLimitDatabaseBackend struct {
// Type is the type of database backend to use. Supported types are:
// * Redis: Connects to a Redis database.
//
// +unionDiscriminator
Type RateLimitDatabaseBackendType `json:"type"`
// Redis defines the settings needed to connect to a Redis database.
//
// +optional
Redis *RateLimitRedisSettings `json:"redis,omitempty"`
}

// RateLimitDatabaseBackendType specifies the types of database backend
// to be used by the rate limit service.
// +kubebuilder:validation:Enum=Redis
type RateLimitDatabaseBackendType string

const (
// RedisBackendType uses a redis database for the rate limit service.
RedisBackendType RateLimitDatabaseBackendType = "Redis"
)

// RateLimitRedisSettings defines the configuration for connecting to
// a Redis database.
type RateLimitRedisSettings struct {
// URL of the Redis Database.
URL *string `json:"url"`
}

func init() {
SchemeBuilder.Register(&EnvoyGateway{})
}
65 changes: 65 additions & 0 deletions api/config/v1alpha1/zz_generated.deepcopy.go

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

0 comments on commit 740b1c8

Please sign in to comment.