Skip to content

Commit

Permalink
Merge branch 'main' into feat-metrics-library
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <[email protected]>
  • Loading branch information
zirain authored Oct 26, 2023
2 parents a62fc8b + bec3f29 commit 0f7a312
Show file tree
Hide file tree
Showing 224 changed files with 1,688 additions and 337 deletions.
5 changes: 4 additions & 1 deletion OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ reviewers:
- chauhanshubham
- kflynn
- LanceEa
- qicz
- zhaohuabing
- tmsnan
- tanujd11
- cnvergence
- shawnh2
6 changes: 6 additions & 0 deletions api/v1alpha1/backendtrafficpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ type BackendTrafficPolicySpec struct {

// RateLimit allows the user to limit the number of incoming requests
// to a predefined value based on attributes within the traffic flow.
// +optional
RateLimit *RateLimitFilterSpec `json:"rateLimit,omitempty"`

// LoadBalancer policy to apply when routing traffic from the gateway to
// the backend endpoints
// +optional
LoadBalancer *LoadBalancer `json:"loadBalancer,omitempty"`
}

// BackendTrafficPolicyStatus defines the state of BackendTrafficPolicy
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/envoygateway_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func DefaultEnvoyGatewayLogging() *EnvoyGatewayLogging {
}
}

// GetEnvoyGatewayAdmin returns the EnvoyGatewayAdmin of EnvoyGateway or a default EnvoyGatewayAdmin if unspecified.
// GetEnvoyGatewayTelemetry returns the EnvoyGatewayTelemetry of EnvoyGateway or a default EnvoyGatewayTelemetry if unspecified.
func (e *EnvoyGateway) GetEnvoyGatewayTelemetry() *EnvoyGatewayTelemetry {
if e.Telemetry != nil {
if e.Telemetry.Metrics.Prometheus == nil {
Expand All @@ -108,8 +108,8 @@ func (e *EnvoyGateway) GetEnvoyGatewayTelemetry() *EnvoyGatewayTelemetry {
return e.Telemetry
}

// IfDisablePrometheus returns if disable prometheus.
func (e *EnvoyGateway) IfDisablePrometheus() bool {
// DisablePrometheus returns if disable prometheus.
func (e *EnvoyGateway) DisablePrometheus() bool {
return e.GetEnvoyGatewayTelemetry().Metrics.Prometheus.Disable
}

Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/envoyproxy_metric_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type ProxyPrometheusProvider struct {
}

// Match defines the stats match configuration.
type Match struct {
type Match struct { // TODO: zhaohuabing this type should be renamed to StatsMatch
// MatcherType defines the stats matcher type
//
// +kubebuilder:validation:Enum=RegularExpression;Prefix;Suffix
Expand All @@ -70,7 +70,7 @@ type Match struct {

type MatcherType string

const (
const ( // TODO: zhaohuabing the const types should be prefixed with StatsMatch
Prefix MatcherType = "Prefix"
RegularExpression MatcherType = "RegularExpression"
Suffix MatcherType = "Suffix"
Expand Down
55 changes: 55 additions & 0 deletions api/v1alpha1/loadbalancer_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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

// LoadBalancer defines the load balancer policy to be applied.
// +union
type LoadBalancer struct {
// Type decides the type of Load Balancer policy.
// Valid RateLimitType values are
// "ConsistentHash",
// "LeastRequest",
// "Random",
// "RoundRobin",
//
// +unionDiscriminator
Type LoadBalancerType `json:"type"`
// ConsistentHash defines the configuration when the load balancer type is
// set to ConsistentHash
//
// +optional
ConsistentHash *ConsistentHash `json:"consistentHash,omitempty"`
}

// LoadBalancerType specifies the types of LoadBalancer.
// +kubebuilder:validation:Enum=ConsistentHash;LeastRequest;Random;RoundRobin
type LoadBalancerType string

const (
// ConsistentHashLoadBalancerType load balancer policy.
ConsistentHashLoadBalancerType LoadBalancerType = "ConsistentHash"
// LeastRequestLoadBalancerType load balancer policy.
LeastRequestLoadBalancerType LoadBalancerType = "LeastRequest"
// RandomLoadBalancerType load balancer policy.
RandomLoadBalancerType LoadBalancerType = "Random"
// RoundRobinLoadBalancerType load balancer policy.
RoundRobinLoadBalancerType LoadBalancerType = "RoundRobin"
)

// ConsistentHash defines the configuration related to the consistent hash
// load balancer policy
type ConsistentHash struct {
Type ConsistentHashType `json:"type"`
}

// ConsistentHashType defines the type of input to hash on.
// +kubebuilder:validation:Enum=SourceIP
type ConsistentHashType string

const (
// SourceIPConsistentHashType hashes based on the source IP address.
SourceIPConsistentHashType ConsistentHashType = "SourceIP"
)
2 changes: 1 addition & 1 deletion api/v1alpha1/ratelimitfilter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ type SourceMatch struct {
}

// HeaderMatch defines the match attributes within the HTTP Headers of the request.
type HeaderMatch struct {
type HeaderMatch struct { // TODO: zhaohuabing this type could be replaced with a general purpose StringMatch type.
// Type specifies how to match against the value of the header.
//
// +optional
Expand Down
59 changes: 59 additions & 0 deletions api/v1alpha1/securitypolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,67 @@ type SecurityPolicySpec struct {
// for this Policy to have effect and be applied to the Gateway.
// TargetRef
TargetRef gwapiv1a2.PolicyTargetReferenceWithSectionName `json:"targetRef"`

// CORS defines the configuration for Cross-Origin Resource Sharing (CORS).
CORS *CORS `json:"cors,omitempty"`
}

// CORS defines the configuration for Cross-Origin Resource Sharing (CORS).
type CORS struct {
// AllowOrigins defines the origins that are allowed to make requests.
// +kubebuilder:validation:MinItems=1
AllowOrigins []StringMatch `json:"allowOrigins,omitempty" yaml:"allowOrigins,omitempty"`
// AllowMethods defines the methods that are allowed to make requests.
// +kubebuilder:validation:MinItems=1
AllowMethods []string `json:"allowMethods,omitempty" yaml:"allowMethods,omitempty"`
// AllowHeaders defines the headers that are allowed to be sent with requests.
AllowHeaders []string `json:"allowHeaders,omitempty" yaml:"allowHeaders,omitempty"`
// ExposeHeaders defines the headers that can be exposed in the responses.
ExposeHeaders []string `json:"exposeHeaders,omitempty" yaml:"exposeHeaders,omitempty"`
// MaxAge defines how long the results of a preflight request can be cached.
MaxAge *metav1.Duration `json:"maxAge,omitempty" yaml:"maxAge,omitempty"`
}

// StringMatch defines how to match any strings.
// This is a general purpose match condition that can be used by other EG APIs
// that need to match against a string.
type StringMatch struct {
// Type specifies how to match against a string.
//
// +optional
// +kubebuilder:default=Exact
Type *MatchType `json:"type,omitempty"`

// Value specifies the string value that the match must have.
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=1024
Value string `json:"value"`
}

// MatchType specifies the semantics of how a string value should be compared.
// Valid MatchType values are "Exact", "Prefix", "Suffix", "RegularExpression".
//
// +kubebuilder:validation:Enum=Exact;Prefix;Suffix;RegularExpression
type MatchType string

const (
// MatchExact :the input string must match exactly the match value.
MatchExact MatchType = "Exact"

// MatchPrefix :the input string must start with the match value.
MatchPrefix MatchType = "Prefix"

// MatchSuffix :the input string must end with the match value.
MatchSuffix MatchType = "Suffix"

// MatchRegularExpression :The input string must match the regular expression
// specified in the match value.
// The regex string must adhere to the syntax documented in
// https://github.com/google/re2/wiki/Syntax.
MatchRegularExpression MatchType = "RegularExpression"
)

// SecurityPolicyStatus defines the state of SecurityPolicy
type SecurityPolicyStatus struct {
// Conditions describe the current conditions of the SecurityPolicy.
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/validation/envoyproxy_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
_ "github.com/envoyproxy/gateway/internal/xds/extensions" // register the generated types to support protojson unmarshalling
)

// Validate validates the provided EnvoyProxy.
// ValidateEnvoyProxy validates the provided EnvoyProxy.
func ValidateEnvoyProxy(proxy *egv1a1.EnvoyProxy) error {
var errs []error
if proxy == nil {
Expand Down
107 changes: 107 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 0f7a312

Please sign in to comment.