Skip to content

Commit 2646c11

Browse files
skos-ninjalboynton
andauthored
feat(ext_proc): add support for observability mode (#8536)
* Attempt at adding observability mode Signed-off-by: Jake Oliver <jake@truelayer.com> Co-authored-by: Lee Boynton <lee.boynton@truelayer.com>
1 parent 532e2f9 commit 2646c11

17 files changed

Lines changed: 481 additions & 0 deletions

File tree

api/v1alpha1/ext_proc_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type ExtProcProcessingMode struct {
6969
// +kubebuilder:validation:XValidation:message="BackendRefs only supports Service, ServiceImport, and Backend kind.",rule="has(self.backendRefs) ? self.backendRefs.all(f, f.kind == 'Service' || f.kind == 'ServiceImport' || f.kind == 'Backend') : true"
7070
// +kubebuilder:validation:XValidation:message="BackendRefs only supports Core, multicluster.x-k8s.io, and gateway.envoyproxy.io groups.",rule="has(self.backendRefs) ? (self.backendRefs.all(f, f.group == \"\" || f.group == 'multicluster.x-k8s.io' || f.group == 'gateway.envoyproxy.io')) : true"
7171
// +kubebuilder:validation:XValidation:message="If FullDuplexStreamed body processing mode is used, FailOpen must be false.",rule="!(has(self.failOpen) && self.failOpen == true && has(self.processingMode) && ((has(self.processingMode.request) && has(self.processingMode.request.body) && self.processingMode.request.body == 'FullDuplexStreamed') || (has(self.processingMode.response) && has(self.processingMode.response.body) && self.processingMode.response.body == 'FullDuplexStreamed')))"
72+
// +kubebuilder:validation:XValidation:message="If shadowMode is enabled, body processing mode must be Streamed or unset.",rule="!(has(self.shadowMode) && self.shadowMode == true && has(self.processingMode) && ((has(self.processingMode.request) && has(self.processingMode.request.body) && self.processingMode.request.body != 'Streamed') || (has(self.processingMode.response) && has(self.processingMode.response.body) && self.processingMode.response.body != 'Streamed')))"
7273
type ExtProc struct {
7374
BackendCluster `json:",inline"`
7475

@@ -97,6 +98,15 @@ type ExtProc struct {
9798
// +optional
9899
ProcessingMode *ExtProcProcessingMode `json:"processingMode,omitempty"`
99100

101+
// ShadowMode sets if envoy gateway should treat this external processor as "send and go".
102+
// When enabled, Envoy forwards request/response data to the external processor but does
103+
// not wait for or apply any response from it. This maps to Envoy's `observability_mode`
104+
// on the ext_proc filter.
105+
// Defaults to false.
106+
//
107+
// +optional
108+
ShadowMode *bool `json:"shadowMode,omitempty"`
109+
100110
// Metadata defines options related to the sending and receiving of dynamic metadata.
101111
// These options define which metadata namespaces would be sent to the processor and which dynamic metadata
102112
// namespaces the processor would be permitted to emit metadata to.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_envoyextensionpolicies.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,14 @@ spec:
16091609
type: string
16101610
type: object
16111611
type: object
1612+
shadowMode:
1613+
description: |-
1614+
ShadowMode sets if envoy gateway should treat this external processor as "send and go".
1615+
When enabled, Envoy forwards request/response data to the external processor but does
1616+
not wait for or apply any response from it. This maps to Envoy's `observability_mode`
1617+
on the ext_proc filter.
1618+
Defaults to false.
1619+
type: boolean
16121620
statusOnError:
16131621
description: |-
16141622
Sets the HTTP status that is returned to the client when the external processor returns an error
@@ -1675,6 +1683,13 @@ spec:
16751683
&& self.processingMode.request.body == ''FullDuplexStreamed'')
16761684
|| (has(self.processingMode.response) && has(self.processingMode.response.body)
16771685
&& self.processingMode.response.body == ''FullDuplexStreamed'')))'
1686+
- message: If shadowMode is enabled, body processing mode must be
1687+
Streamed or unset.
1688+
rule: '!(has(self.shadowMode) && self.shadowMode == true && has(self.processingMode)
1689+
&& ((has(self.processingMode.request) && has(self.processingMode.request.body)
1690+
&& self.processingMode.request.body != ''Streamed'') || (has(self.processingMode.response)
1691+
&& has(self.processingMode.response.body) && self.processingMode.response.body
1692+
!= ''Streamed'')))'
16781693
maxItems: 16
16791694
type: array
16801695
lua:

charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_envoyextensionpolicies.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,14 @@ spec:
16081608
type: string
16091609
type: object
16101610
type: object
1611+
shadowMode:
1612+
description: |-
1613+
ShadowMode sets if envoy gateway should treat this external processor as "send and go".
1614+
When enabled, Envoy forwards request/response data to the external processor but does
1615+
not wait for or apply any response from it. This maps to Envoy's `observability_mode`
1616+
on the ext_proc filter.
1617+
Defaults to false.
1618+
type: boolean
16111619
statusOnError:
16121620
description: |-
16131621
Sets the HTTP status that is returned to the client when the external processor returns an error
@@ -1674,6 +1682,13 @@ spec:
16741682
&& self.processingMode.request.body == ''FullDuplexStreamed'')
16751683
|| (has(self.processingMode.response) && has(self.processingMode.response.body)
16761684
&& self.processingMode.response.body == ''FullDuplexStreamed'')))'
1685+
- message: If shadowMode is enabled, body processing mode must be
1686+
Streamed or unset.
1687+
rule: '!(has(self.shadowMode) && self.shadowMode == true && has(self.processingMode)
1688+
&& ((has(self.processingMode.request) && has(self.processingMode.request.body)
1689+
&& self.processingMode.request.body != ''Streamed'') || (has(self.processingMode.response)
1690+
&& has(self.processingMode.response.body) && self.processingMode.response.body
1691+
!= ''Streamed'')))'
16771692
maxItems: 16
16781693
type: array
16791694
lua:

internal/gatewayapi/envoyextensionpolicy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,10 @@ func (t *Translator) buildExtProc(
888888
extProcIR.MessageTimeout = ir.MetaV1DurationPtr(d)
889889
}
890890

891+
if extProc.ShadowMode != nil {
892+
extProcIR.ShadowMode = extProc.ShadowMode
893+
}
894+
891895
if extProc.FailOpen != nil {
892896
extProcIR.FailOpen = extProc.FailOpen
893897
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
gateways:
2+
- apiVersion: gateway.networking.k8s.io/v1
3+
kind: Gateway
4+
metadata:
5+
namespace: default
6+
name: gateway-1
7+
spec:
8+
gatewayClassName: envoy-gateway-class
9+
listeners:
10+
- name: http
11+
protocol: HTTP
12+
port: 80
13+
allowedRoutes:
14+
namespaces:
15+
from: All
16+
httpRoutes:
17+
- apiVersion: gateway.networking.k8s.io/v1
18+
kind: HTTPRoute
19+
metadata:
20+
namespace: default
21+
name: httproute-1
22+
spec:
23+
hostnames:
24+
- www.foo.com
25+
parentRefs:
26+
- namespace: default
27+
name: gateway-1
28+
sectionName: http
29+
rules:
30+
- matches:
31+
- path:
32+
value: /foo
33+
backendRefs:
34+
- name: service-1
35+
port: 8080
36+
services:
37+
- apiVersion: v1
38+
kind: Service
39+
metadata:
40+
namespace: default
41+
name: grpc-backend
42+
spec:
43+
ports:
44+
- port: 9000
45+
name: grpc
46+
protocol: TCP
47+
endpointSlices:
48+
- apiVersion: discovery.k8s.io/v1
49+
kind: EndpointSlice
50+
metadata:
51+
name: endpointslice-grpc-backend
52+
namespace: default
53+
labels:
54+
kubernetes.io/service-name: grpc-backend
55+
addressType: IPv4
56+
ports:
57+
- name: grpc
58+
protocol: TCP
59+
port: 9000
60+
endpoints:
61+
- addresses:
62+
- 8.8.8.8
63+
conditions:
64+
ready: true
65+
envoyExtensionPolicies:
66+
- apiVersion: gateway.envoyproxy.io/v1alpha1
67+
kind: EnvoyExtensionPolicy
68+
metadata:
69+
namespace: default
70+
name: policy-for-http-route
71+
spec:
72+
targetRef:
73+
group: gateway.networking.k8s.io
74+
kind: HTTPRoute
75+
name: httproute-1
76+
extProc:
77+
- backendRefs:
78+
- Name: grpc-backend
79+
Port: 9000
80+
shadowMode: true
81+
processingMode:
82+
request:
83+
body: Streamed
84+
response:
85+
body: Streamed

0 commit comments

Comments
 (0)