Skip to content

Commit

Permalink
Merge branch 'main' into go-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
guydc authored Apr 17, 2024
2 parents 67219e9 + e8b8074 commit 46284a6
Show file tree
Hide file tree
Showing 261 changed files with 685 additions and 368 deletions.
84 changes: 84 additions & 0 deletions api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,92 @@ type EnvoyProxySpec struct {
//
// +optional
Shutdown *ShutdownConfig `json:"shutdown,omitempty"`

// FilterOrder defines the order of filters in the Envoy proxy's HTTP filter chain.
// If unspecified, the default filter order is applied.
// Default filter order is:
//
// - envoy.filters.http.fault
//
// - envoy.filters.http.cors
//
// - envoy.filters.http.ext_authz
//
// - envoy.filters.http.basic_authn
//
// - envoy.filters.http.oauth2
//
// - envoy.filters.http.jwt_authn
//
// - envoy.filters.http.ext_proc
//
// - envoy.filters.http.wasm
//
// - envoy.filters.http.local_ratelimit
//
// - envoy.filters.http.ratelimit
//
// - envoy.filters.http.router
//
// +optional
// +notImplementedHide
FilterOrder []FilterPosition `json:"filterOrder,omitempty"`
}

// FilterPosition defines the position of an Envoy HTTP filter in the filter chain.
// +kubebuilder:validation:XValidation:rule="(has(self.before) || has(self.after))",message="one of before or after must be specified"
// +kubebuilder:validation:XValidation:rule="(has(self.before) && !has(self.after)) || (!has(self.before) && has(self.after))",message="only one of before or after can be specified"
type FilterPosition struct {
// Name of the filter.
Name EnvoyFilter `json:"filter"`

// Before defines the filter that should come before the filter.
// Only one of Before or After must be set.
Before *EnvoyFilter `json:"before,omitempty"`

// After defines the filter that should come after the filter.
// Only one of Before or After must be set.
After *EnvoyFilter `json:"after,omitempty"`
}

// EnvoyFilter defines the type of Envoy HTTP filter.
// +kubebuilder:validation:Enum=envoy.filters.http.cors;envoy.filters.http.ext_authz;envoy.filters.http.basic_authn;envoy.filters.http.oauth2;envoy.filters.http.jwt_authn;envoy.filters.http.fault;envoy.filters.http.local_ratelimit;envoy.filters.http.ratelimit;envoy.filters.http.wasm;envoy.filters.http.ext_proc
type EnvoyFilter string

const (
// EnvoyFilterFault defines the Envoy HTTP fault filter.
EnvoyFilterFault EnvoyFilter = "envoy.filters.http.fault"
// EnvoyFilterCORS defines the Envoy HTTP CORS filter.
EnvoyFilterCORS EnvoyFilter = "envoy.filters.http.cors"

// EnvoyFilterExtAuthz defines the Envoy HTTP external authorization filter.
EnvoyFilterExtAuthz EnvoyFilter = "envoy.filters.http.ext_authz"

// EnvoyFilterBasicAuthn defines the Envoy HTTP basic authentication filter.
EnvoyFilterBasicAuthn EnvoyFilter = "envoy.filters.http.basic_authn"

// EnvoyFilterOAuth2 defines the Envoy HTTP OAuth2 filter.
EnvoyFilterOAuth2 EnvoyFilter = "envoy.filters.http.oauth2"

// EnvoyFilterJWTAuthn defines the Envoy HTTP JWT authentication filter.
EnvoyFilterJWTAuthn EnvoyFilter = "envoy.filters.http.jwt_authn"

// EnvoyFilterExtProc defines the Envoy HTTP external process filter.
EnvoyFilterExtProc EnvoyFilter = "envoy.filters.http.ext_proc"

// EnvoyFilterWasm defines the Envoy HTTP WebAssembly filter.
EnvoyFilterWasm EnvoyFilter = "envoy.filters.http.wasm"

// EnvoyFilterLocalRateLimit defines the Envoy HTTP local rate limit filter.
EnvoyFilterLocalRateLimit EnvoyFilter = "envoy.filters.http.local_ratelimit"

// EnvoyFilterRateLimit defines the Envoy HTTP rate limit filter.
EnvoyFilterRateLimit EnvoyFilter = "envoy.filters.http.ratelimit"

// EnvoyFilterRouter defines the Envoy HTTP router filter.
EnvoyFilterRouter EnvoyFilter = "envoy.filters.http.router"
)

