Skip to content

Commit

Permalink
httproute: implement RequestMirror filter
Browse files Browse the repository at this point in the history
  • Loading branch information
hbagdi committed Sep 9, 2020
1 parent 52dc87b commit ef0e2f4
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 6 deletions.
39 changes: 37 additions & 2 deletions apis/v1alpha1/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,13 @@ const (
// FilterTypeHTTPRequestHeader can be used to add or remove an HTTP
// header from an HTTP request before it is sent to the upstream target.
// Support: core
// +optional
FilterTypeHTTPRequestHeader = "RequestHeader"
// TODO(hbagdi): add FilterHTTPRequestMirroring filter

// FilterTypeHTTPRequestMirror can be used to mirror requests to a
// different backend. The responses from this backend MUST be ignored
// by the Gateway.
// Support: extended
FilterTypeHTTPRequestMirror = "RequestMirror"

// FilterTypeImplementationSpecific should be used for configuring
// custom filters.
Expand Down Expand Up @@ -334,6 +338,8 @@ type HTTPRouteFilter struct {
// Filter-specific configuration definitions for core and extended filters

RequestHeader *HTTPRequestHeaderFilter `json:"requestHeader"`

RequestMirror *HTTPRequestMirrorFilter `json:"requestMirror"`
}

// HTTPRequestHeaderFilter defines configuration for the
Expand Down Expand Up @@ -379,6 +385,35 @@ type HTTPRequestHeaderFilter struct {
// TODO
}

// HTTPRequestMirrorFilter defines configuration for the
// RequestMirror filter.
type HTTPRequestMirrorFilter struct {
// TargetRef is an object reference to forward matched requests to.
// The resource may be "services" (omit or use the empty string for the
// group), or an implementation may support other resources (for
// example, resource "myroutetargets" in group "networking.acme.io").
// Omitting or specifying the empty string for both the resource and
// group indicates that the resource is "services". If the referent
// cannot be found, the "InvalidRoutes" status condition on any Gateway
// that includes the HTTPRoute will be true.
//
// Support: Core (Kubernetes Services)
// Support: Implementation-specific (Other resource types)
//
TargetRef ForwardToTargetObjectReference `json:"targetRef" protobuf:"bytes,1,opt,name=targetRef"`

// TargetPort specifies the destination port number to use for the TargetRef.
// If unspecified and TargetRef is a Service object consisting of a single
// port definition, that port will be used. If unspecified and TargetRef is
// a Service object consisting of multiple port definitions, an error is
// surfaced in status.
//
// Support: Core
//
// +optional
TargetPort *TargetPort `json:"targetPort,omitempty" protobuf:"bytes,2,opt,name=targetPort"`
}

// HTTPRouteAction is the action taken given a match.
type HTTPRouteAction struct {
// ForwardTo sends requests to the referenced object(s). The
Expand Down
26 changes: 26 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

56 changes: 56 additions & 0 deletions config/crd/bases/networking.x-k8s.io_httproutes.yaml

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

28 changes: 28 additions & 0 deletions config/crd/bases/networking.x-k8s.io_tcproutes.yaml

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

Loading

0 comments on commit ef0e2f4

Please sign in to comment.