Skip to content
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

Rate Limit Service config in EnvoyGateway API #871

Merged
merged 4 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
//
arkodg marked this conversation as resolved.
Show resolved Hide resolved
// +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.
arkodg marked this conversation as resolved.
Show resolved Hide resolved
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"`
arkodg marked this conversation as resolved.
Show resolved Hide resolved
}

// RateLimitDatabaseBackend defines the configuration associated with
// the database backend used by the rate limit service.
arkodg marked this conversation as resolved.
Show resolved Hide resolved
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 {
arkodg marked this conversation as resolved.
Show resolved Hide resolved
// 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.