gateway_api/apis/experimental/httproutes.rs
1// WARNING: generated by kopium - manual changes will be overwritten
2// kopium command: kopium --schema=derived --derive=JsonSchema --derive=Default --derive=PartialEq --docs -f -
3// kopium version: 0.21.2
4
5#[allow(unused_imports)]
6mod prelude {
7 pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
8 pub use kube::CustomResource;
9 pub use schemars::JsonSchema;
10 pub use serde::{Deserialize, Serialize};
11}
12use self::prelude::*;
13
14/// Spec defines the desired state of HTTPRoute.
15#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
16#[kube(
17 group = "gateway.networking.k8s.io",
18 version = "v1",
19 kind = "HTTPRoute",
20 plural = "httproutes"
21)]
22#[kube(namespaced)]
23#[kube(status = "HTTPRouteStatus")]
24#[kube(derive = "Default")]
25#[kube(derive = "PartialEq")]
26pub struct HTTPRouteSpec {
27 /// Hostnames defines a set of hostnames that should match against the HTTP Host
28 /// header to select a HTTPRoute used to process the request. Implementations
29 /// MUST ignore any port value specified in the HTTP Host header while
30 /// performing a match and (absent of any applicable header modification
31 /// configuration) MUST forward this header unmodified to the backend.
32 ///
33 /// Valid values for Hostnames are determined by RFC 1123 definition of a
34 /// hostname with 2 notable exceptions:
35 ///
36 /// 1. IPs are not allowed.
37 /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard
38 /// label must appear by itself as the first label.
39 ///
40 /// If a hostname is specified by both the Listener and HTTPRoute, there
41 /// must be at least one intersecting hostname for the HTTPRoute to be
42 /// attached to the Listener. For example:
43 ///
44 /// * A Listener with `test.example.com` as the hostname matches HTTPRoutes
45 /// that have either not specified any hostnames, or have specified at
46 /// least one of `test.example.com` or `*.example.com`.
47 /// * A Listener with `*.example.com` as the hostname matches HTTPRoutes
48 /// that have either not specified any hostnames or have specified at least
49 /// one hostname that matches the Listener hostname. For example,
50 /// `*.example.com`, `test.example.com`, and `foo.test.example.com` would
51 /// all match. On the other hand, `example.com` and `test.example.net` would
52 /// not match.
53 ///
54 /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted
55 /// as a suffix match. That means that a match for `*.example.com` would match
56 /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`.
57 ///
58 /// If both the Listener and HTTPRoute have specified hostnames, any
59 /// HTTPRoute hostnames that do not match the Listener hostname MUST be
60 /// ignored. For example, if a Listener specified `*.example.com`, and the
61 /// HTTPRoute specified `test.example.com` and `test.example.net`,
62 /// `test.example.net` must not be considered for a match.
63 ///
64 /// If both the Listener and HTTPRoute have specified hostnames, and none
65 /// match with the criteria above, then the HTTPRoute is not accepted. The
66 /// implementation must raise an 'Accepted' Condition with a status of
67 /// `False` in the corresponding RouteParentStatus.
68 ///
69 /// In the event that multiple HTTPRoutes specify intersecting hostnames (e.g.
70 /// overlapping wildcard matching and exact matching hostnames), precedence must
71 /// be given to rules from the HTTPRoute with the largest number of:
72 ///
73 /// * Characters in a matching non-wildcard hostname.
74 /// * Characters in a matching hostname.
75 ///
76 /// If ties exist across multiple Routes, the matching precedence rules for
77 /// HTTPRouteMatches takes over.
78 ///
79 /// Support: Core
80 #[serde(default, skip_serializing_if = "Option::is_none")]
81 pub hostnames: Option<Vec<String>>,
82 /// ParentRefs references the resources (usually Gateways) that a Route wants
83 /// to be attached to. Note that the referenced parent resource needs to
84 /// allow this for the attachment to be complete. For Gateways, that means
85 /// the Gateway needs to allow attachment from Routes of this kind and
86 /// namespace. For Services, that means the Service must either be in the same
87 /// namespace for a "producer" route, or the mesh implementation must support
88 /// and allow "consumer" routes for the referenced Service. ReferenceGrant is
89 /// not applicable for governing ParentRefs to Services - it is not possible to
90 /// create a "producer" route for a Service in a different namespace from the
91 /// Route.
92 ///
93 /// There are two kinds of parent resources with "Core" support:
94 ///
95 /// * Gateway (Gateway conformance profile)
96 /// * Service (Mesh conformance profile, ClusterIP Services only)
97 ///
98 /// This API may be extended in the future to support additional kinds of parent
99 /// resources.
100 ///
101 /// ParentRefs must be _distinct_. This means either that:
102 ///
103 /// * They select different objects. If this is the case, then parentRef
104 /// entries are distinct. In terms of fields, this means that the
105 /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must
106 /// be unique across all parentRef entries in the Route.
107 /// * They do not select different objects, but for each optional field used,
108 /// each ParentRef that selects the same object must set the same set of
109 /// optional fields to different values. If one ParentRef sets a
110 /// combination of optional fields, all must set the same combination.
111 ///
112 /// Some examples:
113 ///
114 /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the
115 /// same object must also set `sectionName`.
116 /// * If one ParentRef sets `port`, all ParentRefs referencing the same
117 /// object must also set `port`.
118 /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs
119 /// referencing the same object must also set `sectionName` and `port`.
120 ///
121 /// It is possible to separately reference multiple distinct objects that may
122 /// be collapsed by an implementation. For example, some implementations may
123 /// choose to merge compatible Gateway Listeners together. If that is the
124 /// case, the list of routes attached to those resources should also be
125 /// merged.
126 ///
127 /// Note that for ParentRefs that cross namespace boundaries, there are specific
128 /// rules. Cross-namespace references are only valid if they are explicitly
129 /// allowed by something in the namespace they are referring to. For example,
130 /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
131 /// generic way to enable other kinds of cross-namespace reference.
132 ///
133 ///
134 /// ParentRefs from a Route to a Service in the same namespace are "producer"
135 /// routes, which apply default routing rules to inbound connections from
136 /// any namespace to the Service.
137 ///
138 /// ParentRefs from a Route to a Service in a different namespace are
139 /// "consumer" routes, and these routing rules are only applied to outbound
140 /// connections originating from the same namespace as the Route, for which
141 /// the intended destination of the connections are a Service targeted as a
142 /// ParentRef of the Route.
143 #[serde(
144 default,
145 skip_serializing_if = "Option::is_none",
146 rename = "parentRefs"
147 )]
148 pub parent_refs: Option<Vec<HTTPRouteParentRefs>>,
149 /// Rules are a list of HTTP matchers, filters and actions.
150 #[serde(default, skip_serializing_if = "Option::is_none")]
151 pub rules: Option<Vec<HTTPRouteRules>>,
152 /// UseDefaultGateways indicates the default Gateway scope to use for this
153 /// Route. If unset (the default) or set to None, the Route will not be
154 /// attached to any default Gateway; if set, it will be attached to any
155 /// default Gateway supporting the named scope, subject to the usual rules
156 /// about which Routes a Gateway is allowed to claim.
157 ///
158 /// Think carefully before using this functionality! The set of default
159 /// Gateways supporting the requested scope can change over time without
160 /// any notice to the Route author, and in many situations it will not be
161 /// appropriate to request a default Gateway for a given Route -- for
162 /// example, a Route with specific security requirements should almost
163 /// certainly not use a default Gateway.
164 #[serde(
165 default,
166 skip_serializing_if = "Option::is_none",
167 rename = "useDefaultGateways"
168 )]
169 pub use_default_gateways: Option<HTTPRouteUseDefaultGateways>,
170}
171
172/// ParentReference identifies an API object (usually a Gateway) that can be considered
173/// a parent of this resource (usually a route). There are two kinds of parent resources
174/// with "Core" support:
175///
176/// * Gateway (Gateway conformance profile)
177/// * Service (Mesh conformance profile, ClusterIP Services only)
178///
179/// This API may be extended in the future to support additional kinds of parent
180/// resources.
181///
182/// The API object must be valid in the cluster; the Group and Kind must
183/// be registered in the cluster for this reference to be valid.
184#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
185pub struct HTTPRouteParentRefs {
186 /// Group is the group of the referent.
187 /// When unspecified, "gateway.networking.k8s.io" is inferred.
188 /// To set the core API group (such as for a "Service" kind referent),
189 /// Group must be explicitly set to "" (empty string).
190 ///
191 /// Support: Core
192 #[serde(default, skip_serializing_if = "Option::is_none")]
193 pub group: Option<String>,
194 /// Kind is kind of the referent.
195 ///
196 /// There are two kinds of parent resources with "Core" support:
197 ///
198 /// * Gateway (Gateway conformance profile)
199 /// * Service (Mesh conformance profile, ClusterIP Services only)
200 ///
201 /// Support for other resources is Implementation-Specific.
202 #[serde(default, skip_serializing_if = "Option::is_none")]
203 pub kind: Option<String>,
204 /// Name is the name of the referent.
205 ///
206 /// Support: Core
207 pub name: String,
208 /// Namespace is the namespace of the referent. When unspecified, this refers
209 /// to the local namespace of the Route.
210 ///
211 /// Note that there are specific rules for ParentRefs which cross namespace
212 /// boundaries. Cross-namespace references are only valid if they are explicitly
213 /// allowed by something in the namespace they are referring to. For example:
214 /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
215 /// generic way to enable any other kind of cross-namespace reference.
216 ///
217 ///
218 /// ParentRefs from a Route to a Service in the same namespace are "producer"
219 /// routes, which apply default routing rules to inbound connections from
220 /// any namespace to the Service.
221 ///
222 /// ParentRefs from a Route to a Service in a different namespace are
223 /// "consumer" routes, and these routing rules are only applied to outbound
224 /// connections originating from the same namespace as the Route, for which
225 /// the intended destination of the connections are a Service targeted as a
226 /// ParentRef of the Route.
227 ///
228 ///
229 /// Support: Core
230 #[serde(default, skip_serializing_if = "Option::is_none")]
231 pub namespace: Option<String>,
232 /// Port is the network port this Route targets. It can be interpreted
233 /// differently based on the type of parent resource.
234 ///
235 /// When the parent resource is a Gateway, this targets all listeners
236 /// listening on the specified port that also support this kind of Route(and
237 /// select this Route). It's not recommended to set `Port` unless the
238 /// networking behaviors specified in a Route must apply to a specific port
239 /// as opposed to a listener(s) whose port(s) may be changed. When both Port
240 /// and SectionName are specified, the name and port of the selected listener
241 /// must match both specified values.
242 ///
243 ///
244 /// When the parent resource is a Service, this targets a specific port in the
245 /// Service spec. When both Port (experimental) and SectionName are specified,
246 /// the name and port of the selected port must match both specified values.
247 ///
248 ///
249 /// Implementations MAY choose to support other parent resources.
250 /// Implementations supporting other types of parent resources MUST clearly
251 /// document how/if Port is interpreted.
252 ///
253 /// For the purpose of status, an attachment is considered successful as
254 /// long as the parent resource accepts it partially. For example, Gateway
255 /// listeners can restrict which Routes can attach to them by Route kind,
256 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment
257 /// from the referencing Route, the Route MUST be considered successfully
258 /// attached. If no Gateway listeners accept attachment from this Route,
259 /// the Route MUST be considered detached from the Gateway.
260 ///
261 /// Support: Extended
262 #[serde(default, skip_serializing_if = "Option::is_none")]
263 pub port: Option<i32>,
264 /// SectionName is the name of a section within the target resource. In the
265 /// following resources, SectionName is interpreted as the following:
266 ///
267 /// * Gateway: Listener name. When both Port (experimental) and SectionName
268 /// are specified, the name and port of the selected listener must match
269 /// both specified values.
270 /// * Service: Port name. When both Port (experimental) and SectionName
271 /// are specified, the name and port of the selected listener must match
272 /// both specified values.
273 ///
274 /// Implementations MAY choose to support attaching Routes to other resources.
275 /// If that is the case, they MUST clearly document how SectionName is
276 /// interpreted.
277 ///
278 /// When unspecified (empty string), this will reference the entire resource.
279 /// For the purpose of status, an attachment is considered successful if at
280 /// least one section in the parent resource accepts it. For example, Gateway
281 /// listeners can restrict which Routes can attach to them by Route kind,
282 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from
283 /// the referencing Route, the Route MUST be considered successfully
284 /// attached. If no Gateway listeners accept attachment from this Route, the
285 /// Route MUST be considered detached from the Gateway.
286 ///
287 /// Support: Core
288 #[serde(
289 default,
290 skip_serializing_if = "Option::is_none",
291 rename = "sectionName"
292 )]
293 pub section_name: Option<String>,
294}
295
296/// HTTPRouteRule defines semantics for matching an HTTP request based on
297/// conditions (matches), processing it (filters), and forwarding the request to
298/// an API object (backendRefs).
299#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
300pub struct HTTPRouteRules {
301 /// BackendRefs defines the backend(s) where matching requests should be
302 /// sent.
303 ///
304 /// Failure behavior here depends on how many BackendRefs are specified and
305 /// how many are invalid.
306 ///
307 /// If *all* entries in BackendRefs are invalid, and there are also no filters
308 /// specified in this route rule, *all* traffic which matches this rule MUST
309 /// receive a 500 status code.
310 ///
311 /// See the HTTPBackendRef definition for the rules about what makes a single
312 /// HTTPBackendRef invalid.
313 ///
314 /// When a HTTPBackendRef is invalid, 500 status codes MUST be returned for
315 /// requests that would have otherwise been routed to an invalid backend. If
316 /// multiple backends are specified, and some are invalid, the proportion of
317 /// requests that would otherwise have been routed to an invalid backend
318 /// MUST receive a 500 status code.
319 ///
320 /// For example, if two backends are specified with equal weights, and one is
321 /// invalid, 50 percent of traffic must receive a 500. Implementations may
322 /// choose how that 50 percent is determined.
323 ///
324 /// When a HTTPBackendRef refers to a Service that has no ready endpoints,
325 /// implementations SHOULD return a 503 for requests to that backend instead.
326 /// If an implementation chooses to do this, all of the above rules for 500 responses
327 /// MUST also apply for responses that return a 503.
328 ///
329 /// Support: Core for Kubernetes Service
330 ///
331 /// Support: Extended for Kubernetes ServiceImport
332 ///
333 /// Support: Implementation-specific for any other resource
334 ///
335 /// Support for weight: Core
336 #[serde(
337 default,
338 skip_serializing_if = "Option::is_none",
339 rename = "backendRefs"
340 )]
341 pub backend_refs: Option<Vec<HTTPRouteRulesBackendRefs>>,
342 /// Filters define the filters that are applied to requests that match
343 /// this rule.
344 ///
345 /// Wherever possible, implementations SHOULD implement filters in the order
346 /// they are specified.
347 ///
348 /// Implementations MAY choose to implement this ordering strictly, rejecting
349 /// any combination or order of filters that cannot be supported. If implementations
350 /// choose a strict interpretation of filter ordering, they MUST clearly document
351 /// that behavior.
352 ///
353 /// To reject an invalid combination or order of filters, implementations SHOULD
354 /// consider the Route Rules with this configuration invalid. If all Route Rules
355 /// in a Route are invalid, the entire Route would be considered invalid. If only
356 /// a portion of Route Rules are invalid, implementations MUST set the
357 /// "PartiallyInvalid" condition for the Route.
358 ///
359 /// Conformance-levels at this level are defined based on the type of filter:
360 ///
361 /// - ALL core filters MUST be supported by all implementations.
362 /// - Implementers are encouraged to support extended filters.
363 /// - Implementation-specific custom filters have no API guarantees across
364 /// implementations.
365 ///
366 /// Specifying the same filter multiple times is not supported unless explicitly
367 /// indicated in the filter.
368 ///
369 /// All filters are expected to be compatible with each other except for the
370 /// URLRewrite and RequestRedirect filters, which may not be combined. If an
371 /// implementation cannot support other combinations of filters, they must clearly
372 /// document that limitation. In cases where incompatible or unsupported
373 /// filters are specified and cause the `Accepted` condition to be set to status
374 /// `False`, implementations may use the `IncompatibleFilters` reason to specify
375 /// this configuration error.
376 ///
377 /// Support: Core
378 #[serde(default, skip_serializing_if = "Option::is_none")]
379 pub filters: Option<Vec<HTTPRouteRulesFilters>>,
380 /// Matches define conditions used for matching the rule against incoming
381 /// HTTP requests. Each match is independent, i.e. this rule will be matched
382 /// if **any** one of the matches is satisfied.
383 ///
384 /// For example, take the following matches configuration:
385 ///
386 /// ```text
387 /// matches:
388 /// - path:
389 /// value: "/foo"
390 /// headers:
391 /// - name: "version"
392 /// value: "v2"
393 /// - path:
394 /// value: "/v2/foo"
395 /// ```
396 ///
397 /// For a request to match against this rule, a request must satisfy
398 /// EITHER of the two conditions:
399 ///
400 /// - path prefixed with `/foo` AND contains the header `version: v2`
401 /// - path prefix of `/v2/foo`
402 ///
403 /// See the documentation for HTTPRouteMatch on how to specify multiple
404 /// match conditions that should be ANDed together.
405 ///
406 /// If no matches are specified, the default is a prefix
407 /// path match on "/", which has the effect of matching every
408 /// HTTP request.
409 ///
410 /// Proxy or Load Balancer routing configuration generated from HTTPRoutes
411 /// MUST prioritize matches based on the following criteria, continuing on
412 /// ties. Across all rules specified on applicable Routes, precedence must be
413 /// given to the match having:
414 ///
415 /// * "Exact" path match.
416 /// * "Prefix" path match with largest number of characters.
417 /// * Method match.
418 /// * Largest number of header matches.
419 /// * Largest number of query param matches.
420 ///
421 /// Note: The precedence of RegularExpression path matches are implementation-specific.
422 ///
423 /// If ties still exist across multiple Routes, matching precedence MUST be
424 /// determined in order of the following criteria, continuing on ties:
425 ///
426 /// * The oldest Route based on creation timestamp.
427 /// * The Route appearing first in alphabetical order by
428 /// "{namespace}/{name}".
429 ///
430 /// If ties still exist within an HTTPRoute, matching precedence MUST be granted
431 /// to the FIRST matching rule (in list order) with a match meeting the above
432 /// criteria.
433 ///
434 /// When no rules matching a request have been successfully attached to the
435 /// parent a request is coming from, a HTTP 404 status code MUST be returned.
436 #[serde(default, skip_serializing_if = "Option::is_none")]
437 pub matches: Option<Vec<HTTPRouteRulesMatches>>,
438 /// Name is the name of the route rule. This name MUST be unique within a Route if it is set.
439 ///
440 /// Support: Extended
441 #[serde(default, skip_serializing_if = "Option::is_none")]
442 pub name: Option<String>,
443 /// Retry defines the configuration for when to retry an HTTP request.
444 ///
445 /// Support: Extended
446 #[serde(default, skip_serializing_if = "Option::is_none")]
447 pub retry: Option<HTTPRouteRulesRetry>,
448 /// SessionPersistence defines and configures session persistence
449 /// for the route rule.
450 ///
451 /// Support: Extended
452 #[serde(
453 default,
454 skip_serializing_if = "Option::is_none",
455 rename = "sessionPersistence"
456 )]
457 pub session_persistence: Option<HTTPRouteRulesSessionPersistence>,
458 /// Timeouts defines the timeouts that can be configured for an HTTP request.
459 ///
460 /// Support: Extended
461 #[serde(default, skip_serializing_if = "Option::is_none")]
462 pub timeouts: Option<HTTPRouteRulesTimeouts>,
463}
464
465/// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request.
466///
467/// Note that when a namespace different than the local namespace is specified, a
468/// ReferenceGrant object is required in the referent namespace to allow that
469/// namespace's owner to accept the reference. See the ReferenceGrant
470/// documentation for details.
471///
472///
473/// When the BackendRef points to a Kubernetes Service, implementations SHOULD
474/// honor the appProtocol field if it is set for the target Service Port.
475///
476/// Implementations supporting appProtocol SHOULD recognize the Kubernetes
477/// Standard Application Protocols defined in KEP-3726.
478///
479/// If a Service appProtocol isn't specified, an implementation MAY infer the
480/// backend protocol through its own means. Implementations MAY infer the
481/// protocol from the Route type referring to the backend Service.
482///
483/// If a Route is not able to send traffic to the backend using the specified
484/// protocol then the backend is considered invalid. Implementations MUST set the
485/// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason.
486#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
487pub struct HTTPRouteRulesBackendRefs {
488 /// Filters defined at this level should be executed if and only if the
489 /// request is being forwarded to the backend defined here.
490 ///
491 /// Support: Implementation-specific (For broader support of filters, use the
492 /// Filters field in HTTPRouteRule.)
493 #[serde(default, skip_serializing_if = "Option::is_none")]
494 pub filters: Option<Vec<HTTPRouteRulesBackendRefsFilters>>,
495 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
496 /// When unspecified or empty string, core API group is inferred.
497 #[serde(default, skip_serializing_if = "Option::is_none")]
498 pub group: Option<String>,
499 /// Kind is the Kubernetes resource kind of the referent. For example
500 /// "Service".
501 ///
502 /// Defaults to "Service" when not specified.
503 ///
504 /// ExternalName services can refer to CNAME DNS records that may live
505 /// outside of the cluster and as such are difficult to reason about in
506 /// terms of conformance. They also may not be safe to forward to (see
507 /// CVE-2021-25740 for more information). Implementations SHOULD NOT
508 /// support ExternalName Services.
509 ///
510 /// Support: Core (Services with a type other than ExternalName)
511 ///
512 /// Support: Implementation-specific (Services with type ExternalName)
513 #[serde(default, skip_serializing_if = "Option::is_none")]
514 pub kind: Option<String>,
515 /// Name is the name of the referent.
516 pub name: String,
517 /// Namespace is the namespace of the backend. When unspecified, the local
518 /// namespace is inferred.
519 ///
520 /// Note that when a namespace different than the local namespace is specified,
521 /// a ReferenceGrant object is required in the referent namespace to allow that
522 /// namespace's owner to accept the reference. See the ReferenceGrant
523 /// documentation for details.
524 ///
525 /// Support: Core
526 #[serde(default, skip_serializing_if = "Option::is_none")]
527 pub namespace: Option<String>,
528 /// Port specifies the destination port number to use for this resource.
529 /// Port is required when the referent is a Kubernetes Service. In this
530 /// case, the port number is the service port number, not the target port.
531 /// For other resources, destination port might be derived from the referent
532 /// resource or this field.
533 #[serde(default, skip_serializing_if = "Option::is_none")]
534 pub port: Option<i32>,
535 /// Weight specifies the proportion of requests forwarded to the referenced
536 /// backend. This is computed as weight/(sum of all weights in this
537 /// BackendRefs list). For non-zero values, there may be some epsilon from
538 /// the exact proportion defined here depending on the precision an
539 /// implementation supports. Weight is not a percentage and the sum of
540 /// weights does not need to equal 100.
541 ///
542 /// If only one backend is specified and it has a weight greater than 0, 100%
543 /// of the traffic is forwarded to that backend. If weight is set to 0, no
544 /// traffic should be forwarded for this entry. If unspecified, weight
545 /// defaults to 1.
546 ///
547 /// Support for this field varies based on the context where used.
548 #[serde(default, skip_serializing_if = "Option::is_none")]
549 pub weight: Option<i32>,
550}
551
552/// HTTPRouteFilter defines processing steps that must be completed during the
553/// request or response lifecycle. HTTPRouteFilters are meant as an extension
554/// point to express processing that may be done in Gateway implementations. Some
555/// examples include request or response modification, implementing
556/// authentication strategies, rate-limiting, and traffic shaping. API
557/// guarantee/conformance is defined based on the type of the filter.
558#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
559pub struct HTTPRouteRulesBackendRefsFilters {
560 /// CORS defines a schema for a filter that responds to the
561 /// cross-origin request based on HTTP response header.
562 ///
563 /// Support: Extended
564 #[serde(default, skip_serializing_if = "Option::is_none")]
565 pub cors: Option<HTTPRouteRulesBackendRefsFiltersCors>,
566 /// ExtensionRef is an optional, implementation-specific extension to the
567 /// "filter" behavior. For example, resource "myroutefilter" in group
568 /// "networking.example.net"). ExtensionRef MUST NOT be used for core and
569 /// extended filters.
570 ///
571 /// This filter can be used multiple times within the same rule.
572 ///
573 /// Support: Implementation-specific
574 #[serde(
575 default,
576 skip_serializing_if = "Option::is_none",
577 rename = "extensionRef"
578 )]
579 pub extension_ref: Option<HTTPRouteRulesBackendRefsFiltersExtensionRef>,
580 /// ExternalAuth configures settings related to sending request details
581 /// to an external auth service. The external service MUST authenticate
582 /// the request, and MAY authorize the request as well.
583 ///
584 /// If there is any problem communicating with the external service,
585 /// this filter MUST fail closed.
586 ///
587 /// Support: Extended
588 #[serde(
589 default,
590 skip_serializing_if = "Option::is_none",
591 rename = "externalAuth"
592 )]
593 pub external_auth: Option<HTTPRouteRulesBackendRefsFiltersExternalAuth>,
594 /// RequestHeaderModifier defines a schema for a filter that modifies request
595 /// headers.
596 ///
597 /// Support: Core
598 #[serde(
599 default,
600 skip_serializing_if = "Option::is_none",
601 rename = "requestHeaderModifier"
602 )]
603 pub request_header_modifier: Option<HTTPRouteRulesBackendRefsFiltersRequestHeaderModifier>,
604 /// RequestMirror defines a schema for a filter that mirrors requests.
605 /// Requests are sent to the specified destination, but responses from
606 /// that destination are ignored.
607 ///
608 /// This filter can be used multiple times within the same rule. Note that
609 /// not all implementations will be able to support mirroring to multiple
610 /// backends.
611 ///
612 /// Support: Extended
613 #[serde(
614 default,
615 skip_serializing_if = "Option::is_none",
616 rename = "requestMirror"
617 )]
618 pub request_mirror: Option<HTTPRouteRulesBackendRefsFiltersRequestMirror>,
619 /// RequestRedirect defines a schema for a filter that responds to the
620 /// request with an HTTP redirection.
621 ///
622 /// Support: Core
623 #[serde(
624 default,
625 skip_serializing_if = "Option::is_none",
626 rename = "requestRedirect"
627 )]
628 pub request_redirect: Option<HTTPRouteRulesBackendRefsFiltersRequestRedirect>,
629 /// ResponseHeaderModifier defines a schema for a filter that modifies response
630 /// headers.
631 ///
632 /// Support: Extended
633 #[serde(
634 default,
635 skip_serializing_if = "Option::is_none",
636 rename = "responseHeaderModifier"
637 )]
638 pub response_header_modifier: Option<HTTPRouteRulesBackendRefsFiltersResponseHeaderModifier>,
639 /// Type identifies the type of filter to apply. As with other API fields,
640 /// types are classified into three conformance levels:
641 ///
642 /// - Core: Filter types and their corresponding configuration defined by
643 /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All
644 /// implementations must support core filters.
645 ///
646 /// - Extended: Filter types and their corresponding configuration defined by
647 /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers
648 /// are encouraged to support extended filters.
649 ///
650 /// - Implementation-specific: Filters that are defined and supported by
651 /// specific vendors.
652 /// In the future, filters showing convergence in behavior across multiple
653 /// implementations will be considered for inclusion in extended or core
654 /// conformance levels. Filter-specific configuration for such filters
655 /// is specified using the ExtensionRef field. `Type` should be set to
656 /// "ExtensionRef" for custom filters.
657 ///
658 /// Implementers are encouraged to define custom implementation types to
659 /// extend the core API with implementation-specific behavior.
660 ///
661 /// If a reference to a custom filter type cannot be resolved, the filter
662 /// MUST NOT be skipped. Instead, requests that would have been processed by
663 /// that filter MUST receive a HTTP error response.
664 ///
665 /// Note that values may be added to this enum, implementations
666 /// must ensure that unknown values will not cause a crash.
667 ///
668 /// Unknown values here must result in the implementation setting the
669 /// Accepted Condition for the Route to `status: False`, with a
670 /// Reason of `UnsupportedValue`.
671 #[serde(rename = "type")]
672 pub r#type: HTTPRouteRulesBackendRefsFiltersType,
673 /// URLRewrite defines a schema for a filter that modifies a request during forwarding.
674 ///
675 /// Support: Extended
676 #[serde(
677 default,
678 skip_serializing_if = "Option::is_none",
679 rename = "urlRewrite"
680 )]
681 pub url_rewrite: Option<HTTPRouteRulesBackendRefsFiltersUrlRewrite>,
682}
683
684/// CORS defines a schema for a filter that responds to the
685/// cross-origin request based on HTTP response header.
686///
687/// Support: Extended
688#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
689pub struct HTTPRouteRulesBackendRefsFiltersCors {
690 /// AllowCredentials indicates whether the actual cross-origin request allows
691 /// to include credentials.
692 ///
693 /// When set to true, the gateway will include the `Access-Control-Allow-Credentials`
694 /// response header with value true (case-sensitive).
695 ///
696 /// When set to false or omitted the gateway will omit the header
697 /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS
698 /// behavior).
699 ///
700 /// Support: Extended
701 #[serde(
702 default,
703 skip_serializing_if = "Option::is_none",
704 rename = "allowCredentials"
705 )]
706 pub allow_credentials: Option<bool>,
707 /// AllowHeaders indicates which HTTP request headers are supported for
708 /// accessing the requested resource.
709 ///
710 /// Header names are not case sensitive.
711 ///
712 /// Multiple header names in the value of the `Access-Control-Allow-Headers`
713 /// response header are separated by a comma (",").
714 ///
715 /// When the `AllowHeaders` field is configured with one or more headers, the
716 /// gateway must return the `Access-Control-Allow-Headers` response header
717 /// which value is present in the `AllowHeaders` field.
718 ///
719 /// If any header name in the `Access-Control-Request-Headers` request header
720 /// is not included in the list of header names specified by the response
721 /// header `Access-Control-Allow-Headers`, it will present an error on the
722 /// client side.
723 ///
724 /// If any header name in the `Access-Control-Allow-Headers` response header
725 /// does not recognize by the client, it will also occur an error on the
726 /// client side.
727 ///
728 /// A wildcard indicates that the requests with all HTTP headers are allowed.
729 /// The `Access-Control-Allow-Headers` response header can only use `*`
730 /// wildcard as value when the `AllowCredentials` field is false or omitted.
731 ///
732 /// When the `AllowCredentials` field is true and `AllowHeaders` field
733 /// specified with the `*` wildcard, the gateway must specify one or more
734 /// HTTP headers in the value of the `Access-Control-Allow-Headers` response
735 /// header. The value of the header `Access-Control-Allow-Headers` is same as
736 /// the `Access-Control-Request-Headers` header provided by the client. If
737 /// the header `Access-Control-Request-Headers` is not included in the
738 /// request, the gateway will omit the `Access-Control-Allow-Headers`
739 /// response header, instead of specifying the `*` wildcard. A Gateway
740 /// implementation may choose to add implementation-specific default headers.
741 ///
742 /// Support: Extended
743 #[serde(
744 default,
745 skip_serializing_if = "Option::is_none",
746 rename = "allowHeaders"
747 )]
748 pub allow_headers: Option<Vec<String>>,
749 /// AllowMethods indicates which HTTP methods are supported for accessing the
750 /// requested resource.
751 ///
752 /// Valid values are any method defined by RFC9110, along with the special
753 /// value `*`, which represents all HTTP methods are allowed.
754 ///
755 /// Method names are case sensitive, so these values are also case-sensitive.
756 /// (See https://www.rfc-editor.org/rfc/rfc2616#section-5.1.1)
757 ///
758 /// Multiple method names in the value of the `Access-Control-Allow-Methods`
759 /// response header are separated by a comma (",").
760 ///
761 /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`.
762 /// (See https://fetch.spec.whatwg.org/#cors-safelisted-method) The
763 /// CORS-safelisted methods are always allowed, regardless of whether they
764 /// are specified in the `AllowMethods` field.
765 ///
766 /// When the `AllowMethods` field is configured with one or more methods, the
767 /// gateway must return the `Access-Control-Allow-Methods` response header
768 /// which value is present in the `AllowMethods` field.
769 ///
770 /// If the HTTP method of the `Access-Control-Request-Method` request header
771 /// is not included in the list of methods specified by the response header
772 /// `Access-Control-Allow-Methods`, it will present an error on the client
773 /// side.
774 ///
775 /// The `Access-Control-Allow-Methods` response header can only use `*`
776 /// wildcard as value when the `AllowCredentials` field is false or omitted.
777 ///
778 /// When the `AllowCredentials` field is true and `AllowMethods` field
779 /// specified with the `*` wildcard, the gateway must specify one HTTP method
780 /// in the value of the Access-Control-Allow-Methods response header. The
781 /// value of the header `Access-Control-Allow-Methods` is same as the
782 /// `Access-Control-Request-Method` header provided by the client. If the
783 /// header `Access-Control-Request-Method` is not included in the request,
784 /// the gateway will omit the `Access-Control-Allow-Methods` response header,
785 /// instead of specifying the `*` wildcard. A Gateway implementation may
786 /// choose to add implementation-specific default methods.
787 ///
788 /// Support: Extended
789 #[serde(
790 default,
791 skip_serializing_if = "Option::is_none",
792 rename = "allowMethods"
793 )]
794 pub allow_methods: Option<Vec<String>>,
795 /// AllowOrigins indicates whether the response can be shared with requested
796 /// resource from the given `Origin`.
797 ///
798 /// The `Origin` consists of a scheme and a host, with an optional port, and
799 /// takes the form `<scheme>://<host>(:<port>)`.
800 ///
801 /// Valid values for scheme are: `http` and `https`.
802 ///
803 /// Valid values for port are any integer between 1 and 65535 (the list of
804 /// available TCP/UDP ports). Note that, if not included, port `80` is
805 /// assumed for `http` scheme origins, and port `443` is assumed for `https`
806 /// origins. This may affect origin matching.
807 ///
808 /// The host part of the origin may contain the wildcard character `*`. These
809 /// wildcard characters behave as follows:
810 ///
811 /// * `*` is a greedy match to the _left_, including any number of
812 /// DNS labels to the left of its position. This also means that
813 /// `*` will include any number of period `.` characters to the
814 /// left of its position.
815 /// * A wildcard by itself matches all hosts.
816 ///
817 /// An origin value that includes _only_ the `*` character indicates requests
818 /// from all `Origin`s are allowed.
819 ///
820 /// When the `AllowOrigins` field is configured with multiple origins, it
821 /// means the server supports clients from multiple origins. If the request
822 /// `Origin` matches the configured allowed origins, the gateway must return
823 /// the given `Origin` and sets value of the header
824 /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the
825 /// client.
826 ///
827 /// The status code of a successful response to a "preflight" request is
828 /// always an OK status (i.e., 204 or 200).
829 ///
830 /// If the request `Origin` does not match the configured allowed origins,
831 /// the gateway returns 204/200 response but doesn't set the relevant
832 /// cross-origin response headers. Alternatively, the gateway responds with
833 /// 403 status to the "preflight" request is denied, coupled with omitting
834 /// the CORS headers. The cross-origin request fails on the client side.
835 /// Therefore, the client doesn't attempt the actual cross-origin request.
836 ///
837 /// The `Access-Control-Allow-Origin` response header can only use `*`
838 /// wildcard as value when the `AllowCredentials` field is false or omitted.
839 ///
840 /// When the `AllowCredentials` field is true and `AllowOrigins` field
841 /// specified with the `*` wildcard, the gateway must return a single origin
842 /// in the value of the `Access-Control-Allow-Origin` response header,
843 /// instead of specifying the `*` wildcard. The value of the header
844 /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by
845 /// the client.
846 ///
847 /// Support: Extended
848 #[serde(
849 default,
850 skip_serializing_if = "Option::is_none",
851 rename = "allowOrigins"
852 )]
853 pub allow_origins: Option<Vec<String>>,
854 /// ExposeHeaders indicates which HTTP response headers can be exposed
855 /// to client-side scripts in response to a cross-origin request.
856 ///
857 /// A CORS-safelisted response header is an HTTP header in a CORS response
858 /// that it is considered safe to expose to the client scripts.
859 /// The CORS-safelisted response headers include the following headers:
860 /// `Cache-Control`
861 /// `Content-Language`
862 /// `Content-Length`
863 /// `Content-Type`
864 /// `Expires`
865 /// `Last-Modified`
866 /// `Pragma`
867 /// (See https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name)
868 /// The CORS-safelisted response headers are exposed to client by default.
869 ///
870 /// When an HTTP header name is specified using the `ExposeHeaders` field,
871 /// this additional header will be exposed as part of the response to the
872 /// client.
873 ///
874 /// Header names are not case sensitive.
875 ///
876 /// Multiple header names in the value of the `Access-Control-Expose-Headers`
877 /// response header are separated by a comma (",").
878 ///
879 /// A wildcard indicates that the responses with all HTTP headers are exposed
880 /// to clients. The `Access-Control-Expose-Headers` response header can only
881 /// use `*` wildcard as value when the `AllowCredentials` field is false or omitted.
882 ///
883 /// Support: Extended
884 #[serde(
885 default,
886 skip_serializing_if = "Option::is_none",
887 rename = "exposeHeaders"
888 )]
889 pub expose_headers: Option<Vec<String>>,
890 /// MaxAge indicates the duration (in seconds) for the client to cache the
891 /// results of a "preflight" request.
892 ///
893 /// The information provided by the `Access-Control-Allow-Methods` and
894 /// `Access-Control-Allow-Headers` response headers can be cached by the
895 /// client until the time specified by `Access-Control-Max-Age` elapses.
896 ///
897 /// The default value of `Access-Control-Max-Age` response header is 5
898 /// (seconds).
899 #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
900 pub max_age: Option<i32>,
901}
902
903/// ExtensionRef is an optional, implementation-specific extension to the
904/// "filter" behavior. For example, resource "myroutefilter" in group
905/// "networking.example.net"). ExtensionRef MUST NOT be used for core and
906/// extended filters.
907///
908/// This filter can be used multiple times within the same rule.
909///
910/// Support: Implementation-specific
911#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
912pub struct HTTPRouteRulesBackendRefsFiltersExtensionRef {
913 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
914 /// When unspecified or empty string, core API group is inferred.
915 pub group: String,
916 /// Kind is kind of the referent. For example "HTTPRoute" or "Service".
917 pub kind: String,
918 /// Name is the name of the referent.
919 pub name: String,
920}
921
922/// ExternalAuth configures settings related to sending request details
923/// to an external auth service. The external service MUST authenticate
924/// the request, and MAY authorize the request as well.
925///
926/// If there is any problem communicating with the external service,
927/// this filter MUST fail closed.
928///
929/// Support: Extended
930#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
931pub struct HTTPRouteRulesBackendRefsFiltersExternalAuth {
932 /// BackendRef is a reference to a backend to send authorization
933 /// requests to.
934 ///
935 /// The backend must speak the selected protocol (GRPC or HTTP) on the
936 /// referenced port.
937 ///
938 /// If the backend service requires TLS, use BackendTLSPolicy to tell the
939 /// implementation to supply the TLS details to be used to connect to that
940 /// backend.
941 #[serde(rename = "backendRef")]
942 pub backend_ref: HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef,
943 /// ForwardBody controls if requests to the authorization server should include
944 /// the body of the client request; and if so, how big that body is allowed
945 /// to be.
946 ///
947 /// It is expected that implementations will buffer the request body up to
948 /// `forwardBody.maxSize` bytes. Bodies over that size must be rejected with a
949 /// 4xx series error (413 or 403 are common examples), and fail processing
950 /// of the filter.
951 ///
952 /// If unset, or `forwardBody.maxSize` is set to `0`, then the body will not
953 /// be forwarded.
954 ///
955 /// Feature Name: HTTPRouteExternalAuthForwardBody
956 #[serde(
957 default,
958 skip_serializing_if = "Option::is_none",
959 rename = "forwardBody"
960 )]
961 pub forward_body: Option<HTTPRouteRulesBackendRefsFiltersExternalAuthForwardBody>,
962 /// GRPCAuthConfig contains configuration for communication with ext_authz
963 /// protocol-speaking backends.
964 ///
965 /// If unset, implementations must assume the default behavior for each
966 /// included field is intended.
967 #[serde(default, skip_serializing_if = "Option::is_none")]
968 pub grpc: Option<HTTPRouteRulesBackendRefsFiltersExternalAuthGrpc>,
969 /// HTTPAuthConfig contains configuration for communication with HTTP-speaking
970 /// backends.
971 ///
972 /// If unset, implementations must assume the default behavior for each
973 /// included field is intended.
974 #[serde(default, skip_serializing_if = "Option::is_none")]
975 pub http: Option<HTTPRouteRulesBackendRefsFiltersExternalAuthHttp>,
976 /// ExternalAuthProtocol describes which protocol to use when communicating with an
977 /// ext_authz authorization server.
978 ///
979 /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol
980 /// on the port specified in `backendRefs`. Requests and responses are defined
981 /// in the protobufs explained at:
982 /// https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/auth/v3/external_auth.proto
983 ///
984 /// When this is set to HTTP, each backend must respond with a `200` status
985 /// code in on a successful authorization. Any other code is considered
986 /// an authorization failure.
987 ///
988 /// Feature Names:
989 /// GRPC Support - HTTPRouteExternalAuthGRPC
990 /// HTTP Support - HTTPRouteExternalAuthHTTP
991 pub protocol: HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol,
992}
993
994/// BackendRef is a reference to a backend to send authorization
995/// requests to.
996///
997/// The backend must speak the selected protocol (GRPC or HTTP) on the
998/// referenced port.
999///
1000/// If the backend service requires TLS, use BackendTLSPolicy to tell the
1001/// implementation to supply the TLS details to be used to connect to that
1002/// backend.
1003#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1004pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthBackendRef {
1005 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
1006 /// When unspecified or empty string, core API group is inferred.
1007 #[serde(default, skip_serializing_if = "Option::is_none")]
1008 pub group: Option<String>,
1009 /// Kind is the Kubernetes resource kind of the referent. For example
1010 /// "Service".
1011 ///
1012 /// Defaults to "Service" when not specified.
1013 ///
1014 /// ExternalName services can refer to CNAME DNS records that may live
1015 /// outside of the cluster and as such are difficult to reason about in
1016 /// terms of conformance. They also may not be safe to forward to (see
1017 /// CVE-2021-25740 for more information). Implementations SHOULD NOT
1018 /// support ExternalName Services.
1019 ///
1020 /// Support: Core (Services with a type other than ExternalName)
1021 ///
1022 /// Support: Implementation-specific (Services with type ExternalName)
1023 #[serde(default, skip_serializing_if = "Option::is_none")]
1024 pub kind: Option<String>,
1025 /// Name is the name of the referent.
1026 pub name: String,
1027 /// Namespace is the namespace of the backend. When unspecified, the local
1028 /// namespace is inferred.
1029 ///
1030 /// Note that when a namespace different than the local namespace is specified,
1031 /// a ReferenceGrant object is required in the referent namespace to allow that
1032 /// namespace's owner to accept the reference. See the ReferenceGrant
1033 /// documentation for details.
1034 ///
1035 /// Support: Core
1036 #[serde(default, skip_serializing_if = "Option::is_none")]
1037 pub namespace: Option<String>,
1038 /// Port specifies the destination port number to use for this resource.
1039 /// Port is required when the referent is a Kubernetes Service. In this
1040 /// case, the port number is the service port number, not the target port.
1041 /// For other resources, destination port might be derived from the referent
1042 /// resource or this field.
1043 #[serde(default, skip_serializing_if = "Option::is_none")]
1044 pub port: Option<i32>,
1045}
1046
1047/// ForwardBody controls if requests to the authorization server should include
1048/// the body of the client request; and if so, how big that body is allowed
1049/// to be.
1050///
1051/// It is expected that implementations will buffer the request body up to
1052/// `forwardBody.maxSize` bytes. Bodies over that size must be rejected with a
1053/// 4xx series error (413 or 403 are common examples), and fail processing
1054/// of the filter.
1055///
1056/// If unset, or `forwardBody.maxSize` is set to `0`, then the body will not
1057/// be forwarded.
1058///
1059/// Feature Name: HTTPRouteExternalAuthForwardBody
1060#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1061pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthForwardBody {
1062 /// MaxSize specifies how large in bytes the largest body that will be buffered
1063 /// and sent to the authorization server. If the body size is larger than
1064 /// `maxSize`, then the body sent to the authorization server must be
1065 /// truncated to `maxSize` bytes.
1066 ///
1067 /// Experimental note: This behavior needs to be checked against
1068 /// various dataplanes; it may need to be changed.
1069 /// See https://github.com/kubernetes-sigs/gateway-api/pull/4001#discussion_r2291405746
1070 /// for more.
1071 ///
1072 /// If 0, the body will not be sent to the authorization server.
1073 #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSize")]
1074 pub max_size: Option<i64>,
1075}
1076
1077/// GRPCAuthConfig contains configuration for communication with ext_authz
1078/// protocol-speaking backends.
1079///
1080/// If unset, implementations must assume the default behavior for each
1081/// included field is intended.
1082#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1083pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthGrpc {
1084 /// AllowedRequestHeaders specifies what headers from the client request
1085 /// will be sent to the authorization server.
1086 ///
1087 /// If this list is empty, then all headers must be sent.
1088 ///
1089 /// If the list has entries, only those entries must be sent.
1090 #[serde(
1091 default,
1092 skip_serializing_if = "Option::is_none",
1093 rename = "allowedHeaders"
1094 )]
1095 pub allowed_headers: Option<Vec<String>>,
1096}
1097
1098/// HTTPAuthConfig contains configuration for communication with HTTP-speaking
1099/// backends.
1100///
1101/// If unset, implementations must assume the default behavior for each
1102/// included field is intended.
1103#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1104pub struct HTTPRouteRulesBackendRefsFiltersExternalAuthHttp {
1105 /// AllowedRequestHeaders specifies what additional headers from the client request
1106 /// will be sent to the authorization server.
1107 ///
1108 /// The following headers must always be sent to the authorization server,
1109 /// regardless of this setting:
1110 ///
1111 /// * `Host`
1112 /// * `Method`
1113 /// * `Path`
1114 /// * `Content-Length`
1115 /// * `Authorization`
1116 ///
1117 /// If this list is empty, then only those headers must be sent.
1118 ///
1119 /// Note that `Content-Length` has a special behavior, in that the length
1120 /// sent must be correct for the actual request to the external authorization
1121 /// server - that is, it must reflect the actual number of bytes sent in the
1122 /// body of the request to the authorization server.
1123 ///
1124 /// So if the `forwardBody` stanza is unset, or `forwardBody.maxSize` is set
1125 /// to `0`, then `Content-Length` must be `0`. If `forwardBody.maxSize` is set
1126 /// to anything other than `0`, then the `Content-Length` of the authorization
1127 /// request must be set to the actual number of bytes forwarded.
1128 #[serde(
1129 default,
1130 skip_serializing_if = "Option::is_none",
1131 rename = "allowedHeaders"
1132 )]
1133 pub allowed_headers: Option<Vec<String>>,
1134 /// AllowedResponseHeaders specifies what headers from the authorization response
1135 /// will be copied into the request to the backend.
1136 ///
1137 /// If this list is empty, then all headers from the authorization server
1138 /// except Authority or Host must be copied.
1139 #[serde(
1140 default,
1141 skip_serializing_if = "Option::is_none",
1142 rename = "allowedResponseHeaders"
1143 )]
1144 pub allowed_response_headers: Option<Vec<String>>,
1145 /// Path sets the prefix that paths from the client request will have added
1146 /// when forwarded to the authorization server.
1147 ///
1148 /// When empty or unspecified, no prefix is added.
1149 ///
1150 /// Valid values are the same as the "value" regex for path values in the `match`
1151 /// stanza, and the validation regex will screen out invalid paths in the same way.
1152 /// Even with the validation, implementations MUST sanitize this input before using it
1153 /// directly.
1154 #[serde(default, skip_serializing_if = "Option::is_none")]
1155 pub path: Option<String>,
1156}
1157
1158/// ExternalAuth configures settings related to sending request details
1159/// to an external auth service. The external service MUST authenticate
1160/// the request, and MAY authorize the request as well.
1161///
1162/// If there is any problem communicating with the external service,
1163/// this filter MUST fail closed.
1164///
1165/// Support: Extended
1166#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1167pub enum HTTPRouteRulesBackendRefsFiltersExternalAuthProtocol {
1168 #[serde(rename = "HTTP")]
1169 Http,
1170 #[serde(rename = "GRPC")]
1171 Grpc,
1172}
1173
1174/// RequestHeaderModifier defines a schema for a filter that modifies request
1175/// headers.
1176///
1177/// Support: Core
1178#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1179pub struct HTTPRouteRulesBackendRefsFiltersRequestHeaderModifier {
1180 /// Add adds the given header(s) (name, value) to the request
1181 /// before the action. It appends to any existing values associated
1182 /// with the header name.
1183 ///
1184 /// Input:
1185 /// GET /foo HTTP/1.1
1186 /// my-header: foo
1187 ///
1188 /// Config:
1189 /// add:
1190 /// - name: "my-header"
1191 /// value: "bar,baz"
1192 ///
1193 /// Output:
1194 /// GET /foo HTTP/1.1
1195 /// my-header: foo,bar,baz
1196 #[serde(default, skip_serializing_if = "Option::is_none")]
1197 pub add: Option<Vec<HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierAdd>>,
1198 /// Remove the given header(s) from the HTTP request before the action. The
1199 /// value of Remove is a list of HTTP header names. Note that the header
1200 /// names are case-insensitive (see
1201 /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).
1202 ///
1203 /// Input:
1204 /// GET /foo HTTP/1.1
1205 /// my-header1: foo
1206 /// my-header2: bar
1207 /// my-header3: baz
1208 ///
1209 /// Config:
1210 /// remove: ["my-header1", "my-header3"]
1211 ///
1212 /// Output:
1213 /// GET /foo HTTP/1.1
1214 /// my-header2: bar
1215 #[serde(default, skip_serializing_if = "Option::is_none")]
1216 pub remove: Option<Vec<String>>,
1217 /// Set overwrites the request with the given header (name, value)
1218 /// before the action.
1219 ///
1220 /// Input:
1221 /// GET /foo HTTP/1.1
1222 /// my-header: foo
1223 ///
1224 /// Config:
1225 /// set:
1226 /// - name: "my-header"
1227 /// value: "bar"
1228 ///
1229 /// Output:
1230 /// GET /foo HTTP/1.1
1231 /// my-header: bar
1232 #[serde(default, skip_serializing_if = "Option::is_none")]
1233 pub set: Option<Vec<HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierSet>>,
1234}
1235
1236/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
1237#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1238pub struct HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierAdd {
1239 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
1240 /// case-insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2).
1241 ///
1242 /// If multiple entries specify equivalent header names, the first entry with
1243 /// an equivalent name MUST be considered for a match. Subsequent entries
1244 /// with an equivalent header name MUST be ignored. Due to the
1245 /// case-insensitivity of header names, "foo" and "Foo" are considered
1246 /// equivalent.
1247 pub name: String,
1248 /// Value is the value of HTTP Header to be matched.
1249 pub value: String,
1250}
1251
1252/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
1253#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1254pub struct HTTPRouteRulesBackendRefsFiltersRequestHeaderModifierSet {
1255 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
1256 /// case-insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2).
1257 ///
1258 /// If multiple entries specify equivalent header names, the first entry with
1259 /// an equivalent name MUST be considered for a match. Subsequent entries
1260 /// with an equivalent header name MUST be ignored. Due to the
1261 /// case-insensitivity of header names, "foo" and "Foo" are considered
1262 /// equivalent.
1263 pub name: String,
1264 /// Value is the value of HTTP Header to be matched.
1265 pub value: String,
1266}
1267
1268/// RequestMirror defines a schema for a filter that mirrors requests.
1269/// Requests are sent to the specified destination, but responses from
1270/// that destination are ignored.
1271///
1272/// This filter can be used multiple times within the same rule. Note that
1273/// not all implementations will be able to support mirroring to multiple
1274/// backends.
1275///
1276/// Support: Extended
1277#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1278pub struct HTTPRouteRulesBackendRefsFiltersRequestMirror {
1279 /// BackendRef references a resource where mirrored requests are sent.
1280 ///
1281 /// Mirrored requests must be sent only to a single destination endpoint
1282 /// within this BackendRef, irrespective of how many endpoints are present
1283 /// within this BackendRef.
1284 ///
1285 /// If the referent cannot be found, this BackendRef is invalid and must be
1286 /// dropped from the Gateway. The controller must ensure the "ResolvedRefs"
1287 /// condition on the Route status is set to `status: False` and not configure
1288 /// this backend in the underlying implementation.
1289 ///
1290 /// If there is a cross-namespace reference to an *existing* object
1291 /// that is not allowed by a ReferenceGrant, the controller must ensure the
1292 /// "ResolvedRefs" condition on the Route is set to `status: False`,
1293 /// with the "RefNotPermitted" reason and not configure this backend in the
1294 /// underlying implementation.
1295 ///
1296 /// In either error case, the Message of the `ResolvedRefs` Condition
1297 /// should be used to provide more detail about the problem.
1298 ///
1299 /// Support: Extended for Kubernetes Service
1300 ///
1301 /// Support: Implementation-specific for any other resource
1302 #[serde(rename = "backendRef")]
1303 pub backend_ref: HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef,
1304 /// Fraction represents the fraction of requests that should be
1305 /// mirrored to BackendRef.
1306 ///
1307 /// Only one of Fraction or Percent may be specified. If neither field
1308 /// is specified, 100% of requests will be mirrored.
1309 #[serde(default, skip_serializing_if = "Option::is_none")]
1310 pub fraction: Option<HTTPRouteRulesBackendRefsFiltersRequestMirrorFraction>,
1311 /// Percent represents the percentage of requests that should be
1312 /// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of
1313 /// requests) and its maximum value is 100 (indicating 100% of requests).
1314 ///
1315 /// Only one of Fraction or Percent may be specified. If neither field
1316 /// is specified, 100% of requests will be mirrored.
1317 #[serde(default, skip_serializing_if = "Option::is_none")]
1318 pub percent: Option<i32>,
1319}
1320
1321/// BackendRef references a resource where mirrored requests are sent.
1322///
1323/// Mirrored requests must be sent only to a single destination endpoint
1324/// within this BackendRef, irrespective of how many endpoints are present
1325/// within this BackendRef.
1326///
1327/// If the referent cannot be found, this BackendRef is invalid and must be
1328/// dropped from the Gateway. The controller must ensure the "ResolvedRefs"
1329/// condition on the Route status is set to `status: False` and not configure
1330/// this backend in the underlying implementation.
1331///
1332/// If there is a cross-namespace reference to an *existing* object
1333/// that is not allowed by a ReferenceGrant, the controller must ensure the
1334/// "ResolvedRefs" condition on the Route is set to `status: False`,
1335/// with the "RefNotPermitted" reason and not configure this backend in the
1336/// underlying implementation.
1337///
1338/// In either error case, the Message of the `ResolvedRefs` Condition
1339/// should be used to provide more detail about the problem.
1340///
1341/// Support: Extended for Kubernetes Service
1342///
1343/// Support: Implementation-specific for any other resource
1344#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1345pub struct HTTPRouteRulesBackendRefsFiltersRequestMirrorBackendRef {
1346 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
1347 /// When unspecified or empty string, core API group is inferred.
1348 #[serde(default, skip_serializing_if = "Option::is_none")]
1349 pub group: Option<String>,
1350 /// Kind is the Kubernetes resource kind of the referent. For example
1351 /// "Service".
1352 ///
1353 /// Defaults to "Service" when not specified.
1354 ///
1355 /// ExternalName services can refer to CNAME DNS records that may live
1356 /// outside of the cluster and as such are difficult to reason about in
1357 /// terms of conformance. They also may not be safe to forward to (see
1358 /// CVE-2021-25740 for more information). Implementations SHOULD NOT
1359 /// support ExternalName Services.
1360 ///
1361 /// Support: Core (Services with a type other than ExternalName)
1362 ///
1363 /// Support: Implementation-specific (Services with type ExternalName)
1364 #[serde(default, skip_serializing_if = "Option::is_none")]
1365 pub kind: Option<String>,
1366 /// Name is the name of the referent.
1367 pub name: String,
1368 /// Namespace is the namespace of the backend. When unspecified, the local
1369 /// namespace is inferred.
1370 ///
1371 /// Note that when a namespace different than the local namespace is specified,
1372 /// a ReferenceGrant object is required in the referent namespace to allow that
1373 /// namespace's owner to accept the reference. See the ReferenceGrant
1374 /// documentation for details.
1375 ///
1376 /// Support: Core
1377 #[serde(default, skip_serializing_if = "Option::is_none")]
1378 pub namespace: Option<String>,
1379 /// Port specifies the destination port number to use for this resource.
1380 /// Port is required when the referent is a Kubernetes Service. In this
1381 /// case, the port number is the service port number, not the target port.
1382 /// For other resources, destination port might be derived from the referent
1383 /// resource or this field.
1384 #[serde(default, skip_serializing_if = "Option::is_none")]
1385 pub port: Option<i32>,
1386}
1387
1388/// Fraction represents the fraction of requests that should be
1389/// mirrored to BackendRef.
1390///
1391/// Only one of Fraction or Percent may be specified. If neither field
1392/// is specified, 100% of requests will be mirrored.
1393#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1394pub struct HTTPRouteRulesBackendRefsFiltersRequestMirrorFraction {
1395 #[serde(default, skip_serializing_if = "Option::is_none")]
1396 pub denominator: Option<i32>,
1397 pub numerator: i32,
1398}
1399
1400/// RequestRedirect defines a schema for a filter that responds to the
1401/// request with an HTTP redirection.
1402///
1403/// Support: Core
1404#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1405pub struct HTTPRouteRulesBackendRefsFiltersRequestRedirect {
1406 /// Hostname is the hostname to be used in the value of the `Location`
1407 /// header in the response.
1408 /// When empty, the hostname in the `Host` header of the request is used.
1409 ///
1410 /// Support: Core
1411 #[serde(default, skip_serializing_if = "Option::is_none")]
1412 pub hostname: Option<String>,
1413 /// Path defines parameters used to modify the path of the incoming request.
1414 /// The modified path is then used to construct the `Location` header. When
1415 /// empty, the request path is used as-is.
1416 ///
1417 /// Support: Extended
1418 #[serde(default, skip_serializing_if = "Option::is_none")]
1419 pub path: Option<HTTPRouteRulesBackendRefsFiltersRequestRedirectPath>,
1420 /// Port is the port to be used in the value of the `Location`
1421 /// header in the response.
1422 ///
1423 /// If no port is specified, the redirect port MUST be derived using the
1424 /// following rules:
1425 ///
1426 /// * If redirect scheme is not-empty, the redirect port MUST be the well-known
1427 /// port associated with the redirect scheme. Specifically "http" to port 80
1428 /// and "https" to port 443. If the redirect scheme does not have a
1429 /// well-known port, the listener port of the Gateway SHOULD be used.
1430 /// * If redirect scheme is empty, the redirect port MUST be the Gateway
1431 /// Listener port.
1432 ///
1433 /// Implementations SHOULD NOT add the port number in the 'Location'
1434 /// header in the following cases:
1435 ///
1436 /// * A Location header that will use HTTP (whether that is determined via
1437 /// the Listener protocol or the Scheme field) _and_ use port 80.
1438 /// * A Location header that will use HTTPS (whether that is determined via
1439 /// the Listener protocol or the Scheme field) _and_ use port 443.
1440 ///
1441 /// Support: Extended
1442 #[serde(default, skip_serializing_if = "Option::is_none")]
1443 pub port: Option<i32>,
1444 /// Scheme is the scheme to be used in the value of the `Location` header in
1445 /// the response. When empty, the scheme of the request is used.
1446 ///
1447 /// Scheme redirects can affect the port of the redirect, for more information,
1448 /// refer to the documentation for the port field of this filter.
1449 ///
1450 /// Note that values may be added to this enum, implementations
1451 /// must ensure that unknown values will not cause a crash.
1452 ///
1453 /// Unknown values here must result in the implementation setting the
1454 /// Accepted Condition for the Route to `status: False`, with a
1455 /// Reason of `UnsupportedValue`.
1456 ///
1457 /// Support: Extended
1458 #[serde(default, skip_serializing_if = "Option::is_none")]
1459 pub scheme: Option<HTTPRouteRulesBackendRefsFiltersRequestRedirectScheme>,
1460 /// StatusCode is the HTTP status code to be used in response.
1461 ///
1462 /// Note that values may be added to this enum, implementations
1463 /// must ensure that unknown values will not cause a crash.
1464 ///
1465 /// Unknown values here must result in the implementation setting the
1466 /// Accepted Condition for the Route to `status: False`, with a
1467 /// Reason of `UnsupportedValue`.
1468 ///
1469 /// Support: Core
1470 #[serde(
1471 default,
1472 skip_serializing_if = "Option::is_none",
1473 rename = "statusCode"
1474 )]
1475 pub status_code: Option<i64>,
1476}
1477
1478/// Path defines parameters used to modify the path of the incoming request.
1479/// The modified path is then used to construct the `Location` header. When
1480/// empty, the request path is used as-is.
1481///
1482/// Support: Extended
1483#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1484pub struct HTTPRouteRulesBackendRefsFiltersRequestRedirectPath {
1485 /// ReplaceFullPath specifies the value with which to replace the full path
1486 /// of a request during a rewrite or redirect.
1487 #[serde(
1488 default,
1489 skip_serializing_if = "Option::is_none",
1490 rename = "replaceFullPath"
1491 )]
1492 pub replace_full_path: Option<String>,
1493 /// ReplacePrefixMatch specifies the value with which to replace the prefix
1494 /// match of a request during a rewrite or redirect. For example, a request
1495 /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch
1496 /// of "/xyz" would be modified to "/xyz/bar".
1497 ///
1498 /// Note that this matches the behavior of the PathPrefix match type. This
1499 /// matches full path elements. A path element refers to the list of labels
1500 /// in the path split by the `/` separator. When specified, a trailing `/` is
1501 /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all
1502 /// match the prefix `/abc`, but the path `/abcd` would not.
1503 ///
1504 /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch.
1505 /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in
1506 /// the implementation setting the Accepted Condition for the Route to `status: False`.
1507 ///
1508 /// Request Path | Prefix Match | Replace Prefix | Modified Path
1509 #[serde(
1510 default,
1511 skip_serializing_if = "Option::is_none",
1512 rename = "replacePrefixMatch"
1513 )]
1514 pub replace_prefix_match: Option<String>,
1515 /// Type defines the type of path modifier. Additional types may be
1516 /// added in a future release of the API.
1517 ///
1518 /// Note that values may be added to this enum, implementations
1519 /// must ensure that unknown values will not cause a crash.
1520 ///
1521 /// Unknown values here must result in the implementation setting the
1522 /// Accepted Condition for the Route to `status: False`, with a
1523 /// Reason of `UnsupportedValue`.
1524 #[serde(rename = "type")]
1525 pub r#type: HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType,
1526}
1527
1528/// Path defines parameters used to modify the path of the incoming request.
1529/// The modified path is then used to construct the `Location` header. When
1530/// empty, the request path is used as-is.
1531///
1532/// Support: Extended
1533#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1534pub enum HTTPRouteRulesBackendRefsFiltersRequestRedirectPathType {
1535 ReplaceFullPath,
1536 ReplacePrefixMatch,
1537}
1538
1539/// RequestRedirect defines a schema for a filter that responds to the
1540/// request with an HTTP redirection.
1541///
1542/// Support: Core
1543#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1544pub enum HTTPRouteRulesBackendRefsFiltersRequestRedirectScheme {
1545 #[serde(rename = "http")]
1546 Http,
1547 #[serde(rename = "https")]
1548 Https,
1549}
1550
1551/// RequestRedirect defines a schema for a filter that responds to the
1552/// request with an HTTP redirection.
1553///
1554/// Support: Core
1555#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1556pub enum HTTPRouteRulesBackendRefsFiltersRequestRedirectStatusCode {
1557 #[serde(rename = "301")]
1558 r#_301,
1559 #[serde(rename = "302")]
1560 r#_302,
1561}
1562
1563/// ResponseHeaderModifier defines a schema for a filter that modifies response
1564/// headers.
1565///
1566/// Support: Extended
1567#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1568pub struct HTTPRouteRulesBackendRefsFiltersResponseHeaderModifier {
1569 /// Add adds the given header(s) (name, value) to the request
1570 /// before the action. It appends to any existing values associated
1571 /// with the header name.
1572 ///
1573 /// Input:
1574 /// GET /foo HTTP/1.1
1575 /// my-header: foo
1576 ///
1577 /// Config:
1578 /// add:
1579 /// - name: "my-header"
1580 /// value: "bar,baz"
1581 ///
1582 /// Output:
1583 /// GET /foo HTTP/1.1
1584 /// my-header: foo,bar,baz
1585 #[serde(default, skip_serializing_if = "Option::is_none")]
1586 pub add: Option<Vec<HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierAdd>>,
1587 /// Remove the given header(s) from the HTTP request before the action. The
1588 /// value of Remove is a list of HTTP header names. Note that the header
1589 /// names are case-insensitive (see
1590 /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).
1591 ///
1592 /// Input:
1593 /// GET /foo HTTP/1.1
1594 /// my-header1: foo
1595 /// my-header2: bar
1596 /// my-header3: baz
1597 ///
1598 /// Config:
1599 /// remove: ["my-header1", "my-header3"]
1600 ///
1601 /// Output:
1602 /// GET /foo HTTP/1.1
1603 /// my-header2: bar
1604 #[serde(default, skip_serializing_if = "Option::is_none")]
1605 pub remove: Option<Vec<String>>,
1606 /// Set overwrites the request with the given header (name, value)
1607 /// before the action.
1608 ///
1609 /// Input:
1610 /// GET /foo HTTP/1.1
1611 /// my-header: foo
1612 ///
1613 /// Config:
1614 /// set:
1615 /// - name: "my-header"
1616 /// value: "bar"
1617 ///
1618 /// Output:
1619 /// GET /foo HTTP/1.1
1620 /// my-header: bar
1621 #[serde(default, skip_serializing_if = "Option::is_none")]
1622 pub set: Option<Vec<HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierSet>>,
1623}
1624
1625/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
1626#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1627pub struct HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierAdd {
1628 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
1629 /// case-insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2).
1630 ///
1631 /// If multiple entries specify equivalent header names, the first entry with
1632 /// an equivalent name MUST be considered for a match. Subsequent entries
1633 /// with an equivalent header name MUST be ignored. Due to the
1634 /// case-insensitivity of header names, "foo" and "Foo" are considered
1635 /// equivalent.
1636 pub name: String,
1637 /// Value is the value of HTTP Header to be matched.
1638 pub value: String,
1639}
1640
1641/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
1642#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1643pub struct HTTPRouteRulesBackendRefsFiltersResponseHeaderModifierSet {
1644 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
1645 /// case-insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2).
1646 ///
1647 /// If multiple entries specify equivalent header names, the first entry with
1648 /// an equivalent name MUST be considered for a match. Subsequent entries
1649 /// with an equivalent header name MUST be ignored. Due to the
1650 /// case-insensitivity of header names, "foo" and "Foo" are considered
1651 /// equivalent.
1652 pub name: String,
1653 /// Value is the value of HTTP Header to be matched.
1654 pub value: String,
1655}
1656
1657/// HTTPRouteFilter defines processing steps that must be completed during the
1658/// request or response lifecycle. HTTPRouteFilters are meant as an extension
1659/// point to express processing that may be done in Gateway implementations. Some
1660/// examples include request or response modification, implementing
1661/// authentication strategies, rate-limiting, and traffic shaping. API
1662/// guarantee/conformance is defined based on the type of the filter.
1663#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1664pub enum HTTPRouteRulesBackendRefsFiltersType {
1665 RequestHeaderModifier,
1666 ResponseHeaderModifier,
1667 RequestMirror,
1668 RequestRedirect,
1669 #[serde(rename = "URLRewrite")]
1670 UrlRewrite,
1671 ExtensionRef,
1672 #[serde(rename = "CORS")]
1673 Cors,
1674 ExternalAuth,
1675}
1676
1677/// URLRewrite defines a schema for a filter that modifies a request during forwarding.
1678///
1679/// Support: Extended
1680#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1681pub struct HTTPRouteRulesBackendRefsFiltersUrlRewrite {
1682 /// Hostname is the value to be used to replace the Host header value during
1683 /// forwarding.
1684 ///
1685 /// Support: Extended
1686 #[serde(default, skip_serializing_if = "Option::is_none")]
1687 pub hostname: Option<String>,
1688 /// Path defines a path rewrite.
1689 ///
1690 /// Support: Extended
1691 #[serde(default, skip_serializing_if = "Option::is_none")]
1692 pub path: Option<HTTPRouteRulesBackendRefsFiltersUrlRewritePath>,
1693}
1694
1695/// Path defines a path rewrite.
1696///
1697/// Support: Extended
1698#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1699pub struct HTTPRouteRulesBackendRefsFiltersUrlRewritePath {
1700 /// ReplaceFullPath specifies the value with which to replace the full path
1701 /// of a request during a rewrite or redirect.
1702 #[serde(
1703 default,
1704 skip_serializing_if = "Option::is_none",
1705 rename = "replaceFullPath"
1706 )]
1707 pub replace_full_path: Option<String>,
1708 /// ReplacePrefixMatch specifies the value with which to replace the prefix
1709 /// match of a request during a rewrite or redirect. For example, a request
1710 /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch
1711 /// of "/xyz" would be modified to "/xyz/bar".
1712 ///
1713 /// Note that this matches the behavior of the PathPrefix match type. This
1714 /// matches full path elements. A path element refers to the list of labels
1715 /// in the path split by the `/` separator. When specified, a trailing `/` is
1716 /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all
1717 /// match the prefix `/abc`, but the path `/abcd` would not.
1718 ///
1719 /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch.
1720 /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in
1721 /// the implementation setting the Accepted Condition for the Route to `status: False`.
1722 ///
1723 /// Request Path | Prefix Match | Replace Prefix | Modified Path
1724 #[serde(
1725 default,
1726 skip_serializing_if = "Option::is_none",
1727 rename = "replacePrefixMatch"
1728 )]
1729 pub replace_prefix_match: Option<String>,
1730 /// Type defines the type of path modifier. Additional types may be
1731 /// added in a future release of the API.
1732 ///
1733 /// Note that values may be added to this enum, implementations
1734 /// must ensure that unknown values will not cause a crash.
1735 ///
1736 /// Unknown values here must result in the implementation setting the
1737 /// Accepted Condition for the Route to `status: False`, with a
1738 /// Reason of `UnsupportedValue`.
1739 #[serde(rename = "type")]
1740 pub r#type: HTTPRouteRulesBackendRefsFiltersUrlRewritePathType,
1741}
1742
1743/// Path defines a path rewrite.
1744///
1745/// Support: Extended
1746#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1747pub enum HTTPRouteRulesBackendRefsFiltersUrlRewritePathType {
1748 ReplaceFullPath,
1749 ReplacePrefixMatch,
1750}
1751
1752/// HTTPRouteFilter defines processing steps that must be completed during the
1753/// request or response lifecycle. HTTPRouteFilters are meant as an extension
1754/// point to express processing that may be done in Gateway implementations. Some
1755/// examples include request or response modification, implementing
1756/// authentication strategies, rate-limiting, and traffic shaping. API
1757/// guarantee/conformance is defined based on the type of the filter.
1758#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1759pub struct HTTPRouteRulesFilters {
1760 /// CORS defines a schema for a filter that responds to the
1761 /// cross-origin request based on HTTP response header.
1762 ///
1763 /// Support: Extended
1764 #[serde(default, skip_serializing_if = "Option::is_none")]
1765 pub cors: Option<HTTPRouteRulesFiltersCors>,
1766 /// ExtensionRef is an optional, implementation-specific extension to the
1767 /// "filter" behavior. For example, resource "myroutefilter" in group
1768 /// "networking.example.net"). ExtensionRef MUST NOT be used for core and
1769 /// extended filters.
1770 ///
1771 /// This filter can be used multiple times within the same rule.
1772 ///
1773 /// Support: Implementation-specific
1774 #[serde(
1775 default,
1776 skip_serializing_if = "Option::is_none",
1777 rename = "extensionRef"
1778 )]
1779 pub extension_ref: Option<HTTPRouteRulesFiltersExtensionRef>,
1780 /// ExternalAuth configures settings related to sending request details
1781 /// to an external auth service. The external service MUST authenticate
1782 /// the request, and MAY authorize the request as well.
1783 ///
1784 /// If there is any problem communicating with the external service,
1785 /// this filter MUST fail closed.
1786 ///
1787 /// Support: Extended
1788 #[serde(
1789 default,
1790 skip_serializing_if = "Option::is_none",
1791 rename = "externalAuth"
1792 )]
1793 pub external_auth: Option<HTTPRouteRulesFiltersExternalAuth>,
1794 /// RequestHeaderModifier defines a schema for a filter that modifies request
1795 /// headers.
1796 ///
1797 /// Support: Core
1798 #[serde(
1799 default,
1800 skip_serializing_if = "Option::is_none",
1801 rename = "requestHeaderModifier"
1802 )]
1803 pub request_header_modifier: Option<HTTPRouteRulesFiltersRequestHeaderModifier>,
1804 /// RequestMirror defines a schema for a filter that mirrors requests.
1805 /// Requests are sent to the specified destination, but responses from
1806 /// that destination are ignored.
1807 ///
1808 /// This filter can be used multiple times within the same rule. Note that
1809 /// not all implementations will be able to support mirroring to multiple
1810 /// backends.
1811 ///
1812 /// Support: Extended
1813 #[serde(
1814 default,
1815 skip_serializing_if = "Option::is_none",
1816 rename = "requestMirror"
1817 )]
1818 pub request_mirror: Option<HTTPRouteRulesFiltersRequestMirror>,
1819 /// RequestRedirect defines a schema for a filter that responds to the
1820 /// request with an HTTP redirection.
1821 ///
1822 /// Support: Core
1823 #[serde(
1824 default,
1825 skip_serializing_if = "Option::is_none",
1826 rename = "requestRedirect"
1827 )]
1828 pub request_redirect: Option<HTTPRouteRulesFiltersRequestRedirect>,
1829 /// ResponseHeaderModifier defines a schema for a filter that modifies response
1830 /// headers.
1831 ///
1832 /// Support: Extended
1833 #[serde(
1834 default,
1835 skip_serializing_if = "Option::is_none",
1836 rename = "responseHeaderModifier"
1837 )]
1838 pub response_header_modifier: Option<HTTPRouteRulesFiltersResponseHeaderModifier>,
1839 /// Type identifies the type of filter to apply. As with other API fields,
1840 /// types are classified into three conformance levels:
1841 ///
1842 /// - Core: Filter types and their corresponding configuration defined by
1843 /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All
1844 /// implementations must support core filters.
1845 ///
1846 /// - Extended: Filter types and their corresponding configuration defined by
1847 /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers
1848 /// are encouraged to support extended filters.
1849 ///
1850 /// - Implementation-specific: Filters that are defined and supported by
1851 /// specific vendors.
1852 /// In the future, filters showing convergence in behavior across multiple
1853 /// implementations will be considered for inclusion in extended or core
1854 /// conformance levels. Filter-specific configuration for such filters
1855 /// is specified using the ExtensionRef field. `Type` should be set to
1856 /// "ExtensionRef" for custom filters.
1857 ///
1858 /// Implementers are encouraged to define custom implementation types to
1859 /// extend the core API with implementation-specific behavior.
1860 ///
1861 /// If a reference to a custom filter type cannot be resolved, the filter
1862 /// MUST NOT be skipped. Instead, requests that would have been processed by
1863 /// that filter MUST receive a HTTP error response.
1864 ///
1865 /// Note that values may be added to this enum, implementations
1866 /// must ensure that unknown values will not cause a crash.
1867 ///
1868 /// Unknown values here must result in the implementation setting the
1869 /// Accepted Condition for the Route to `status: False`, with a
1870 /// Reason of `UnsupportedValue`.
1871 #[serde(rename = "type")]
1872 pub r#type: HTTPRouteRulesFiltersType,
1873 /// URLRewrite defines a schema for a filter that modifies a request during forwarding.
1874 ///
1875 /// Support: Extended
1876 #[serde(
1877 default,
1878 skip_serializing_if = "Option::is_none",
1879 rename = "urlRewrite"
1880 )]
1881 pub url_rewrite: Option<HTTPRouteRulesFiltersUrlRewrite>,
1882}
1883
1884/// CORS defines a schema for a filter that responds to the
1885/// cross-origin request based on HTTP response header.
1886///
1887/// Support: Extended
1888#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1889pub struct HTTPRouteRulesFiltersCors {
1890 /// AllowCredentials indicates whether the actual cross-origin request allows
1891 /// to include credentials.
1892 ///
1893 /// When set to true, the gateway will include the `Access-Control-Allow-Credentials`
1894 /// response header with value true (case-sensitive).
1895 ///
1896 /// When set to false or omitted the gateway will omit the header
1897 /// `Access-Control-Allow-Credentials` entirely (this is the standard CORS
1898 /// behavior).
1899 ///
1900 /// Support: Extended
1901 #[serde(
1902 default,
1903 skip_serializing_if = "Option::is_none",
1904 rename = "allowCredentials"
1905 )]
1906 pub allow_credentials: Option<bool>,
1907 /// AllowHeaders indicates which HTTP request headers are supported for
1908 /// accessing the requested resource.
1909 ///
1910 /// Header names are not case sensitive.
1911 ///
1912 /// Multiple header names in the value of the `Access-Control-Allow-Headers`
1913 /// response header are separated by a comma (",").
1914 ///
1915 /// When the `AllowHeaders` field is configured with one or more headers, the
1916 /// gateway must return the `Access-Control-Allow-Headers` response header
1917 /// which value is present in the `AllowHeaders` field.
1918 ///
1919 /// If any header name in the `Access-Control-Request-Headers` request header
1920 /// is not included in the list of header names specified by the response
1921 /// header `Access-Control-Allow-Headers`, it will present an error on the
1922 /// client side.
1923 ///
1924 /// If any header name in the `Access-Control-Allow-Headers` response header
1925 /// does not recognize by the client, it will also occur an error on the
1926 /// client side.
1927 ///
1928 /// A wildcard indicates that the requests with all HTTP headers are allowed.
1929 /// The `Access-Control-Allow-Headers` response header can only use `*`
1930 /// wildcard as value when the `AllowCredentials` field is false or omitted.
1931 ///
1932 /// When the `AllowCredentials` field is true and `AllowHeaders` field
1933 /// specified with the `*` wildcard, the gateway must specify one or more
1934 /// HTTP headers in the value of the `Access-Control-Allow-Headers` response
1935 /// header. The value of the header `Access-Control-Allow-Headers` is same as
1936 /// the `Access-Control-Request-Headers` header provided by the client. If
1937 /// the header `Access-Control-Request-Headers` is not included in the
1938 /// request, the gateway will omit the `Access-Control-Allow-Headers`
1939 /// response header, instead of specifying the `*` wildcard. A Gateway
1940 /// implementation may choose to add implementation-specific default headers.
1941 ///
1942 /// Support: Extended
1943 #[serde(
1944 default,
1945 skip_serializing_if = "Option::is_none",
1946 rename = "allowHeaders"
1947 )]
1948 pub allow_headers: Option<Vec<String>>,
1949 /// AllowMethods indicates which HTTP methods are supported for accessing the
1950 /// requested resource.
1951 ///
1952 /// Valid values are any method defined by RFC9110, along with the special
1953 /// value `*`, which represents all HTTP methods are allowed.
1954 ///
1955 /// Method names are case sensitive, so these values are also case-sensitive.
1956 /// (See https://www.rfc-editor.org/rfc/rfc2616#section-5.1.1)
1957 ///
1958 /// Multiple method names in the value of the `Access-Control-Allow-Methods`
1959 /// response header are separated by a comma (",").
1960 ///
1961 /// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`.
1962 /// (See https://fetch.spec.whatwg.org/#cors-safelisted-method) The
1963 /// CORS-safelisted methods are always allowed, regardless of whether they
1964 /// are specified in the `AllowMethods` field.
1965 ///
1966 /// When the `AllowMethods` field is configured with one or more methods, the
1967 /// gateway must return the `Access-Control-Allow-Methods` response header
1968 /// which value is present in the `AllowMethods` field.
1969 ///
1970 /// If the HTTP method of the `Access-Control-Request-Method` request header
1971 /// is not included in the list of methods specified by the response header
1972 /// `Access-Control-Allow-Methods`, it will present an error on the client
1973 /// side.
1974 ///
1975 /// The `Access-Control-Allow-Methods` response header can only use `*`
1976 /// wildcard as value when the `AllowCredentials` field is false or omitted.
1977 ///
1978 /// When the `AllowCredentials` field is true and `AllowMethods` field
1979 /// specified with the `*` wildcard, the gateway must specify one HTTP method
1980 /// in the value of the Access-Control-Allow-Methods response header. The
1981 /// value of the header `Access-Control-Allow-Methods` is same as the
1982 /// `Access-Control-Request-Method` header provided by the client. If the
1983 /// header `Access-Control-Request-Method` is not included in the request,
1984 /// the gateway will omit the `Access-Control-Allow-Methods` response header,
1985 /// instead of specifying the `*` wildcard. A Gateway implementation may
1986 /// choose to add implementation-specific default methods.
1987 ///
1988 /// Support: Extended
1989 #[serde(
1990 default,
1991 skip_serializing_if = "Option::is_none",
1992 rename = "allowMethods"
1993 )]
1994 pub allow_methods: Option<Vec<String>>,
1995 /// AllowOrigins indicates whether the response can be shared with requested
1996 /// resource from the given `Origin`.
1997 ///
1998 /// The `Origin` consists of a scheme and a host, with an optional port, and
1999 /// takes the form `<scheme>://<host>(:<port>)`.
2000 ///
2001 /// Valid values for scheme are: `http` and `https`.
2002 ///
2003 /// Valid values for port are any integer between 1 and 65535 (the list of
2004 /// available TCP/UDP ports). Note that, if not included, port `80` is
2005 /// assumed for `http` scheme origins, and port `443` is assumed for `https`
2006 /// origins. This may affect origin matching.
2007 ///
2008 /// The host part of the origin may contain the wildcard character `*`. These
2009 /// wildcard characters behave as follows:
2010 ///
2011 /// * `*` is a greedy match to the _left_, including any number of
2012 /// DNS labels to the left of its position. This also means that
2013 /// `*` will include any number of period `.` characters to the
2014 /// left of its position.
2015 /// * A wildcard by itself matches all hosts.
2016 ///
2017 /// An origin value that includes _only_ the `*` character indicates requests
2018 /// from all `Origin`s are allowed.
2019 ///
2020 /// When the `AllowOrigins` field is configured with multiple origins, it
2021 /// means the server supports clients from multiple origins. If the request
2022 /// `Origin` matches the configured allowed origins, the gateway must return
2023 /// the given `Origin` and sets value of the header
2024 /// `Access-Control-Allow-Origin` same as the `Origin` header provided by the
2025 /// client.
2026 ///
2027 /// The status code of a successful response to a "preflight" request is
2028 /// always an OK status (i.e., 204 or 200).
2029 ///
2030 /// If the request `Origin` does not match the configured allowed origins,
2031 /// the gateway returns 204/200 response but doesn't set the relevant
2032 /// cross-origin response headers. Alternatively, the gateway responds with
2033 /// 403 status to the "preflight" request is denied, coupled with omitting
2034 /// the CORS headers. The cross-origin request fails on the client side.
2035 /// Therefore, the client doesn't attempt the actual cross-origin request.
2036 ///
2037 /// The `Access-Control-Allow-Origin` response header can only use `*`
2038 /// wildcard as value when the `AllowCredentials` field is false or omitted.
2039 ///
2040 /// When the `AllowCredentials` field is true and `AllowOrigins` field
2041 /// specified with the `*` wildcard, the gateway must return a single origin
2042 /// in the value of the `Access-Control-Allow-Origin` response header,
2043 /// instead of specifying the `*` wildcard. The value of the header
2044 /// `Access-Control-Allow-Origin` is same as the `Origin` header provided by
2045 /// the client.
2046 ///
2047 /// Support: Extended
2048 #[serde(
2049 default,
2050 skip_serializing_if = "Option::is_none",
2051 rename = "allowOrigins"
2052 )]
2053 pub allow_origins: Option<Vec<String>>,
2054 /// ExposeHeaders indicates which HTTP response headers can be exposed
2055 /// to client-side scripts in response to a cross-origin request.
2056 ///
2057 /// A CORS-safelisted response header is an HTTP header in a CORS response
2058 /// that it is considered safe to expose to the client scripts.
2059 /// The CORS-safelisted response headers include the following headers:
2060 /// `Cache-Control`
2061 /// `Content-Language`
2062 /// `Content-Length`
2063 /// `Content-Type`
2064 /// `Expires`
2065 /// `Last-Modified`
2066 /// `Pragma`
2067 /// (See https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name)
2068 /// The CORS-safelisted response headers are exposed to client by default.
2069 ///
2070 /// When an HTTP header name is specified using the `ExposeHeaders` field,
2071 /// this additional header will be exposed as part of the response to the
2072 /// client.
2073 ///
2074 /// Header names are not case sensitive.
2075 ///
2076 /// Multiple header names in the value of the `Access-Control-Expose-Headers`
2077 /// response header are separated by a comma (",").
2078 ///
2079 /// A wildcard indicates that the responses with all HTTP headers are exposed
2080 /// to clients. The `Access-Control-Expose-Headers` response header can only
2081 /// use `*` wildcard as value when the `AllowCredentials` field is false or omitted.
2082 ///
2083 /// Support: Extended
2084 #[serde(
2085 default,
2086 skip_serializing_if = "Option::is_none",
2087 rename = "exposeHeaders"
2088 )]
2089 pub expose_headers: Option<Vec<String>>,
2090 /// MaxAge indicates the duration (in seconds) for the client to cache the
2091 /// results of a "preflight" request.
2092 ///
2093 /// The information provided by the `Access-Control-Allow-Methods` and
2094 /// `Access-Control-Allow-Headers` response headers can be cached by the
2095 /// client until the time specified by `Access-Control-Max-Age` elapses.
2096 ///
2097 /// The default value of `Access-Control-Max-Age` response header is 5
2098 /// (seconds).
2099 #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
2100 pub max_age: Option<i32>,
2101}
2102
2103/// ExtensionRef is an optional, implementation-specific extension to the
2104/// "filter" behavior. For example, resource "myroutefilter" in group
2105/// "networking.example.net"). ExtensionRef MUST NOT be used for core and
2106/// extended filters.
2107///
2108/// This filter can be used multiple times within the same rule.
2109///
2110/// Support: Implementation-specific
2111#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2112pub struct HTTPRouteRulesFiltersExtensionRef {
2113 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
2114 /// When unspecified or empty string, core API group is inferred.
2115 pub group: String,
2116 /// Kind is kind of the referent. For example "HTTPRoute" or "Service".
2117 pub kind: String,
2118 /// Name is the name of the referent.
2119 pub name: String,
2120}
2121
2122/// ExternalAuth configures settings related to sending request details
2123/// to an external auth service. The external service MUST authenticate
2124/// the request, and MAY authorize the request as well.
2125///
2126/// If there is any problem communicating with the external service,
2127/// this filter MUST fail closed.
2128///
2129/// Support: Extended
2130#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2131pub struct HTTPRouteRulesFiltersExternalAuth {
2132 /// BackendRef is a reference to a backend to send authorization
2133 /// requests to.
2134 ///
2135 /// The backend must speak the selected protocol (GRPC or HTTP) on the
2136 /// referenced port.
2137 ///
2138 /// If the backend service requires TLS, use BackendTLSPolicy to tell the
2139 /// implementation to supply the TLS details to be used to connect to that
2140 /// backend.
2141 #[serde(rename = "backendRef")]
2142 pub backend_ref: HTTPRouteRulesFiltersExternalAuthBackendRef,
2143 /// ForwardBody controls if requests to the authorization server should include
2144 /// the body of the client request; and if so, how big that body is allowed
2145 /// to be.
2146 ///
2147 /// It is expected that implementations will buffer the request body up to
2148 /// `forwardBody.maxSize` bytes. Bodies over that size must be rejected with a
2149 /// 4xx series error (413 or 403 are common examples), and fail processing
2150 /// of the filter.
2151 ///
2152 /// If unset, or `forwardBody.maxSize` is set to `0`, then the body will not
2153 /// be forwarded.
2154 ///
2155 /// Feature Name: HTTPRouteExternalAuthForwardBody
2156 #[serde(
2157 default,
2158 skip_serializing_if = "Option::is_none",
2159 rename = "forwardBody"
2160 )]
2161 pub forward_body: Option<HTTPRouteRulesFiltersExternalAuthForwardBody>,
2162 /// GRPCAuthConfig contains configuration for communication with ext_authz
2163 /// protocol-speaking backends.
2164 ///
2165 /// If unset, implementations must assume the default behavior for each
2166 /// included field is intended.
2167 #[serde(default, skip_serializing_if = "Option::is_none")]
2168 pub grpc: Option<HTTPRouteRulesFiltersExternalAuthGrpc>,
2169 /// HTTPAuthConfig contains configuration for communication with HTTP-speaking
2170 /// backends.
2171 ///
2172 /// If unset, implementations must assume the default behavior for each
2173 /// included field is intended.
2174 #[serde(default, skip_serializing_if = "Option::is_none")]
2175 pub http: Option<HTTPRouteRulesFiltersExternalAuthHttp>,
2176 /// ExternalAuthProtocol describes which protocol to use when communicating with an
2177 /// ext_authz authorization server.
2178 ///
2179 /// When this is set to GRPC, each backend must use the Envoy ext_authz protocol
2180 /// on the port specified in `backendRefs`. Requests and responses are defined
2181 /// in the protobufs explained at:
2182 /// https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/auth/v3/external_auth.proto
2183 ///
2184 /// When this is set to HTTP, each backend must respond with a `200` status
2185 /// code in on a successful authorization. Any other code is considered
2186 /// an authorization failure.
2187 ///
2188 /// Feature Names:
2189 /// GRPC Support - HTTPRouteExternalAuthGRPC
2190 /// HTTP Support - HTTPRouteExternalAuthHTTP
2191 pub protocol: HTTPRouteRulesFiltersExternalAuthProtocol,
2192}
2193
2194/// BackendRef is a reference to a backend to send authorization
2195/// requests to.
2196///
2197/// The backend must speak the selected protocol (GRPC or HTTP) on the
2198/// referenced port.
2199///
2200/// If the backend service requires TLS, use BackendTLSPolicy to tell the
2201/// implementation to supply the TLS details to be used to connect to that
2202/// backend.
2203#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2204pub struct HTTPRouteRulesFiltersExternalAuthBackendRef {
2205 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
2206 /// When unspecified or empty string, core API group is inferred.
2207 #[serde(default, skip_serializing_if = "Option::is_none")]
2208 pub group: Option<String>,
2209 /// Kind is the Kubernetes resource kind of the referent. For example
2210 /// "Service".
2211 ///
2212 /// Defaults to "Service" when not specified.
2213 ///
2214 /// ExternalName services can refer to CNAME DNS records that may live
2215 /// outside of the cluster and as such are difficult to reason about in
2216 /// terms of conformance. They also may not be safe to forward to (see
2217 /// CVE-2021-25740 for more information). Implementations SHOULD NOT
2218 /// support ExternalName Services.
2219 ///
2220 /// Support: Core (Services with a type other than ExternalName)
2221 ///
2222 /// Support: Implementation-specific (Services with type ExternalName)
2223 #[serde(default, skip_serializing_if = "Option::is_none")]
2224 pub kind: Option<String>,
2225 /// Name is the name of the referent.
2226 pub name: String,
2227 /// Namespace is the namespace of the backend. When unspecified, the local
2228 /// namespace is inferred.
2229 ///
2230 /// Note that when a namespace different than the local namespace is specified,
2231 /// a ReferenceGrant object is required in the referent namespace to allow that
2232 /// namespace's owner to accept the reference. See the ReferenceGrant
2233 /// documentation for details.
2234 ///
2235 /// Support: Core
2236 #[serde(default, skip_serializing_if = "Option::is_none")]
2237 pub namespace: Option<String>,
2238 /// Port specifies the destination port number to use for this resource.
2239 /// Port is required when the referent is a Kubernetes Service. In this
2240 /// case, the port number is the service port number, not the target port.
2241 /// For other resources, destination port might be derived from the referent
2242 /// resource or this field.
2243 #[serde(default, skip_serializing_if = "Option::is_none")]
2244 pub port: Option<i32>,
2245}
2246
2247/// ForwardBody controls if requests to the authorization server should include
2248/// the body of the client request; and if so, how big that body is allowed
2249/// to be.
2250///
2251/// It is expected that implementations will buffer the request body up to
2252/// `forwardBody.maxSize` bytes. Bodies over that size must be rejected with a
2253/// 4xx series error (413 or 403 are common examples), and fail processing
2254/// of the filter.
2255///
2256/// If unset, or `forwardBody.maxSize` is set to `0`, then the body will not
2257/// be forwarded.
2258///
2259/// Feature Name: HTTPRouteExternalAuthForwardBody
2260#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2261pub struct HTTPRouteRulesFiltersExternalAuthForwardBody {
2262 /// MaxSize specifies how large in bytes the largest body that will be buffered
2263 /// and sent to the authorization server. If the body size is larger than
2264 /// `maxSize`, then the body sent to the authorization server must be
2265 /// truncated to `maxSize` bytes.
2266 ///
2267 /// Experimental note: This behavior needs to be checked against
2268 /// various dataplanes; it may need to be changed.
2269 /// See https://github.com/kubernetes-sigs/gateway-api/pull/4001#discussion_r2291405746
2270 /// for more.
2271 ///
2272 /// If 0, the body will not be sent to the authorization server.
2273 #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSize")]
2274 pub max_size: Option<i64>,
2275}
2276
2277/// GRPCAuthConfig contains configuration for communication with ext_authz
2278/// protocol-speaking backends.
2279///
2280/// If unset, implementations must assume the default behavior for each
2281/// included field is intended.
2282#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2283pub struct HTTPRouteRulesFiltersExternalAuthGrpc {
2284 /// AllowedRequestHeaders specifies what headers from the client request
2285 /// will be sent to the authorization server.
2286 ///
2287 /// If this list is empty, then all headers must be sent.
2288 ///
2289 /// If the list has entries, only those entries must be sent.
2290 #[serde(
2291 default,
2292 skip_serializing_if = "Option::is_none",
2293 rename = "allowedHeaders"
2294 )]
2295 pub allowed_headers: Option<Vec<String>>,
2296}
2297
2298/// HTTPAuthConfig contains configuration for communication with HTTP-speaking
2299/// backends.
2300///
2301/// If unset, implementations must assume the default behavior for each
2302/// included field is intended.
2303#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2304pub struct HTTPRouteRulesFiltersExternalAuthHttp {
2305 /// AllowedRequestHeaders specifies what additional headers from the client request
2306 /// will be sent to the authorization server.
2307 ///
2308 /// The following headers must always be sent to the authorization server,
2309 /// regardless of this setting:
2310 ///
2311 /// * `Host`
2312 /// * `Method`
2313 /// * `Path`
2314 /// * `Content-Length`
2315 /// * `Authorization`
2316 ///
2317 /// If this list is empty, then only those headers must be sent.
2318 ///
2319 /// Note that `Content-Length` has a special behavior, in that the length
2320 /// sent must be correct for the actual request to the external authorization
2321 /// server - that is, it must reflect the actual number of bytes sent in the
2322 /// body of the request to the authorization server.
2323 ///
2324 /// So if the `forwardBody` stanza is unset, or `forwardBody.maxSize` is set
2325 /// to `0`, then `Content-Length` must be `0`. If `forwardBody.maxSize` is set
2326 /// to anything other than `0`, then the `Content-Length` of the authorization
2327 /// request must be set to the actual number of bytes forwarded.
2328 #[serde(
2329 default,
2330 skip_serializing_if = "Option::is_none",
2331 rename = "allowedHeaders"
2332 )]
2333 pub allowed_headers: Option<Vec<String>>,
2334 /// AllowedResponseHeaders specifies what headers from the authorization response
2335 /// will be copied into the request to the backend.
2336 ///
2337 /// If this list is empty, then all headers from the authorization server
2338 /// except Authority or Host must be copied.
2339 #[serde(
2340 default,
2341 skip_serializing_if = "Option::is_none",
2342 rename = "allowedResponseHeaders"
2343 )]
2344 pub allowed_response_headers: Option<Vec<String>>,
2345 /// Path sets the prefix that paths from the client request will have added
2346 /// when forwarded to the authorization server.
2347 ///
2348 /// When empty or unspecified, no prefix is added.
2349 ///
2350 /// Valid values are the same as the "value" regex for path values in the `match`
2351 /// stanza, and the validation regex will screen out invalid paths in the same way.
2352 /// Even with the validation, implementations MUST sanitize this input before using it
2353 /// directly.
2354 #[serde(default, skip_serializing_if = "Option::is_none")]
2355 pub path: Option<String>,
2356}
2357
2358/// ExternalAuth configures settings related to sending request details
2359/// to an external auth service. The external service MUST authenticate
2360/// the request, and MAY authorize the request as well.
2361///
2362/// If there is any problem communicating with the external service,
2363/// this filter MUST fail closed.
2364///
2365/// Support: Extended
2366#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
2367pub enum HTTPRouteRulesFiltersExternalAuthProtocol {
2368 #[serde(rename = "HTTP")]
2369 Http,
2370 #[serde(rename = "GRPC")]
2371 Grpc,
2372}
2373
2374/// RequestHeaderModifier defines a schema for a filter that modifies request
2375/// headers.
2376///
2377/// Support: Core
2378#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2379pub struct HTTPRouteRulesFiltersRequestHeaderModifier {
2380 /// Add adds the given header(s) (name, value) to the request
2381 /// before the action. It appends to any existing values associated
2382 /// with the header name.
2383 ///
2384 /// Input:
2385 /// GET /foo HTTP/1.1
2386 /// my-header: foo
2387 ///
2388 /// Config:
2389 /// add:
2390 /// - name: "my-header"
2391 /// value: "bar,baz"
2392 ///
2393 /// Output:
2394 /// GET /foo HTTP/1.1
2395 /// my-header: foo,bar,baz
2396 #[serde(default, skip_serializing_if = "Option::is_none")]
2397 pub add: Option<Vec<HTTPRouteRulesFiltersRequestHeaderModifierAdd>>,
2398 /// Remove the given header(s) from the HTTP request before the action. The
2399 /// value of Remove is a list of HTTP header names. Note that the header
2400 /// names are case-insensitive (see
2401 /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).
2402 ///
2403 /// Input:
2404 /// GET /foo HTTP/1.1
2405 /// my-header1: foo
2406 /// my-header2: bar
2407 /// my-header3: baz
2408 ///
2409 /// Config:
2410 /// remove: ["my-header1", "my-header3"]
2411 ///
2412 /// Output:
2413 /// GET /foo HTTP/1.1
2414 /// my-header2: bar
2415 #[serde(default, skip_serializing_if = "Option::is_none")]
2416 pub remove: Option<Vec<String>>,
2417 /// Set overwrites the request with the given header (name, value)
2418 /// before the action.
2419 ///
2420 /// Input:
2421 /// GET /foo HTTP/1.1
2422 /// my-header: foo
2423 ///
2424 /// Config:
2425 /// set:
2426 /// - name: "my-header"
2427 /// value: "bar"
2428 ///
2429 /// Output:
2430 /// GET /foo HTTP/1.1
2431 /// my-header: bar
2432 #[serde(default, skip_serializing_if = "Option::is_none")]
2433 pub set: Option<Vec<HTTPRouteRulesFiltersRequestHeaderModifierSet>>,
2434}
2435
2436/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
2437#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2438pub struct HTTPRouteRulesFiltersRequestHeaderModifierAdd {
2439 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
2440 /// case-insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2).
2441 ///
2442 /// If multiple entries specify equivalent header names, the first entry with
2443 /// an equivalent name MUST be considered for a match. Subsequent entries
2444 /// with an equivalent header name MUST be ignored. Due to the
2445 /// case-insensitivity of header names, "foo" and "Foo" are considered
2446 /// equivalent.
2447 pub name: String,
2448 /// Value is the value of HTTP Header to be matched.
2449 pub value: String,
2450}
2451
2452/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
2453#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2454pub struct HTTPRouteRulesFiltersRequestHeaderModifierSet {
2455 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
2456 /// case-insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2).
2457 ///
2458 /// If multiple entries specify equivalent header names, the first entry with
2459 /// an equivalent name MUST be considered for a match. Subsequent entries
2460 /// with an equivalent header name MUST be ignored. Due to the
2461 /// case-insensitivity of header names, "foo" and "Foo" are considered
2462 /// equivalent.
2463 pub name: String,
2464 /// Value is the value of HTTP Header to be matched.
2465 pub value: String,
2466}
2467
2468/// RequestMirror defines a schema for a filter that mirrors requests.
2469/// Requests are sent to the specified destination, but responses from
2470/// that destination are ignored.
2471///
2472/// This filter can be used multiple times within the same rule. Note that
2473/// not all implementations will be able to support mirroring to multiple
2474/// backends.
2475///
2476/// Support: Extended
2477#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2478pub struct HTTPRouteRulesFiltersRequestMirror {
2479 /// BackendRef references a resource where mirrored requests are sent.
2480 ///
2481 /// Mirrored requests must be sent only to a single destination endpoint
2482 /// within this BackendRef, irrespective of how many endpoints are present
2483 /// within this BackendRef.
2484 ///
2485 /// If the referent cannot be found, this BackendRef is invalid and must be
2486 /// dropped from the Gateway. The controller must ensure the "ResolvedRefs"
2487 /// condition on the Route status is set to `status: False` and not configure
2488 /// this backend in the underlying implementation.
2489 ///
2490 /// If there is a cross-namespace reference to an *existing* object
2491 /// that is not allowed by a ReferenceGrant, the controller must ensure the
2492 /// "ResolvedRefs" condition on the Route is set to `status: False`,
2493 /// with the "RefNotPermitted" reason and not configure this backend in the
2494 /// underlying implementation.
2495 ///
2496 /// In either error case, the Message of the `ResolvedRefs` Condition
2497 /// should be used to provide more detail about the problem.
2498 ///
2499 /// Support: Extended for Kubernetes Service
2500 ///
2501 /// Support: Implementation-specific for any other resource
2502 #[serde(rename = "backendRef")]
2503 pub backend_ref: HTTPRouteRulesFiltersRequestMirrorBackendRef,
2504 /// Fraction represents the fraction of requests that should be
2505 /// mirrored to BackendRef.
2506 ///
2507 /// Only one of Fraction or Percent may be specified. If neither field
2508 /// is specified, 100% of requests will be mirrored.
2509 #[serde(default, skip_serializing_if = "Option::is_none")]
2510 pub fraction: Option<HTTPRouteRulesFiltersRequestMirrorFraction>,
2511 /// Percent represents the percentage of requests that should be
2512 /// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of
2513 /// requests) and its maximum value is 100 (indicating 100% of requests).
2514 ///
2515 /// Only one of Fraction or Percent may be specified. If neither field
2516 /// is specified, 100% of requests will be mirrored.
2517 #[serde(default, skip_serializing_if = "Option::is_none")]
2518 pub percent: Option<i32>,
2519}
2520
2521/// BackendRef references a resource where mirrored requests are sent.
2522///
2523/// Mirrored requests must be sent only to a single destination endpoint
2524/// within this BackendRef, irrespective of how many endpoints are present
2525/// within this BackendRef.
2526///
2527/// If the referent cannot be found, this BackendRef is invalid and must be
2528/// dropped from the Gateway. The controller must ensure the "ResolvedRefs"
2529/// condition on the Route status is set to `status: False` and not configure
2530/// this backend in the underlying implementation.
2531///
2532/// If there is a cross-namespace reference to an *existing* object
2533/// that is not allowed by a ReferenceGrant, the controller must ensure the
2534/// "ResolvedRefs" condition on the Route is set to `status: False`,
2535/// with the "RefNotPermitted" reason and not configure this backend in the
2536/// underlying implementation.
2537///
2538/// In either error case, the Message of the `ResolvedRefs` Condition
2539/// should be used to provide more detail about the problem.
2540///
2541/// Support: Extended for Kubernetes Service
2542///
2543/// Support: Implementation-specific for any other resource
2544#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2545pub struct HTTPRouteRulesFiltersRequestMirrorBackendRef {
2546 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
2547 /// When unspecified or empty string, core API group is inferred.
2548 #[serde(default, skip_serializing_if = "Option::is_none")]
2549 pub group: Option<String>,
2550 /// Kind is the Kubernetes resource kind of the referent. For example
2551 /// "Service".
2552 ///
2553 /// Defaults to "Service" when not specified.
2554 ///
2555 /// ExternalName services can refer to CNAME DNS records that may live
2556 /// outside of the cluster and as such are difficult to reason about in
2557 /// terms of conformance. They also may not be safe to forward to (see
2558 /// CVE-2021-25740 for more information). Implementations SHOULD NOT
2559 /// support ExternalName Services.
2560 ///
2561 /// Support: Core (Services with a type other than ExternalName)
2562 ///
2563 /// Support: Implementation-specific (Services with type ExternalName)
2564 #[serde(default, skip_serializing_if = "Option::is_none")]
2565 pub kind: Option<String>,
2566 /// Name is the name of the referent.
2567 pub name: String,
2568 /// Namespace is the namespace of the backend. When unspecified, the local
2569 /// namespace is inferred.
2570 ///
2571 /// Note that when a namespace different than the local namespace is specified,
2572 /// a ReferenceGrant object is required in the referent namespace to allow that
2573 /// namespace's owner to accept the reference. See the ReferenceGrant
2574 /// documentation for details.
2575 ///
2576 /// Support: Core
2577 #[serde(default, skip_serializing_if = "Option::is_none")]
2578 pub namespace: Option<String>,
2579 /// Port specifies the destination port number to use for this resource.
2580 /// Port is required when the referent is a Kubernetes Service. In this
2581 /// case, the port number is the service port number, not the target port.
2582 /// For other resources, destination port might be derived from the referent
2583 /// resource or this field.
2584 #[serde(default, skip_serializing_if = "Option::is_none")]
2585 pub port: Option<i32>,
2586}
2587
2588/// Fraction represents the fraction of requests that should be
2589/// mirrored to BackendRef.
2590///
2591/// Only one of Fraction or Percent may be specified. If neither field
2592/// is specified, 100% of requests will be mirrored.
2593#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2594pub struct HTTPRouteRulesFiltersRequestMirrorFraction {
2595 #[serde(default, skip_serializing_if = "Option::is_none")]
2596 pub denominator: Option<i32>,
2597 pub numerator: i32,
2598}
2599
2600/// RequestRedirect defines a schema for a filter that responds to the
2601/// request with an HTTP redirection.
2602///
2603/// Support: Core
2604#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2605pub struct HTTPRouteRulesFiltersRequestRedirect {
2606 /// Hostname is the hostname to be used in the value of the `Location`
2607 /// header in the response.
2608 /// When empty, the hostname in the `Host` header of the request is used.
2609 ///
2610 /// Support: Core
2611 #[serde(default, skip_serializing_if = "Option::is_none")]
2612 pub hostname: Option<String>,
2613 /// Path defines parameters used to modify the path of the incoming request.
2614 /// The modified path is then used to construct the `Location` header. When
2615 /// empty, the request path is used as-is.
2616 ///
2617 /// Support: Extended
2618 #[serde(default, skip_serializing_if = "Option::is_none")]
2619 pub path: Option<HTTPRouteRulesFiltersRequestRedirectPath>,
2620 /// Port is the port to be used in the value of the `Location`
2621 /// header in the response.
2622 ///
2623 /// If no port is specified, the redirect port MUST be derived using the
2624 /// following rules:
2625 ///
2626 /// * If redirect scheme is not-empty, the redirect port MUST be the well-known
2627 /// port associated with the redirect scheme. Specifically "http" to port 80
2628 /// and "https" to port 443. If the redirect scheme does not have a
2629 /// well-known port, the listener port of the Gateway SHOULD be used.
2630 /// * If redirect scheme is empty, the redirect port MUST be the Gateway
2631 /// Listener port.
2632 ///
2633 /// Implementations SHOULD NOT add the port number in the 'Location'
2634 /// header in the following cases:
2635 ///
2636 /// * A Location header that will use HTTP (whether that is determined via
2637 /// the Listener protocol or the Scheme field) _and_ use port 80.
2638 /// * A Location header that will use HTTPS (whether that is determined via
2639 /// the Listener protocol or the Scheme field) _and_ use port 443.
2640 ///
2641 /// Support: Extended
2642 #[serde(default, skip_serializing_if = "Option::is_none")]
2643 pub port: Option<i32>,
2644 /// Scheme is the scheme to be used in the value of the `Location` header in
2645 /// the response. When empty, the scheme of the request is used.
2646 ///
2647 /// Scheme redirects can affect the port of the redirect, for more information,
2648 /// refer to the documentation for the port field of this filter.
2649 ///
2650 /// Note that values may be added to this enum, implementations
2651 /// must ensure that unknown values will not cause a crash.
2652 ///
2653 /// Unknown values here must result in the implementation setting the
2654 /// Accepted Condition for the Route to `status: False`, with a
2655 /// Reason of `UnsupportedValue`.
2656 ///
2657 /// Support: Extended
2658 #[serde(default, skip_serializing_if = "Option::is_none")]
2659 pub scheme: Option<HTTPRouteRulesFiltersRequestRedirectScheme>,
2660 /// StatusCode is the HTTP status code to be used in response.
2661 ///
2662 /// Note that values may be added to this enum, implementations
2663 /// must ensure that unknown values will not cause a crash.
2664 ///
2665 /// Unknown values here must result in the implementation setting the
2666 /// Accepted Condition for the Route to `status: False`, with a
2667 /// Reason of `UnsupportedValue`.
2668 ///
2669 /// Support: Core
2670 #[serde(
2671 default,
2672 skip_serializing_if = "Option::is_none",
2673 rename = "statusCode"
2674 )]
2675 pub status_code: Option<i64>,
2676}
2677
2678/// Path defines parameters used to modify the path of the incoming request.
2679/// The modified path is then used to construct the `Location` header. When
2680/// empty, the request path is used as-is.
2681///
2682/// Support: Extended
2683#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2684pub struct HTTPRouteRulesFiltersRequestRedirectPath {
2685 /// ReplaceFullPath specifies the value with which to replace the full path
2686 /// of a request during a rewrite or redirect.
2687 #[serde(
2688 default,
2689 skip_serializing_if = "Option::is_none",
2690 rename = "replaceFullPath"
2691 )]
2692 pub replace_full_path: Option<String>,
2693 /// ReplacePrefixMatch specifies the value with which to replace the prefix
2694 /// match of a request during a rewrite or redirect. For example, a request
2695 /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch
2696 /// of "/xyz" would be modified to "/xyz/bar".
2697 ///
2698 /// Note that this matches the behavior of the PathPrefix match type. This
2699 /// matches full path elements. A path element refers to the list of labels
2700 /// in the path split by the `/` separator. When specified, a trailing `/` is
2701 /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all
2702 /// match the prefix `/abc`, but the path `/abcd` would not.
2703 ///
2704 /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch.
2705 /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in
2706 /// the implementation setting the Accepted Condition for the Route to `status: False`.
2707 ///
2708 /// Request Path | Prefix Match | Replace Prefix | Modified Path
2709 #[serde(
2710 default,
2711 skip_serializing_if = "Option::is_none",
2712 rename = "replacePrefixMatch"
2713 )]
2714 pub replace_prefix_match: Option<String>,
2715 /// Type defines the type of path modifier. Additional types may be
2716 /// added in a future release of the API.
2717 ///
2718 /// Note that values may be added to this enum, implementations
2719 /// must ensure that unknown values will not cause a crash.
2720 ///
2721 /// Unknown values here must result in the implementation setting the
2722 /// Accepted Condition for the Route to `status: False`, with a
2723 /// Reason of `UnsupportedValue`.
2724 #[serde(rename = "type")]
2725 pub r#type: HTTPRouteRulesFiltersRequestRedirectPathType,
2726}
2727
2728/// Path defines parameters used to modify the path of the incoming request.
2729/// The modified path is then used to construct the `Location` header. When
2730/// empty, the request path is used as-is.
2731///
2732/// Support: Extended
2733#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
2734pub enum HTTPRouteRulesFiltersRequestRedirectPathType {
2735 ReplaceFullPath,
2736 ReplacePrefixMatch,
2737}
2738
2739/// RequestRedirect defines a schema for a filter that responds to the
2740/// request with an HTTP redirection.
2741///
2742/// Support: Core
2743#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
2744pub enum HTTPRouteRulesFiltersRequestRedirectScheme {
2745 #[serde(rename = "http")]
2746 Http,
2747 #[serde(rename = "https")]
2748 Https,
2749}
2750
2751/// RequestRedirect defines a schema for a filter that responds to the
2752/// request with an HTTP redirection.
2753///
2754/// Support: Core
2755#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
2756pub enum HTTPRouteRulesFiltersRequestRedirectStatusCode {
2757 #[serde(rename = "301")]
2758 r#_301,
2759 #[serde(rename = "302")]
2760 r#_302,
2761}
2762
2763/// ResponseHeaderModifier defines a schema for a filter that modifies response
2764/// headers.
2765///
2766/// Support: Extended
2767#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2768pub struct HTTPRouteRulesFiltersResponseHeaderModifier {
2769 /// Add adds the given header(s) (name, value) to the request
2770 /// before the action. It appends to any existing values associated
2771 /// with the header name.
2772 ///
2773 /// Input:
2774 /// GET /foo HTTP/1.1
2775 /// my-header: foo
2776 ///
2777 /// Config:
2778 /// add:
2779 /// - name: "my-header"
2780 /// value: "bar,baz"
2781 ///
2782 /// Output:
2783 /// GET /foo HTTP/1.1
2784 /// my-header: foo,bar,baz
2785 #[serde(default, skip_serializing_if = "Option::is_none")]
2786 pub add: Option<Vec<HTTPRouteRulesFiltersResponseHeaderModifierAdd>>,
2787 /// Remove the given header(s) from the HTTP request before the action. The
2788 /// value of Remove is a list of HTTP header names. Note that the header
2789 /// names are case-insensitive (see
2790 /// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).
2791 ///
2792 /// Input:
2793 /// GET /foo HTTP/1.1
2794 /// my-header1: foo
2795 /// my-header2: bar
2796 /// my-header3: baz
2797 ///
2798 /// Config:
2799 /// remove: ["my-header1", "my-header3"]
2800 ///
2801 /// Output:
2802 /// GET /foo HTTP/1.1
2803 /// my-header2: bar
2804 #[serde(default, skip_serializing_if = "Option::is_none")]
2805 pub remove: Option<Vec<String>>,
2806 /// Set overwrites the request with the given header (name, value)
2807 /// before the action.
2808 ///
2809 /// Input:
2810 /// GET /foo HTTP/1.1
2811 /// my-header: foo
2812 ///
2813 /// Config:
2814 /// set:
2815 /// - name: "my-header"
2816 /// value: "bar"
2817 ///
2818 /// Output:
2819 /// GET /foo HTTP/1.1
2820 /// my-header: bar
2821 #[serde(default, skip_serializing_if = "Option::is_none")]
2822 pub set: Option<Vec<HTTPRouteRulesFiltersResponseHeaderModifierSet>>,
2823}
2824
2825/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
2826#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2827pub struct HTTPRouteRulesFiltersResponseHeaderModifierAdd {
2828 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
2829 /// case-insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2).
2830 ///
2831 /// If multiple entries specify equivalent header names, the first entry with
2832 /// an equivalent name MUST be considered for a match. Subsequent entries
2833 /// with an equivalent header name MUST be ignored. Due to the
2834 /// case-insensitivity of header names, "foo" and "Foo" are considered
2835 /// equivalent.
2836 pub name: String,
2837 /// Value is the value of HTTP Header to be matched.
2838 pub value: String,
2839}
2840
2841/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
2842#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2843pub struct HTTPRouteRulesFiltersResponseHeaderModifierSet {
2844 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
2845 /// case-insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2).
2846 ///
2847 /// If multiple entries specify equivalent header names, the first entry with
2848 /// an equivalent name MUST be considered for a match. Subsequent entries
2849 /// with an equivalent header name MUST be ignored. Due to the
2850 /// case-insensitivity of header names, "foo" and "Foo" are considered
2851 /// equivalent.
2852 pub name: String,
2853 /// Value is the value of HTTP Header to be matched.
2854 pub value: String,
2855}
2856
2857/// HTTPRouteFilter defines processing steps that must be completed during the
2858/// request or response lifecycle. HTTPRouteFilters are meant as an extension
2859/// point to express processing that may be done in Gateway implementations. Some
2860/// examples include request or response modification, implementing
2861/// authentication strategies, rate-limiting, and traffic shaping. API
2862/// guarantee/conformance is defined based on the type of the filter.
2863#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
2864pub enum HTTPRouteRulesFiltersType {
2865 RequestHeaderModifier,
2866 ResponseHeaderModifier,
2867 RequestMirror,
2868 RequestRedirect,
2869 #[serde(rename = "URLRewrite")]
2870 UrlRewrite,
2871 ExtensionRef,
2872 #[serde(rename = "CORS")]
2873 Cors,
2874 ExternalAuth,
2875}
2876
2877/// URLRewrite defines a schema for a filter that modifies a request during forwarding.
2878///
2879/// Support: Extended
2880#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2881pub struct HTTPRouteRulesFiltersUrlRewrite {
2882 /// Hostname is the value to be used to replace the Host header value during
2883 /// forwarding.
2884 ///
2885 /// Support: Extended
2886 #[serde(default, skip_serializing_if = "Option::is_none")]
2887 pub hostname: Option<String>,
2888 /// Path defines a path rewrite.
2889 ///
2890 /// Support: Extended
2891 #[serde(default, skip_serializing_if = "Option::is_none")]
2892 pub path: Option<HTTPRouteRulesFiltersUrlRewritePath>,
2893}
2894
2895/// Path defines a path rewrite.
2896///
2897/// Support: Extended
2898#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2899pub struct HTTPRouteRulesFiltersUrlRewritePath {
2900 /// ReplaceFullPath specifies the value with which to replace the full path
2901 /// of a request during a rewrite or redirect.
2902 #[serde(
2903 default,
2904 skip_serializing_if = "Option::is_none",
2905 rename = "replaceFullPath"
2906 )]
2907 pub replace_full_path: Option<String>,
2908 /// ReplacePrefixMatch specifies the value with which to replace the prefix
2909 /// match of a request during a rewrite or redirect. For example, a request
2910 /// to "/foo/bar" with a prefix match of "/foo" and a ReplacePrefixMatch
2911 /// of "/xyz" would be modified to "/xyz/bar".
2912 ///
2913 /// Note that this matches the behavior of the PathPrefix match type. This
2914 /// matches full path elements. A path element refers to the list of labels
2915 /// in the path split by the `/` separator. When specified, a trailing `/` is
2916 /// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all
2917 /// match the prefix `/abc`, but the path `/abcd` would not.
2918 ///
2919 /// ReplacePrefixMatch is only compatible with a `PathPrefix` HTTPRouteMatch.
2920 /// Using any other HTTPRouteMatch type on the same HTTPRouteRule will result in
2921 /// the implementation setting the Accepted Condition for the Route to `status: False`.
2922 ///
2923 /// Request Path | Prefix Match | Replace Prefix | Modified Path
2924 #[serde(
2925 default,
2926 skip_serializing_if = "Option::is_none",
2927 rename = "replacePrefixMatch"
2928 )]
2929 pub replace_prefix_match: Option<String>,
2930 /// Type defines the type of path modifier. Additional types may be
2931 /// added in a future release of the API.
2932 ///
2933 /// Note that values may be added to this enum, implementations
2934 /// must ensure that unknown values will not cause a crash.
2935 ///
2936 /// Unknown values here must result in the implementation setting the
2937 /// Accepted Condition for the Route to `status: False`, with a
2938 /// Reason of `UnsupportedValue`.
2939 #[serde(rename = "type")]
2940 pub r#type: HTTPRouteRulesFiltersUrlRewritePathType,
2941}
2942
2943/// Path defines a path rewrite.
2944///
2945/// Support: Extended
2946#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
2947pub enum HTTPRouteRulesFiltersUrlRewritePathType {
2948 ReplaceFullPath,
2949 ReplacePrefixMatch,
2950}
2951
2952/// HTTPRouteMatch defines the predicate used to match requests to a given
2953/// action. Multiple match types are ANDed together, i.e. the match will
2954/// evaluate to true only if all conditions are satisfied.
2955///
2956/// For example, the match below will match a HTTP request only if its path
2957/// starts with `/foo` AND it contains the `version: v1` header:
2958///
2959/// ```text
2960/// match:
2961///
2962/// path:
2963/// value: "/foo"
2964/// headers:
2965/// - name: "version"
2966/// value "v1"
2967///
2968/// ```
2969#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
2970pub struct HTTPRouteRulesMatches {
2971 /// Headers specifies HTTP request header matchers. Multiple match values are
2972 /// ANDed together, meaning, a request must match all the specified headers
2973 /// to select the route.
2974 #[serde(default, skip_serializing_if = "Option::is_none")]
2975 pub headers: Option<Vec<HTTPRouteRulesMatchesHeaders>>,
2976 /// Method specifies HTTP method matcher.
2977 /// When specified, this route will be matched only if the request has the
2978 /// specified method.
2979 ///
2980 /// Support: Extended
2981 #[serde(default, skip_serializing_if = "Option::is_none")]
2982 pub method: Option<HTTPRouteRulesMatchesMethod>,
2983 /// Path specifies a HTTP request path matcher. If this field is not
2984 /// specified, a default prefix match on the "/" path is provided.
2985 #[serde(default, skip_serializing_if = "Option::is_none")]
2986 pub path: Option<HTTPRouteRulesMatchesPath>,
2987 /// QueryParams specifies HTTP query parameter matchers. Multiple match
2988 /// values are ANDed together, meaning, a request must match all the
2989 /// specified query parameters to select the route.
2990 ///
2991 /// Support: Extended
2992 #[serde(
2993 default,
2994 skip_serializing_if = "Option::is_none",
2995 rename = "queryParams"
2996 )]
2997 pub query_params: Option<Vec<HTTPRouteRulesMatchesQueryParams>>,
2998}
2999
3000/// HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request
3001/// headers.
3002#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3003pub struct HTTPRouteRulesMatchesHeaders {
3004 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
3005 /// case-insensitive. (See https://tools.ietf.org/html/rfc7230#section-3.2).
3006 ///
3007 /// If multiple entries specify equivalent header names, only the first
3008 /// entry with an equivalent name MUST be considered for a match. Subsequent
3009 /// entries with an equivalent header name MUST be ignored. Due to the
3010 /// case-insensitivity of header names, "foo" and "Foo" are considered
3011 /// equivalent.
3012 ///
3013 /// When a header is repeated in an HTTP request, it is
3014 /// implementation-specific behavior as to how this is represented.
3015 /// Generally, proxies should follow the guidance from the RFC:
3016 /// https://www.rfc-editor.org/rfc/rfc7230.html#section-3.2.2 regarding
3017 /// processing a repeated header, with special handling for "Set-Cookie".
3018 pub name: String,
3019 /// Type specifies how to match against the value of the header.
3020 ///
3021 /// Support: Core (Exact)
3022 ///
3023 /// Support: Implementation-specific (RegularExpression)
3024 ///
3025 /// Since RegularExpression HeaderMatchType has implementation-specific
3026 /// conformance, implementations can support POSIX, PCRE or any other dialects
3027 /// of regular expressions. Please read the implementation's documentation to
3028 /// determine the supported dialect.
3029 #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
3030 pub r#type: Option<HTTPRouteRulesMatchesHeadersType>,
3031 /// Value is the value of HTTP Header to be matched.
3032 pub value: String,
3033}
3034
3035/// HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request
3036/// headers.
3037#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
3038pub enum HTTPRouteRulesMatchesHeadersType {
3039 Exact,
3040 RegularExpression,
3041}
3042
3043/// HTTPRouteMatch defines the predicate used to match requests to a given
3044/// action. Multiple match types are ANDed together, i.e. the match will
3045/// evaluate to true only if all conditions are satisfied.
3046///
3047/// For example, the match below will match a HTTP request only if its path
3048/// starts with `/foo` AND it contains the `version: v1` header:
3049///
3050/// ```text
3051/// match:
3052///
3053/// path:
3054/// value: "/foo"
3055/// headers:
3056/// - name: "version"
3057/// value "v1"
3058///
3059/// ```
3060#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
3061pub enum HTTPRouteRulesMatchesMethod {
3062 #[serde(rename = "GET")]
3063 Get,
3064 #[serde(rename = "HEAD")]
3065 Head,
3066 #[serde(rename = "POST")]
3067 Post,
3068 #[serde(rename = "PUT")]
3069 Put,
3070 #[serde(rename = "DELETE")]
3071 Delete,
3072 #[serde(rename = "CONNECT")]
3073 Connect,
3074 #[serde(rename = "OPTIONS")]
3075 Options,
3076 #[serde(rename = "TRACE")]
3077 Trace,
3078 #[serde(rename = "PATCH")]
3079 Patch,
3080}
3081
3082/// Path specifies a HTTP request path matcher. If this field is not
3083/// specified, a default prefix match on the "/" path is provided.
3084#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3085pub struct HTTPRouteRulesMatchesPath {
3086 /// Type specifies how to match against the path Value.
3087 ///
3088 /// Support: Core (Exact, PathPrefix)
3089 ///
3090 /// Support: Implementation-specific (RegularExpression)
3091 #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
3092 pub r#type: Option<HTTPRouteRulesMatchesPathType>,
3093 /// Value of the HTTP path to match against.
3094 #[serde(default, skip_serializing_if = "Option::is_none")]
3095 pub value: Option<String>,
3096}
3097
3098/// Path specifies a HTTP request path matcher. If this field is not
3099/// specified, a default prefix match on the "/" path is provided.
3100#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
3101pub enum HTTPRouteRulesMatchesPathType {
3102 Exact,
3103 PathPrefix,
3104 RegularExpression,
3105}
3106
3107/// HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP
3108/// query parameters.
3109#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3110pub struct HTTPRouteRulesMatchesQueryParams {
3111 /// Name is the name of the HTTP query param to be matched. This must be an
3112 /// exact string match. (See
3113 /// https://tools.ietf.org/html/rfc7230#section-2.7.3).
3114 ///
3115 /// If multiple entries specify equivalent query param names, only the first
3116 /// entry with an equivalent name MUST be considered for a match. Subsequent
3117 /// entries with an equivalent query param name MUST be ignored.
3118 ///
3119 /// If a query param is repeated in an HTTP request, the behavior is
3120 /// purposely left undefined, since different data planes have different
3121 /// capabilities. However, it is *recommended* that implementations should
3122 /// match against the first value of the param if the data plane supports it,
3123 /// as this behavior is expected in other load balancing contexts outside of
3124 /// the Gateway API.
3125 ///
3126 /// Users SHOULD NOT route traffic based on repeated query params to guard
3127 /// themselves against potential differences in the implementations.
3128 pub name: String,
3129 /// Type specifies how to match against the value of the query parameter.
3130 ///
3131 /// Support: Extended (Exact)
3132 ///
3133 /// Support: Implementation-specific (RegularExpression)
3134 ///
3135 /// Since RegularExpression QueryParamMatchType has Implementation-specific
3136 /// conformance, implementations can support POSIX, PCRE or any other
3137 /// dialects of regular expressions. Please read the implementation's
3138 /// documentation to determine the supported dialect.
3139 #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
3140 pub r#type: Option<HTTPRouteRulesMatchesQueryParamsType>,
3141 /// Value is the value of HTTP query param to be matched.
3142 pub value: String,
3143}
3144
3145/// HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP
3146/// query parameters.
3147#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
3148pub enum HTTPRouteRulesMatchesQueryParamsType {
3149 Exact,
3150 RegularExpression,
3151}
3152
3153/// Retry defines the configuration for when to retry an HTTP request.
3154///
3155/// Support: Extended
3156#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3157pub struct HTTPRouteRulesRetry {
3158 /// Attempts specifies the maximum number of times an individual request
3159 /// from the gateway to a backend should be retried.
3160 ///
3161 /// If the maximum number of retries has been attempted without a successful
3162 /// response from the backend, the Gateway MUST return an error.
3163 ///
3164 /// When this field is unspecified, the number of times to attempt to retry
3165 /// a backend request is implementation-specific.
3166 ///
3167 /// Support: Extended
3168 #[serde(default, skip_serializing_if = "Option::is_none")]
3169 pub attempts: Option<i64>,
3170 /// Backoff specifies the minimum duration a Gateway should wait between
3171 /// retry attempts and is represented in Gateway API Duration formatting.
3172 ///
3173 /// For example, setting the `rules[].retry.backoff` field to the value
3174 /// `100ms` will cause a backend request to first be retried approximately
3175 /// 100 milliseconds after timing out or receiving a response code configured
3176 /// to be retryable.
3177 ///
3178 /// An implementation MAY use an exponential or alternative backoff strategy
3179 /// for subsequent retry attempts, MAY cap the maximum backoff duration to
3180 /// some amount greater than the specified minimum, and MAY add arbitrary
3181 /// jitter to stagger requests, as long as unsuccessful backend requests are
3182 /// not retried before the configured minimum duration.
3183 ///
3184 /// If a Request timeout (`rules[].timeouts.request`) is configured on the
3185 /// route, the entire duration of the initial request and any retry attempts
3186 /// MUST not exceed the Request timeout duration. If any retry attempts are
3187 /// still in progress when the Request timeout duration has been reached,
3188 /// these SHOULD be canceled if possible and the Gateway MUST immediately
3189 /// return a timeout error.
3190 ///
3191 /// If a BackendRequest timeout (`rules[].timeouts.backendRequest`) is
3192 /// configured on the route, any retry attempts which reach the configured
3193 /// BackendRequest timeout duration without a response SHOULD be canceled if
3194 /// possible and the Gateway should wait for at least the specified backoff
3195 /// duration before attempting to retry the backend request again.
3196 ///
3197 /// If a BackendRequest timeout is _not_ configured on the route, retry
3198 /// attempts MAY time out after an implementation default duration, or MAY
3199 /// remain pending until a configured Request timeout or implementation
3200 /// default duration for total request time is reached.
3201 ///
3202 /// When this field is unspecified, the time to wait between retry attempts
3203 /// is implementation-specific.
3204 ///
3205 /// Support: Extended
3206 #[serde(default, skip_serializing_if = "Option::is_none")]
3207 pub backoff: Option<String>,
3208 /// Codes defines the HTTP response status codes for which a backend request
3209 /// should be retried.
3210 ///
3211 /// Support: Extended
3212 #[serde(default, skip_serializing_if = "Option::is_none")]
3213 pub codes: Option<Vec<i64>>,
3214}
3215
3216/// SessionPersistence defines and configures session persistence
3217/// for the route rule.
3218///
3219/// Support: Extended
3220#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3221pub struct HTTPRouteRulesSessionPersistence {
3222 /// AbsoluteTimeout defines the absolute timeout of the persistent
3223 /// session. Once the AbsoluteTimeout duration has elapsed, the
3224 /// session becomes invalid.
3225 ///
3226 /// Support: Extended
3227 #[serde(
3228 default,
3229 skip_serializing_if = "Option::is_none",
3230 rename = "absoluteTimeout"
3231 )]
3232 pub absolute_timeout: Option<String>,
3233 /// CookieConfig provides configuration settings that are specific
3234 /// to cookie-based session persistence.
3235 ///
3236 /// Support: Core
3237 #[serde(
3238 default,
3239 skip_serializing_if = "Option::is_none",
3240 rename = "cookieConfig"
3241 )]
3242 pub cookie_config: Option<HTTPRouteRulesSessionPersistenceCookieConfig>,
3243 /// IdleTimeout defines the idle timeout of the persistent session.
3244 /// Once the session has been idle for more than the specified
3245 /// IdleTimeout duration, the session becomes invalid.
3246 ///
3247 /// Support: Extended
3248 #[serde(
3249 default,
3250 skip_serializing_if = "Option::is_none",
3251 rename = "idleTimeout"
3252 )]
3253 pub idle_timeout: Option<String>,
3254 /// SessionName defines the name of the persistent session token
3255 /// which may be reflected in the cookie or the header. Users
3256 /// should avoid reusing session names to prevent unintended
3257 /// consequences, such as rejection or unpredictable behavior.
3258 ///
3259 /// Support: Implementation-specific
3260 #[serde(
3261 default,
3262 skip_serializing_if = "Option::is_none",
3263 rename = "sessionName"
3264 )]
3265 pub session_name: Option<String>,
3266 /// Type defines the type of session persistence such as through
3267 /// the use a header or cookie. Defaults to cookie based session
3268 /// persistence.
3269 ///
3270 /// Support: Core for "Cookie" type
3271 ///
3272 /// Support: Extended for "Header" type
3273 #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
3274 pub r#type: Option<HTTPRouteRulesSessionPersistenceType>,
3275}
3276
3277/// CookieConfig provides configuration settings that are specific
3278/// to cookie-based session persistence.
3279///
3280/// Support: Core
3281#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3282pub struct HTTPRouteRulesSessionPersistenceCookieConfig {
3283 /// LifetimeType specifies whether the cookie has a permanent or
3284 /// session-based lifetime. A permanent cookie persists until its
3285 /// specified expiry time, defined by the Expires or Max-Age cookie
3286 /// attributes, while a session cookie is deleted when the current
3287 /// session ends.
3288 ///
3289 /// When set to "Permanent", AbsoluteTimeout indicates the
3290 /// cookie's lifetime via the Expires or Max-Age cookie attributes
3291 /// and is required.
3292 ///
3293 /// When set to "Session", AbsoluteTimeout indicates the
3294 /// absolute lifetime of the cookie tracked by the gateway and
3295 /// is optional.
3296 ///
3297 /// Defaults to "Session".
3298 ///
3299 /// Support: Core for "Session" type
3300 ///
3301 /// Support: Extended for "Permanent" type
3302 #[serde(
3303 default,
3304 skip_serializing_if = "Option::is_none",
3305 rename = "lifetimeType"
3306 )]
3307 pub lifetime_type: Option<HTTPRouteRulesSessionPersistenceCookieConfigLifetimeType>,
3308}
3309
3310/// CookieConfig provides configuration settings that are specific
3311/// to cookie-based session persistence.
3312///
3313/// Support: Core
3314#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
3315pub enum HTTPRouteRulesSessionPersistenceCookieConfigLifetimeType {
3316 Permanent,
3317 Session,
3318}
3319
3320/// SessionPersistence defines and configures session persistence
3321/// for the route rule.
3322///
3323/// Support: Extended
3324#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
3325pub enum HTTPRouteRulesSessionPersistenceType {
3326 Cookie,
3327 Header,
3328}
3329
3330/// Timeouts defines the timeouts that can be configured for an HTTP request.
3331///
3332/// Support: Extended
3333#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3334pub struct HTTPRouteRulesTimeouts {
3335 /// BackendRequest specifies a timeout for an individual request from the gateway
3336 /// to a backend. This covers the time from when the request first starts being
3337 /// sent from the gateway to when the full response has been received from the backend.
3338 ///
3339 /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout
3340 /// completely. Implementations that cannot completely disable the timeout MUST
3341 /// instead interpret the zero duration as the longest possible value to which
3342 /// the timeout can be set.
3343 ///
3344 /// An entire client HTTP transaction with a gateway, covered by the Request timeout,
3345 /// may result in more than one call from the gateway to the destination backend,
3346 /// for example, if automatic retries are supported.
3347 ///
3348 /// The value of BackendRequest must be a Gateway API Duration string as defined by
3349 /// GEP-2257. When this field is unspecified, its behavior is implementation-specific;
3350 /// when specified, the value of BackendRequest must be no more than the value of the
3351 /// Request timeout (since the Request timeout encompasses the BackendRequest timeout).
3352 ///
3353 /// Support: Extended
3354 #[serde(
3355 default,
3356 skip_serializing_if = "Option::is_none",
3357 rename = "backendRequest"
3358 )]
3359 pub backend_request: Option<String>,
3360 /// Request specifies the maximum duration for a gateway to respond to an HTTP request.
3361 /// If the gateway has not been able to respond before this deadline is met, the gateway
3362 /// MUST return a timeout error.
3363 ///
3364 /// For example, setting the `rules.timeouts.request` field to the value `10s` in an
3365 /// `HTTPRoute` will cause a timeout if a client request is taking longer than 10 seconds
3366 /// to complete.
3367 ///
3368 /// Setting a timeout to the zero duration (e.g. "0s") SHOULD disable the timeout
3369 /// completely. Implementations that cannot completely disable the timeout MUST
3370 /// instead interpret the zero duration as the longest possible value to which
3371 /// the timeout can be set.
3372 ///
3373 /// This timeout is intended to cover as close to the whole request-response transaction
3374 /// as possible although an implementation MAY choose to start the timeout after the entire
3375 /// request stream has been received instead of immediately after the transaction is
3376 /// initiated by the client.
3377 ///
3378 /// The value of Request is a Gateway API Duration string as defined by GEP-2257. When this
3379 /// field is unspecified, request timeout behavior is implementation-specific.
3380 ///
3381 /// Support: Extended
3382 #[serde(default, skip_serializing_if = "Option::is_none")]
3383 pub request: Option<String>,
3384}
3385
3386/// Spec defines the desired state of HTTPRoute.
3387#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
3388pub enum HTTPRouteUseDefaultGateways {
3389 All,
3390 None,
3391}
3392
3393/// Status defines the current state of HTTPRoute.
3394#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3395pub struct HTTPRouteStatus {
3396 /// Parents is a list of parent resources (usually Gateways) that are
3397 /// associated with the route, and the status of the route with respect to
3398 /// each parent. When this route attaches to a parent, the controller that
3399 /// manages the parent must add an entry to this list when the controller
3400 /// first sees the route and should update the entry as appropriate when the
3401 /// route or gateway is modified.
3402 ///
3403 /// Note that parent references that cannot be resolved by an implementation
3404 /// of this API will not be added to this list. Implementations of this API
3405 /// can only populate Route status for the Gateways/parent resources they are
3406 /// responsible for.
3407 ///
3408 /// A maximum of 32 Gateways will be represented in this list. An empty list
3409 /// means the route has not been attached to any Gateway.
3410 pub parents: Vec<HTTPRouteStatusParents>,
3411}
3412
3413/// RouteParentStatus describes the status of a route with respect to an
3414/// associated Parent.
3415#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3416pub struct HTTPRouteStatusParents {
3417 /// Conditions describes the status of the route with respect to the Gateway.
3418 /// Note that the route's availability is also subject to the Gateway's own
3419 /// status conditions and listener status.
3420 ///
3421 /// If the Route's ParentRef specifies an existing Gateway that supports
3422 /// Routes of this kind AND that Gateway's controller has sufficient access,
3423 /// then that Gateway's controller MUST set the "Accepted" condition on the
3424 /// Route, to indicate whether the route has been accepted or rejected by the
3425 /// Gateway, and why.
3426 ///
3427 /// A Route MUST be considered "Accepted" if at least one of the Route's
3428 /// rules is implemented by the Gateway.
3429 ///
3430 /// There are a number of cases where the "Accepted" condition may not be set
3431 /// due to lack of controller visibility, that includes when:
3432 ///
3433 /// * The Route refers to a nonexistent parent.
3434 /// * The Route is of a type that the controller does not support.
3435 /// * The Route is in a namespace the controller does not have access to.
3436 pub conditions: Vec<Condition>,
3437 /// ControllerName is a domain/path string that indicates the name of the
3438 /// controller that wrote this status. This corresponds with the
3439 /// controllerName field on GatewayClass.
3440 ///
3441 /// Example: "example.net/gateway-controller".
3442 ///
3443 /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are
3444 /// valid Kubernetes names
3445 /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).
3446 ///
3447 /// Controllers MUST populate this field when writing status. Controllers should ensure that
3448 /// entries to status populated with their ControllerName are cleaned up when they are no
3449 /// longer necessary.
3450 #[serde(rename = "controllerName")]
3451 pub controller_name: String,
3452 /// ParentRef corresponds with a ParentRef in the spec that this
3453 /// RouteParentStatus struct describes the status of.
3454 #[serde(rename = "parentRef")]
3455 pub parent_ref: HTTPRouteStatusParentsParentRef,
3456}
3457
3458/// ParentRef corresponds with a ParentRef in the spec that this
3459/// RouteParentStatus struct describes the status of.
3460#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
3461pub struct HTTPRouteStatusParentsParentRef {
3462 /// Group is the group of the referent.
3463 /// When unspecified, "gateway.networking.k8s.io" is inferred.
3464 /// To set the core API group (such as for a "Service" kind referent),
3465 /// Group must be explicitly set to "" (empty string).
3466 ///
3467 /// Support: Core
3468 #[serde(default, skip_serializing_if = "Option::is_none")]
3469 pub group: Option<String>,
3470 /// Kind is kind of the referent.
3471 ///
3472 /// There are two kinds of parent resources with "Core" support:
3473 ///
3474 /// * Gateway (Gateway conformance profile)
3475 /// * Service (Mesh conformance profile, ClusterIP Services only)
3476 ///
3477 /// Support for other resources is Implementation-Specific.
3478 #[serde(default, skip_serializing_if = "Option::is_none")]
3479 pub kind: Option<String>,
3480 /// Name is the name of the referent.
3481 ///
3482 /// Support: Core
3483 pub name: String,
3484 /// Namespace is the namespace of the referent. When unspecified, this refers
3485 /// to the local namespace of the Route.
3486 ///
3487 /// Note that there are specific rules for ParentRefs which cross namespace
3488 /// boundaries. Cross-namespace references are only valid if they are explicitly
3489 /// allowed by something in the namespace they are referring to. For example:
3490 /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
3491 /// generic way to enable any other kind of cross-namespace reference.
3492 ///
3493 ///
3494 /// ParentRefs from a Route to a Service in the same namespace are "producer"
3495 /// routes, which apply default routing rules to inbound connections from
3496 /// any namespace to the Service.
3497 ///
3498 /// ParentRefs from a Route to a Service in a different namespace are
3499 /// "consumer" routes, and these routing rules are only applied to outbound
3500 /// connections originating from the same namespace as the Route, for which
3501 /// the intended destination of the connections are a Service targeted as a
3502 /// ParentRef of the Route.
3503 ///
3504 ///
3505 /// Support: Core
3506 #[serde(default, skip_serializing_if = "Option::is_none")]
3507 pub namespace: Option<String>,
3508 /// Port is the network port this Route targets. It can be interpreted
3509 /// differently based on the type of parent resource.
3510 ///
3511 /// When the parent resource is a Gateway, this targets all listeners
3512 /// listening on the specified port that also support this kind of Route(and
3513 /// select this Route). It's not recommended to set `Port` unless the
3514 /// networking behaviors specified in a Route must apply to a specific port
3515 /// as opposed to a listener(s) whose port(s) may be changed. When both Port
3516 /// and SectionName are specified, the name and port of the selected listener
3517 /// must match both specified values.
3518 ///
3519 ///
3520 /// When the parent resource is a Service, this targets a specific port in the
3521 /// Service spec. When both Port (experimental) and SectionName are specified,
3522 /// the name and port of the selected port must match both specified values.
3523 ///
3524 ///
3525 /// Implementations MAY choose to support other parent resources.
3526 /// Implementations supporting other types of parent resources MUST clearly
3527 /// document how/if Port is interpreted.
3528 ///
3529 /// For the purpose of status, an attachment is considered successful as
3530 /// long as the parent resource accepts it partially. For example, Gateway
3531 /// listeners can restrict which Routes can attach to them by Route kind,
3532 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment
3533 /// from the referencing Route, the Route MUST be considered successfully
3534 /// attached. If no Gateway listeners accept attachment from this Route,
3535 /// the Route MUST be considered detached from the Gateway.
3536 ///
3537 /// Support: Extended
3538 #[serde(default, skip_serializing_if = "Option::is_none")]
3539 pub port: Option<i32>,
3540 /// SectionName is the name of a section within the target resource. In the
3541 /// following resources, SectionName is interpreted as the following:
3542 ///
3543 /// * Gateway: Listener name. When both Port (experimental) and SectionName
3544 /// are specified, the name and port of the selected listener must match
3545 /// both specified values.
3546 /// * Service: Port name. When both Port (experimental) and SectionName
3547 /// are specified, the name and port of the selected listener must match
3548 /// both specified values.
3549 ///
3550 /// Implementations MAY choose to support attaching Routes to other resources.
3551 /// If that is the case, they MUST clearly document how SectionName is
3552 /// interpreted.
3553 ///
3554 /// When unspecified (empty string), this will reference the entire resource.
3555 /// For the purpose of status, an attachment is considered successful if at
3556 /// least one section in the parent resource accepts it. For example, Gateway
3557 /// listeners can restrict which Routes can attach to them by Route kind,
3558 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from
3559 /// the referencing Route, the Route MUST be considered successfully
3560 /// attached. If no Gateway listeners accept attachment from this Route, the
3561 /// Route MUST be considered detached from the Gateway.
3562 ///
3563 /// Support: Core
3564 #[serde(
3565 default,
3566 skip_serializing_if = "Option::is_none",
3567 rename = "sectionName"
3568 )]
3569 pub section_name: Option<String>,
3570}