Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions internal/gatewayapi/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ func (t *Translator) ProcessGRPCFilters(
}
}

if httpFiltersContext.DirectResponse != nil && len(httpFiltersContext.Mirrors) > 0 {
httpFiltersContext.DirectResponse = nil
httpFiltersContext.Mirrors = nil

errs.Add(status.NewRouteStatusError(
errors.New(requestMirrorDirectResponseConflictMsg),
gwapiv1.RouteReasonIncompatibleFilters,
).WithType(gwapiv1.RouteConditionAccepted))
}

return httpFiltersContext, errs.GetAllErrors()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
gateways:
- apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
namespace: envoy-gateway
name: gateway-1
spec:
gatewayClassName: envoy-gateway-class
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: All
grpcRoutes:
- apiVersion: gateway.networking.k8s.io/v1
kind: GRPCRoute
metadata:
namespace: default
name: mirror-direct-response
spec:
parentRefs:
- namespace: envoy-gateway
name: gateway-1
sectionName: http
rules:
- backendRefs:
- name: service-1
port: 8080
filters:
- type: RequestMirror
requestMirror:
backendRef:
kind: Service
name: service-1
port: 8080
- type: ExtensionRef
extensionRef:
group: gateway.envoyproxy.io
kind: HTTPRouteFilter
name: mirror-direct-response
- backendRefs:
- name: service-2
port: 8080
httpFilters:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: HTTPRouteFilter
metadata:
name: mirror-direct-response
namespace: default
spec:
directResponse:
statusCode: 404
contentType: text/plain
body:
type: Inline
inline: "blocked"
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
gateways:
- apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: gateway-1
namespace: envoy-gateway
spec:
gatewayClassName: envoy-gateway-class
listeners:
- allowedRoutes:
namespaces:
from: All
name: http
port: 80
protocol: HTTP
status:
listeners:
- attachedRoutes: 1
conditions:
- lastTransitionTime: null
message: Sending translated listener configuration to the data plane
reason: Programmed
status: "True"
type: Programmed
- lastTransitionTime: null
message: Listener has been successfully translated
reason: Accepted
status: "True"
type: Accepted
- lastTransitionTime: null
message: Listener references have been resolved
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
name: http
supportedKinds:
- group: gateway.networking.k8s.io
kind: HTTPRoute
- group: gateway.networking.k8s.io
kind: GRPCRoute
grpcRoutes:
- apiVersion: gateway.networking.k8s.io/v1
kind: GRPCRoute
metadata:
name: mirror-direct-response
namespace: default
spec:
parentRefs:
- name: gateway-1
namespace: envoy-gateway
sectionName: http
rules:
- backendRefs:
- name: service-1
port: 8080
filters:
- requestMirror:
backendRef:
kind: Service
name: service-1
port: 8080
type: RequestMirror
- extensionRef:
group: gateway.envoyproxy.io
kind: HTTPRouteFilter
name: mirror-direct-response
type: ExtensionRef
- backendRefs:
- name: service-2
port: 8080
status:
parents:
- conditions:
- lastTransitionTime: null
message: Route is accepted
reason: Accepted
status: "True"
type: Accepted
- lastTransitionTime: null
message: |-
Dropped Rule(s) [0]: Invalid filter ExtensionRef: unknown kind gateway.envoyproxy.io/HTTPRouteFilter.
RequestMirror filter cannot be used when the rule also configures a DirectResponse filter.
reason: IncompatibleFilters, UnsupportedValue
status: "True"
type: PartiallyInvalid
- lastTransitionTime: null
message: Resolved all the Object references for the Route
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parentRef:
name: gateway-1
namespace: envoy-gateway
sectionName: http
infraIR:
envoy-gateway/gateway-1:
proxy:
listeners:
- name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http-80
protocol: HTTP
servicePort: 80
metadata:
labels:
gateway.envoyproxy.io/owning-gateway-name: gateway-1
gateway.envoyproxy.io/owning-gateway-namespace: envoy-gateway
ownerReference:
kind: GatewayClass
name: envoy-gateway-class
name: envoy-gateway/gateway-1
namespace: envoy-gateway-system
xdsIR:
envoy-gateway/gateway-1:
accessLog:
json:
- path: /dev/stdout
globalResources:
proxyServiceCluster:
metadata:
kind: Service
name: envoy-envoy-gateway-gateway-1-196ae069
namespace: envoy-gateway-system
sectionName: "8080"
name: envoy-gateway/gateway-1
settings:
- addressType: IP
endpoints:
- host: 7.6.5.4
port: 8080
zone: zone1
metadata:
kind: Service
name: envoy-envoy-gateway-gateway-1-196ae069
namespace: envoy-gateway-system
sectionName: "8080"
name: envoy-gateway/gateway-1
protocol: TCP
http:
- address: 0.0.0.0
externalPort: 80
grpc:
enableGRPCStats: true
enableGRPCWeb: true
hostnames:
- '*'
metadata:
kind: Gateway
name: gateway-1
namespace: envoy-gateway
sectionName: http
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- directResponse:
statusCode: 500
hostname: '*'
isHTTP2: true
metadata:
kind: GRPCRoute
name: mirror-direct-response
namespace: default
name: grpcroute/default/mirror-direct-response/rule/0/match/-1/*
- destination:
metadata:
kind: GRPCRoute
name: mirror-direct-response
namespace: default
name: grpcroute/default/mirror-direct-response/rule/1
settings:
- addressType: IP
endpoints:
- host: 7.7.7.7
port: 8080
metadata:
kind: Service
name: service-2
namespace: default
sectionName: "8080"
name: grpcroute/default/mirror-direct-response/rule/1/backend/0
protocol: GRPC
weight: 1
hostname: '*'
isHTTP2: true
metadata:
kind: GRPCRoute
name: mirror-direct-response
namespace: default
name: grpcroute/default/mirror-direct-response/rule/1/match/-1/*
readyListener:
address: 0.0.0.0
ipFamily: IPv4
path: /ready
port: 19003
15 changes: 15 additions & 0 deletions internal/provider/kubernetes/indexers.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,21 @@ func backendGRPCRouteIndexFunc(rawObj client.Object) []string {
)
}
}

for _, filter := range rule.Filters {
if filter.Type != gwapiv1.GRPCRouteFilterRequestMirror {
continue
}

mirrorBackendRef := filter.RequestMirror.BackendRef

backendRefs = append(backendRefs,
types.NamespacedName{
Namespace: gatewayapi.NamespaceDerefOr(mirrorBackendRef.Namespace, grpcroute.Namespace),
Name: string(mirrorBackendRef.Name),
}.String(),
)
}
}
return backendRefs
}
Expand Down
Loading
Loading