Skip to content

Commit d99dab1

Browse files
committed
Add examples of processor extension schema definition and advertising.
Signed-off-by: usize <[email protected]>
1 parent fd7009e commit d99dab1

File tree

1 file changed

+107
-1
lines changed

1 file changed

+107
-1
lines changed

proposals/10-egress-gateways.md

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ A catalog of standard policies will be defined, for example:
164164
165165
TODO: decide on a definitive catalog of processors.
166166
167-
Controllers MUST publish the set of supported processor kinds and versions for a GatewayClass via GatewayClass.status.parametersRef or an implementation-specific status e.g. GatewayClass.status.supportedExtensionKinds.
167+
Controllers MUST publish the set of supported processor kinds and versions for a GatewayClass via `GatewayClass.status.parametersRef` or an implementation-specific status e.g. `GatewayClass.status.supportedExtensionKinds`.
168168

169169
Admission MUST reject unknown catalog kinds and MAY admit domain-scoped kinds but set status Degraded with reason UnsupportedExtensionType until support is advertised.
170170

@@ -181,6 +181,112 @@ Additional processors may be defined. They MUST declare the following fields:
181181
Controllers MUST reject processors that declare unsupported phases or invalid schemas.
182182
Controllers SHOULD reconcile each processor independently, surfacing a `Degraded` status on a per-extension basis (to avoid requeuing entire Backend objects).
183183

184+
#### Processor Config Schema Example
185+
186+
Below is an example of how a config may be defined and made available as a ConfigMap.
187+
188+
```yaml
189+
apiVersion: v1
190+
kind: ConfigMap
191+
metadata:
192+
name: acme-piidetector-v1-schema
193+
namespace: gateway-system
194+
data:
195+
schema.json: |
196+
{
197+
"$schema": "https://json-schema.org/draft/2020-12/schema",
198+
"title": "acme.example.com/PIIDetector:v1 config",
199+
"type": "object",
200+
"additionalProperties": false,
201+
"properties": {
202+
"modelRef": {
203+
"type": "string",
204+
"minLength": 1,
205+
"description": "The PII model to use."
206+
},
207+
"redactionStyle": {
208+
"type": "string",
209+
"enum": ["mask", "delete", "hash"],
210+
"default": "mask",
211+
"description": "How matched PII is transformed"
212+
},
213+
"confidenceThreshold": {
214+
"type": "number",
215+
"minimum": 0.0,
216+
"maximum": 1.0,
217+
"default": 0.6,
218+
"description": "Minimum confidence score to redact"
219+
},
220+
"maxBodyBytes": {
221+
"type": "integer",
222+
"minimum": 0,
223+
"default": 1048576,
224+
"description": "Maximum bytes of body this processor will buffer (0 = unlimited per impl)"
225+
}
226+
},
227+
"required": ["modelRef"]
228+
}
229+
```
230+
231+
The controller may then advertise the processor via `GatewayClass.status.supportedExtensionKinds`.
232+
233+
```yaml
234+
apiVersion: gateway.networking.k8s.io/v1
235+
kind: GatewayClass
236+
metadata:
237+
name: envoy-gateway
238+
spec:
239+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
240+
status:
241+
supportedExtensionKinds:
242+
- group: gateway.networking.k8s.io
243+
kind: CredentialInjector
244+
versions: ["v1"]
245+
- group: acme.example.com
246+
kind: PIIDetector
247+
versions: ["v1"]
248+
schemaRefs:
249+
- apiVersion: v1
250+
kind: ConfigMap
251+
name: acme-piidetector-v1-schema
252+
namespace: gateway-system
253+
```
254+
255+
Finally the processor may be attached to a `Backend` as such:
256+
257+
```yaml
258+
apiVersion: gateway.networking.k8s.io/v1alpha1
259+
kind: Backend
260+
metadata:
261+
name: no-pii-openai
262+
namespace: app
263+
spec:
264+
destination:
265+
type: FQDN
266+
fqdn:
267+
hostname: api.openai.com
268+
port: 443
269+
tls:
270+
mode: Mutual
271+
sni: api.openai.com
272+
caBundleRef:
273+
name: vendor-ca
274+
# clientCertificateRef:
275+
# name: egress-client-cert
276+
extensions:
277+
- name: pii-detector
278+
type: acme.example.com/PIIDetector:v1
279+
phase: request-body
280+
priority: 20
281+
failOpen: false
282+
preAuth: true
283+
config:
284+
modelRef: pii-detect-small
285+
redactionStyle: delete
286+
confidenceThreshold: 0.7
287+
maxBodyBytes: 2097152
288+
```
289+
184290
#### Phases
185291

186292
Phases are always evaluated in the following order:

0 commit comments

Comments
 (0)