type ProxyTelemetry struct {
// AccessLogs defines accesslog parameters for managed proxies.
// If unspecified, will send default format to stdout.
Expand Down
32 changes: 32 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.

Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,104 @@ spec:
items:
type: string
type: array
filterOrder:
description: |-
FilterOrder defines the order of filters in the Envoy proxy's HTTP filter chain.
If unspecified, the default filter order is applied.
Default filter order is:
- envoy.filters.http.fault
- envoy.filters.http.cors
- envoy.filters.http.ext_authz
- envoy.filters.http.basic_authn
- envoy.filters.http.oauth2
- envoy.filters.http.jwt_authn
- envoy.filters.http.ext_proc
- envoy.filters.http.wasm
- envoy.filters.http.local_ratelimit
- envoy.filters.http.ratelimit
- envoy.filters.http.router
items:
description: FilterPosition defines the position of an Envoy HTTP
filter in the filter chain.
properties:
after:
description: |-
After defines the filter that should come after the filter.
Only one of Before or After must be set.
enum:
- envoy.filters.http.cors
- envoy.filters.http.ext_authz
- envoy.filters.http.basic_authn
- envoy.filters.http.oauth2
- envoy.filters.http.jwt_authn
- envoy.filters.http.fault
- envoy.filters.http.local_ratelimit
- envoy.filters.http.ratelimit
- envoy.filters.http.wasm
- envoy.filters.http.ext_proc
type: string
before:
description: |-
Before defines the filter that should come before the filter.
Only one of Before or After must be set.
enum:
- envoy.filters.http.cors
- envoy.filters.http.ext_authz
- envoy.filters.http.basic_authn
- envoy.filters.http.oauth2
- envoy.filters.http.jwt_authn
- envoy.filters.http.fault
- envoy.filters.http.local_ratelimit
- envoy.filters.http.ratelimit
- envoy.filters.http.wasm
- envoy.filters.http.ext_proc
type: string
filter:
description: Name of the filter.
enum:
- envoy.filters.http.cors
- envoy.filters.http.ext_authz
- envoy.filters.http.basic_authn
- envoy.filters.http.oauth2
- envoy.filters.http.jwt_authn
- envoy.filters.http.fault
- envoy.filters.http.local_ratelimit
- envoy.filters.http.ratelimit
- envoy.filters.http.wasm
- envoy.filters.http.ext_proc
type: string
required:
- filter
type: object
x-kubernetes-validations:
- message: one of before or after must be specified
rule: (has(self.before) || has(self.after))
- message: only one of before or after can be specified
rule: (has(self.before) && !has(self.after)) || (!has(self.before)
&& has(self.after))
type: array
logging:
default:
level:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ infraIR:
name: envoy-gateway-system/eg/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
4 changes: 4 additions & 0 deletions internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ func irUDPListenerName(listener *ListenerContext, udpRoute *UDPRouteContext) str
return fmt.Sprintf("%s/%s/%s/%s", listener.gateway.Namespace, listener.gateway.Name, listener.Name, udpRoute.Name)
}

func irListenerPortName(proto ir.ProtocolType, port int32) string {
return strings.ToLower(fmt.Sprintf("%s-%d", proto, port))
}

func irRoutePrefix(route RouteContext) string {
// add a "/" at the end of the prefix to prevent mismatching routes with the
// same prefix. For example, route prefix "/foo/" should not match a route "/foobar".
Expand Down
6 changes: 1 addition & 5 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,8 @@ func (t *Translator) processInfraIRListener(listener *ListenerContext, infraIR I
proto = ir.UDPProtocolType
}

infraPortName := string(listener.Name)
if t.MergeGateways {
infraPortName = irHTTPListenerName(listener)
}
infraPort := ir.ListenerPort{
Name: infraPortName,
Name: irListenerPortName(proto, servicePort.port),
Protocol: proto,
ServicePort: servicePort.port,
ContainerPort: servicePortToContainerPort(servicePort.port),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ infraIR:
name: another-namespace/not-same-namespace-gateway/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -520,7 +520,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -535,14 +535,14 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
- address: null
name: envoy-gateway/gateway-2/tcp
ports:
- containerPort: 10053
name: tcp
name: tcp-53
protocol: TCP
servicePort: 53
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -318,7 +318,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Loading

0 comments on commit 46284a6

Please sign in to comment.