gateway_api/apis/standard/grpcroutes.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.22.5
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 GRPCRoute.
15#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
16#[kube(
17 group = "gateway.networking.k8s.io",
18 version = "v1",
19 kind = "GRPCRoute",
20 plural = "grpcroutes"
21)]
22#[kube(namespaced)]
23#[kube(status = "GrpcRouteStatus")]
24#[kube(derive = "Default")]
25#[kube(derive = "PartialEq")]
26pub struct GrpcRouteSpec {
27 /// Hostnames defines a set of hostnames to match against the GRPC
28 /// Host header to select a GRPCRoute to process the request. This matches
29 /// the RFC 1123 definition of a hostname with 2 notable exceptions:
30 ///
31 /// 1. IPs are not allowed.
32 /// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard
33 /// label MUST appear by itself as the first label.
34 ///
35 /// If a hostname is specified by both the Listener and GRPCRoute, there
36 /// MUST be at least one intersecting hostname for the GRPCRoute to be
37 /// attached to the Listener. For example:
38 ///
39 /// * A Listener with `test.example.com` as the hostname matches GRPCRoutes
40 /// that have either not specified any hostnames, or have specified at
41 /// least one of `test.example.com` or `*.example.com`.
42 /// * A Listener with `*.example.com` as the hostname matches GRPCRoutes
43 /// that have either not specified any hostnames or have specified at least
44 /// one hostname that matches the Listener hostname. For example,
45 /// `test.example.com` and `*.example.com` would both match. On the other
46 /// hand, `example.com` and `test.example.net` would not match.
47 ///
48 /// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted
49 /// as a suffix match. That means that a match for `*.example.com` would match
50 /// both `test.example.com`, and `foo.test.example.com`, but not `example.com`.
51 ///
52 /// If both the Listener and GRPCRoute have specified hostnames, any
53 /// GRPCRoute hostnames that do not match the Listener hostname MUST be
54 /// ignored. For example, if a Listener specified `*.example.com`, and the
55 /// GRPCRoute specified `test.example.com` and `test.example.net`,
56 /// `test.example.net` MUST NOT be considered for a match.
57 ///
58 /// If both the Listener and GRPCRoute have specified hostnames, and none
59 /// match with the criteria above, then the GRPCRoute MUST NOT be accepted by
60 /// the implementation. The implementation MUST raise an 'Accepted' Condition
61 /// with a status of `False` in the corresponding RouteParentStatus.
62 ///
63 /// If a Route (A) of type HTTPRoute or GRPCRoute is attached to a
64 /// Listener and that listener already has another Route (B) of the other
65 /// type attached and the intersection of the hostnames of A and B is
66 /// non-empty, then the implementation MUST accept exactly one of these two
67 /// routes, determined by the following criteria, in order:
68 ///
69 /// * The oldest Route based on creation timestamp.
70 /// * The Route appearing first in alphabetical order by
71 /// "{namespace}/{name}".
72 ///
73 /// The rejected Route MUST raise an 'Accepted' condition with a status of
74 /// 'False' in the corresponding RouteParentStatus.
75 ///
76 /// Support: Core
77 #[serde(default, skip_serializing_if = "Option::is_none")]
78 pub hostnames: Option<Vec<String>>,
79 /// ParentRefs references the resources (usually Gateways) that a Route wants
80 /// to be attached to. Note that the referenced parent resource needs to
81 /// allow this for the attachment to be complete. For Gateways, that means
82 /// the Gateway needs to allow attachment from Routes of this kind and
83 /// namespace. For Services, that means the Service must either be in the same
84 /// namespace for a "producer" route, or the mesh implementation must support
85 /// and allow "consumer" routes for the referenced Service. ReferenceGrant is
86 /// not applicable for governing ParentRefs to Services - it is not possible to
87 /// create a "producer" route for a Service in a different namespace from the
88 /// Route.
89 ///
90 /// There are two kinds of parent resources with "Core" support:
91 ///
92 /// * Gateway (Gateway conformance profile)
93 /// * Service (Mesh conformance profile, ClusterIP Services only)
94 ///
95 /// This API may be extended in the future to support additional kinds of parent
96 /// resources.
97 ///
98 /// ParentRefs must be _distinct_. This means either that:
99 ///
100 /// * They select different objects. If this is the case, then parentRef
101 /// entries are distinct. In terms of fields, this means that the
102 /// multi-part key defined by `group`, `kind`, `namespace`, and `name` must
103 /// be unique across all parentRef entries in the Route.
104 /// * They do not select different objects, but for each optional field used,
105 /// each ParentRef that selects the same object must set the same set of
106 /// optional fields to different values. If one ParentRef sets a
107 /// combination of optional fields, all must set the same combination.
108 ///
109 /// Some examples:
110 ///
111 /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the
112 /// same object must also set `sectionName`.
113 /// * If one ParentRef sets `port`, all ParentRefs referencing the same
114 /// object must also set `port`.
115 /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs
116 /// referencing the same object must also set `sectionName` and `port`.
117 ///
118 /// It is possible to separately reference multiple distinct objects that may
119 /// be collapsed by an implementation. For example, some implementations may
120 /// choose to merge compatible Gateway Listeners together. If that is the
121 /// case, the list of routes attached to those resources should also be
122 /// merged.
123 ///
124 /// Note that for ParentRefs that cross namespace boundaries, there are specific
125 /// rules. Cross-namespace references are only valid if they are explicitly
126 /// allowed by something in the namespace they are referring to. For example,
127 /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
128 /// generic way to enable other kinds of cross-namespace reference.
129 #[serde(default, skip_serializing_if = "Option::is_none", rename = "parentRefs")]
130 pub parent_refs: Option<Vec<GrpcRouteParentRefs>>,
131 /// Rules are a list of GRPC matchers, filters and actions.
132 #[serde(default, skip_serializing_if = "Option::is_none")]
133 pub rules: Option<Vec<GrpcRouteRules>>,
134}
135
136/// ParentReference identifies an API object (usually a Gateway) that can be considered
137/// a parent of this resource (usually a route). There are two kinds of parent resources
138/// with "Core" support:
139///
140/// * Gateway (Gateway conformance profile)
141/// * Service (Mesh conformance profile, ClusterIP Services only)
142///
143/// This API may be extended in the future to support additional kinds of parent
144/// resources.
145///
146/// The API object must be valid in the cluster; the Group and Kind must
147/// be registered in the cluster for this reference to be valid.
148#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
149pub struct GrpcRouteParentRefs {
150 /// Group is the group of the referent.
151 /// When unspecified, "gateway.networking.k8s.io" is inferred.
152 /// To set the core API group (such as for a "Service" kind referent),
153 /// Group must be explicitly set to "" (empty string).
154 ///
155 /// Support: Core
156 #[serde(default, skip_serializing_if = "Option::is_none")]
157 pub group: Option<String>,
158 /// Kind is kind of the referent.
159 ///
160 /// There are two kinds of parent resources with "Core" support:
161 ///
162 /// * Gateway (Gateway conformance profile)
163 /// * Service (Mesh conformance profile, ClusterIP Services only)
164 ///
165 /// Support for other resources is Implementation-Specific.
166 #[serde(default, skip_serializing_if = "Option::is_none")]
167 pub kind: Option<String>,
168 /// Name is the name of the referent.
169 ///
170 /// Support: Core
171 pub name: String,
172 /// Namespace is the namespace of the referent. When unspecified, this refers
173 /// to the local namespace of the Route.
174 ///
175 /// Note that there are specific rules for ParentRefs which cross namespace
176 /// boundaries. Cross-namespace references are only valid if they are explicitly
177 /// allowed by something in the namespace they are referring to. For example:
178 /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
179 /// generic way to enable any other kind of cross-namespace reference.
180 ///
181 /// Support: Core
182 #[serde(default, skip_serializing_if = "Option::is_none")]
183 pub namespace: Option<String>,
184 /// Port is the network port this Route targets. It can be interpreted
185 /// differently based on the type of parent resource.
186 ///
187 /// When the parent resource is a Gateway, this targets all listeners
188 /// listening on the specified port that also support this kind of Route(and
189 /// select this Route). It's not recommended to set `Port` unless the
190 /// networking behaviors specified in a Route must apply to a specific port
191 /// as opposed to a listener(s) whose port(s) may be changed. When both Port
192 /// and SectionName are specified, the name and port of the selected listener
193 /// must match both specified values.
194 ///
195 /// Implementations MAY choose to support other parent resources.
196 /// Implementations supporting other types of parent resources MUST clearly
197 /// document how/if Port is interpreted.
198 ///
199 /// For the purpose of status, an attachment is considered successful as
200 /// long as the parent resource accepts it partially. For example, Gateway
201 /// listeners can restrict which Routes can attach to them by Route kind,
202 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment
203 /// from the referencing Route, the Route MUST be considered successfully
204 /// attached. If no Gateway listeners accept attachment from this Route,
205 /// the Route MUST be considered detached from the Gateway.
206 ///
207 /// Support: Extended
208 #[serde(default, skip_serializing_if = "Option::is_none")]
209 pub port: Option<i32>,
210 /// SectionName is the name of a section within the target resource. In the
211 /// following resources, SectionName is interpreted as the following:
212 ///
213 /// * Gateway: Listener name. When both Port (experimental) and SectionName
214 /// are specified, the name and port of the selected listener must match
215 /// both specified values.
216 /// * Service: Port name. When both Port (experimental) and SectionName
217 /// are specified, the name and port of the selected listener must match
218 /// both specified values.
219 ///
220 /// Implementations MAY choose to support attaching Routes to other resources.
221 /// If that is the case, they MUST clearly document how SectionName is
222 /// interpreted.
223 ///
224 /// When unspecified (empty string), this will reference the entire resource.
225 /// For the purpose of status, an attachment is considered successful if at
226 /// least one section in the parent resource accepts it. For example, Gateway
227 /// listeners can restrict which Routes can attach to them by Route kind,
228 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from
229 /// the referencing Route, the Route MUST be considered successfully
230 /// attached. If no Gateway listeners accept attachment from this Route, the
231 /// Route MUST be considered detached from the Gateway.
232 ///
233 /// Support: Core
234 #[serde(default, skip_serializing_if = "Option::is_none", rename = "sectionName")]
235 pub section_name: Option<String>,
236}
237
238/// GRPCRouteRule defines the semantics for matching a gRPC request based on
239/// conditions (matches), processing it (filters), and forwarding the request to
240/// an API object (backendRefs).
241#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
242pub struct GrpcRouteRules {
243 /// BackendRefs defines the backend(s) where matching requests should be
244 /// sent.
245 ///
246 /// Failure behavior here depends on how many BackendRefs are specified and
247 /// how many are invalid.
248 ///
249 /// If *all* entries in BackendRefs are invalid, and there are also no filters
250 /// specified in this route rule, *all* traffic which matches this rule MUST
251 /// receive an `UNAVAILABLE` status.
252 ///
253 /// See the GRPCBackendRef definition for the rules about what makes a single
254 /// GRPCBackendRef invalid.
255 ///
256 /// When a GRPCBackendRef is invalid, `UNAVAILABLE` statuses MUST be returned for
257 /// requests that would have otherwise been routed to an invalid backend. If
258 /// multiple backends are specified, and some are invalid, the proportion of
259 /// requests that would otherwise have been routed to an invalid backend
260 /// MUST receive an `UNAVAILABLE` status.
261 ///
262 /// For example, if two backends are specified with equal weights, and one is
263 /// invalid, 50 percent of traffic MUST receive an `UNAVAILABLE` status.
264 /// Implementations may choose how that 50 percent is determined.
265 ///
266 /// Support: Core for Kubernetes Service
267 ///
268 /// Support: Implementation-specific for any other resource
269 ///
270 /// Support for weight: Core
271 #[serde(default, skip_serializing_if = "Option::is_none", rename = "backendRefs")]
272 pub backend_refs: Option<Vec<GrpcRouteRulesBackendRefs>>,
273 /// Filters define the filters that are applied to requests that match
274 /// this rule.
275 ///
276 /// The effects of ordering of multiple behaviors are currently unspecified.
277 /// This can change in the future based on feedback during the alpha stage.
278 ///
279 /// Conformance-levels at this level are defined based on the type of filter:
280 ///
281 /// - ALL core filters MUST be supported by all implementations that support
282 /// GRPCRoute.
283 /// - Implementers are encouraged to support extended filters.
284 /// - Implementation-specific custom filters have no API guarantees across
285 /// implementations.
286 ///
287 /// Specifying the same filter multiple times is not supported unless explicitly
288 /// indicated in the filter.
289 ///
290 /// If an implementation cannot support a combination of filters, it must clearly
291 /// document that limitation. In cases where incompatible or unsupported
292 /// filters are specified and cause the `Accepted` condition to be set to status
293 /// `False`, implementations may use the `IncompatibleFilters` reason to specify
294 /// this configuration error.
295 ///
296 /// Support: Core
297 #[serde(default, skip_serializing_if = "Option::is_none")]
298 pub filters: Option<Vec<GrpcRouteRulesFilters>>,
299 /// Matches define conditions used for matching the rule against incoming
300 /// gRPC requests. Each match is independent, i.e. this rule will be matched
301 /// if **any** one of the matches is satisfied.
302 ///
303 /// For example, take the following matches configuration:
304 ///
305 /// ```text
306 /// matches:
307 /// - method:
308 /// service: foo.bar
309 /// headers:
310 /// values:
311 /// version: 2
312 /// - method:
313 /// service: foo.bar.v2
314 /// ```
315 ///
316 /// For a request to match against this rule, it MUST satisfy
317 /// EITHER of the two conditions:
318 ///
319 /// - service of foo.bar AND contains the header `version: 2`
320 /// - service of foo.bar.v2
321 ///
322 /// See the documentation for GRPCRouteMatch on how to specify multiple
323 /// match conditions to be ANDed together.
324 ///
325 /// If no matches are specified, the implementation MUST match every gRPC request.
326 ///
327 /// Proxy or Load Balancer routing configuration generated from GRPCRoutes
328 /// MUST prioritize rules based on the following criteria, continuing on
329 /// ties. Merging MUST not be done between GRPCRoutes and HTTPRoutes.
330 /// Precedence MUST be given to the rule with the largest number of:
331 ///
332 /// * Characters in a matching non-wildcard hostname.
333 /// * Characters in a matching hostname.
334 /// * Characters in a matching service.
335 /// * Characters in a matching method.
336 /// * Header matches.
337 ///
338 /// If ties still exist across multiple Routes, matching precedence MUST be
339 /// determined in order of the following criteria, continuing on ties:
340 ///
341 /// * The oldest Route based on creation timestamp.
342 /// * The Route appearing first in alphabetical order by
343 /// "{namespace}/{name}".
344 ///
345 /// If ties still exist within the Route that has been given precedence,
346 /// matching precedence MUST be granted to the first matching rule meeting
347 /// the above criteria.
348 #[serde(default, skip_serializing_if = "Option::is_none")]
349 pub matches: Option<Vec<GrpcRouteRulesMatches>>,
350 /// Name is the name of the route rule. This name MUST be unique within a Route if it is set.
351 ///
352 /// Support: Extended
353 #[serde(default, skip_serializing_if = "Option::is_none")]
354 pub name: Option<String>,
355}
356
357/// GRPCBackendRef defines how a GRPCRoute forwards a gRPC request.
358///
359/// Note that when a namespace different than the local namespace is specified, a
360/// ReferenceGrant object is required in the referent namespace to allow that
361/// namespace's owner to accept the reference. See the ReferenceGrant
362/// documentation for details.
363#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
364pub struct GrpcRouteRulesBackendRefs {
365 /// Filters defined at this level MUST be executed if and only if the
366 /// request is being forwarded to the backend defined here.
367 ///
368 /// Support: Implementation-specific (For broader support of filters, use the
369 /// Filters field in GRPCRouteRule.)
370 #[serde(default, skip_serializing_if = "Option::is_none")]
371 pub filters: Option<Vec<GrpcRouteRulesBackendRefsFilters>>,
372 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
373 /// When unspecified or empty string, core API group is inferred.
374 #[serde(default, skip_serializing_if = "Option::is_none")]
375 pub group: Option<String>,
376 /// Kind is the Kubernetes resource kind of the referent. For example
377 /// "Service".
378 ///
379 /// Defaults to "Service" when not specified.
380 ///
381 /// ExternalName services can refer to CNAME DNS records that may live
382 /// outside of the cluster and as such are difficult to reason about in
383 /// terms of conformance. They also may not be safe to forward to (see
384 /// CVE-2021-25740 for more information). Implementations SHOULD NOT
385 /// support ExternalName Services.
386 ///
387 /// Support: Core (Services with a type other than ExternalName)
388 ///
389 /// Support: Implementation-specific (Services with type ExternalName)
390 #[serde(default, skip_serializing_if = "Option::is_none")]
391 pub kind: Option<String>,
392 /// Name is the name of the referent.
393 pub name: String,
394 /// Namespace is the namespace of the backend. When unspecified, the local
395 /// namespace is inferred.
396 ///
397 /// Note that when a namespace different than the local namespace is specified,
398 /// a ReferenceGrant object is required in the referent namespace to allow that
399 /// namespace's owner to accept the reference. See the ReferenceGrant
400 /// documentation for details.
401 ///
402 /// Support: Core
403 #[serde(default, skip_serializing_if = "Option::is_none")]
404 pub namespace: Option<String>,
405 /// Port specifies the destination port number to use for this resource.
406 /// Port is required when the referent is a Kubernetes Service. In this
407 /// case, the port number is the service port number, not the target port.
408 /// For other resources, destination port might be derived from the referent
409 /// resource or this field.
410 #[serde(default, skip_serializing_if = "Option::is_none")]
411 pub port: Option<i32>,
412 /// Weight specifies the proportion of requests forwarded to the referenced
413 /// backend. This is computed as weight/(sum of all weights in this
414 /// BackendRefs list). For non-zero values, there may be some epsilon from
415 /// the exact proportion defined here depending on the precision an
416 /// implementation supports. Weight is not a percentage and the sum of
417 /// weights does not need to equal 100.
418 ///
419 /// If only one backend is specified and it has a weight greater than 0, 100%
420 /// of the traffic is forwarded to that backend. If weight is set to 0, no
421 /// traffic should be forwarded for this entry. If unspecified, weight
422 /// defaults to 1.
423 ///
424 /// Support for this field varies based on the context where used.
425 #[serde(default, skip_serializing_if = "Option::is_none")]
426 pub weight: Option<i32>,
427}
428
429/// GRPCRouteFilter defines processing steps that must be completed during the
430/// request or response lifecycle. GRPCRouteFilters are meant as an extension
431/// point to express processing that may be done in Gateway implementations. Some
432/// examples include request or response modification, implementing
433/// authentication strategies, rate-limiting, and traffic shaping. API
434/// guarantee/conformance is defined based on the type of the filter.
435#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
436pub struct GrpcRouteRulesBackendRefsFilters {
437 /// ExtensionRef is an optional, implementation-specific extension to the
438 /// "filter" behavior. For example, resource "myroutefilter" in group
439 /// "networking.example.net"). ExtensionRef MUST NOT be used for core and
440 /// extended filters.
441 ///
442 /// Support: Implementation-specific
443 ///
444 /// This filter can be used multiple times within the same rule.
445 #[serde(default, skip_serializing_if = "Option::is_none", rename = "extensionRef")]
446 pub extension_ref: Option<GrpcRouteRulesBackendRefsFiltersExtensionRef>,
447 /// RequestHeaderModifier defines a schema for a filter that modifies request
448 /// headers.
449 ///
450 /// Support: Core
451 #[serde(default, skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier")]
452 pub request_header_modifier: Option<GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier>,
453 /// RequestMirror defines a schema for a filter that mirrors requests.
454 /// Requests are sent to the specified destination, but responses from
455 /// that destination are ignored.
456 ///
457 /// This filter can be used multiple times within the same rule. Note that
458 /// not all implementations will be able to support mirroring to multiple
459 /// backends.
460 ///
461 /// Support: Extended
462 #[serde(default, skip_serializing_if = "Option::is_none", rename = "requestMirror")]
463 pub request_mirror: Option<GrpcRouteRulesBackendRefsFiltersRequestMirror>,
464 /// ResponseHeaderModifier defines a schema for a filter that modifies response
465 /// headers.
466 ///
467 /// Support: Extended
468 #[serde(default, skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier")]
469 pub response_header_modifier: Option<GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier>,
470 /// Type identifies the type of filter to apply. As with other API fields,
471 /// types are classified into three conformance levels:
472 ///
473 /// - Core: Filter types and their corresponding configuration defined by
474 /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All
475 /// implementations supporting GRPCRoute MUST support core filters.
476 ///
477 /// - Extended: Filter types and their corresponding configuration defined by
478 /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers
479 /// are encouraged to support extended filters.
480 ///
481 /// - Implementation-specific: Filters that are defined and supported by specific vendors.
482 /// In the future, filters showing convergence in behavior across multiple
483 /// implementations will be considered for inclusion in extended or core
484 /// conformance levels. Filter-specific configuration for such filters
485 /// is specified using the ExtensionRef field. `Type` MUST be set to
486 /// "ExtensionRef" for custom filters.
487 ///
488 /// Implementers are encouraged to define custom implementation types to
489 /// extend the core API with implementation-specific behavior.
490 ///
491 /// If a reference to a custom filter type cannot be resolved, the filter
492 /// MUST NOT be skipped. Instead, requests that would have been processed by
493 /// that filter MUST receive a HTTP error response.
494 #[serde(rename = "type")]
495 pub r#type: GrpcRouteRulesBackendRefsFiltersType,
496}
497
498/// ExtensionRef is an optional, implementation-specific extension to the
499/// "filter" behavior. For example, resource "myroutefilter" in group
500/// "networking.example.net"). ExtensionRef MUST NOT be used for core and
501/// extended filters.
502///
503/// Support: Implementation-specific
504///
505/// This filter can be used multiple times within the same rule.
506#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
507pub struct GrpcRouteRulesBackendRefsFiltersExtensionRef {
508 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
509 /// When unspecified or empty string, core API group is inferred.
510 pub group: String,
511 /// Kind is kind of the referent. For example "HTTPRoute" or "Service".
512 pub kind: String,
513 /// Name is the name of the referent.
514 pub name: String,
515}
516
517/// RequestHeaderModifier defines a schema for a filter that modifies request
518/// headers.
519///
520/// Support: Core
521#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
522pub struct GrpcRouteRulesBackendRefsFiltersRequestHeaderModifier {
523 /// Add adds the given header(s) (name, value) to the request
524 /// before the action. It appends to any existing values associated
525 /// with the header name.
526 ///
527 /// Input:
528 /// GET /foo HTTP/1.1
529 /// my-header: foo
530 ///
531 /// Config:
532 /// add:
533 /// - name: "my-header"
534 /// value: "bar,baz"
535 ///
536 /// Output:
537 /// GET /foo HTTP/1.1
538 /// my-header: foo,bar,baz
539 #[serde(default, skip_serializing_if = "Option::is_none")]
540 pub add: Option<Vec<GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd>>,
541 /// Remove the given header(s) from the HTTP request before the action. The
542 /// value of Remove is a list of HTTP header names. Note that the header
543 /// names are case-insensitive (see
544 /// <https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).>
545 ///
546 /// Input:
547 /// GET /foo HTTP/1.1
548 /// my-header1: foo
549 /// my-header2: bar
550 /// my-header3: baz
551 ///
552 /// Config:
553 /// remove: ["my-header1", "my-header3"]
554 ///
555 /// Output:
556 /// GET /foo HTTP/1.1
557 /// my-header2: bar
558 #[serde(default, skip_serializing_if = "Option::is_none")]
559 pub remove: Option<Vec<String>>,
560 /// Set overwrites the request with the given header (name, value)
561 /// before the action.
562 ///
563 /// Input:
564 /// GET /foo HTTP/1.1
565 /// my-header: foo
566 ///
567 /// Config:
568 /// set:
569 /// - name: "my-header"
570 /// value: "bar"
571 ///
572 /// Output:
573 /// GET /foo HTTP/1.1
574 /// my-header: bar
575 #[serde(default, skip_serializing_if = "Option::is_none")]
576 pub set: Option<Vec<GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet>>,
577}
578
579/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
580#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
581pub struct GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierAdd {
582 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
583 /// case-insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2).>
584 ///
585 /// If multiple entries specify equivalent header names, the first entry with
586 /// an equivalent name MUST be considered for a match. Subsequent entries
587 /// with an equivalent header name MUST be ignored. Due to the
588 /// case-insensitivity of header names, "foo" and "Foo" are considered
589 /// equivalent.
590 pub name: String,
591 /// Value is the value of HTTP Header to be matched.
592 pub value: String,
593}
594
595/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
596#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
597pub struct GrpcRouteRulesBackendRefsFiltersRequestHeaderModifierSet {
598 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
599 /// case-insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2).>
600 ///
601 /// If multiple entries specify equivalent header names, the first entry with
602 /// an equivalent name MUST be considered for a match. Subsequent entries
603 /// with an equivalent header name MUST be ignored. Due to the
604 /// case-insensitivity of header names, "foo" and "Foo" are considered
605 /// equivalent.
606 pub name: String,
607 /// Value is the value of HTTP Header to be matched.
608 pub value: String,
609}
610
611/// RequestMirror defines a schema for a filter that mirrors requests.
612/// Requests are sent to the specified destination, but responses from
613/// that destination are ignored.
614///
615/// This filter can be used multiple times within the same rule. Note that
616/// not all implementations will be able to support mirroring to multiple
617/// backends.
618///
619/// Support: Extended
620#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
621pub struct GrpcRouteRulesBackendRefsFiltersRequestMirror {
622 /// BackendRef references a resource where mirrored requests are sent.
623 ///
624 /// Mirrored requests must be sent only to a single destination endpoint
625 /// within this BackendRef, irrespective of how many endpoints are present
626 /// within this BackendRef.
627 ///
628 /// If the referent cannot be found, this BackendRef is invalid and must be
629 /// dropped from the Gateway. The controller must ensure the "ResolvedRefs"
630 /// condition on the Route status is set to `status: False` and not configure
631 /// this backend in the underlying implementation.
632 ///
633 /// If there is a cross-namespace reference to an *existing* object
634 /// that is not allowed by a ReferenceGrant, the controller must ensure the
635 /// "ResolvedRefs" condition on the Route is set to `status: False`,
636 /// with the "RefNotPermitted" reason and not configure this backend in the
637 /// underlying implementation.
638 ///
639 /// In either error case, the Message of the `ResolvedRefs` Condition
640 /// should be used to provide more detail about the problem.
641 ///
642 /// Support: Extended for Kubernetes Service
643 ///
644 /// Support: Implementation-specific for any other resource
645 #[serde(rename = "backendRef")]
646 pub backend_ref: GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef,
647 /// Fraction represents the fraction of requests that should be
648 /// mirrored to BackendRef.
649 ///
650 /// Only one of Fraction or Percent may be specified. If neither field
651 /// is specified, 100% of requests will be mirrored.
652 #[serde(default, skip_serializing_if = "Option::is_none")]
653 pub fraction: Option<GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction>,
654 /// Percent represents the percentage of requests that should be
655 /// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of
656 /// requests) and its maximum value is 100 (indicating 100% of requests).
657 ///
658 /// Only one of Fraction or Percent may be specified. If neither field
659 /// is specified, 100% of requests will be mirrored.
660 #[serde(default, skip_serializing_if = "Option::is_none")]
661 pub percent: Option<i32>,
662}
663
664/// BackendRef references a resource where mirrored requests are sent.
665///
666/// Mirrored requests must be sent only to a single destination endpoint
667/// within this BackendRef, irrespective of how many endpoints are present
668/// within this BackendRef.
669///
670/// If the referent cannot be found, this BackendRef is invalid and must be
671/// dropped from the Gateway. The controller must ensure the "ResolvedRefs"
672/// condition on the Route status is set to `status: False` and not configure
673/// this backend in the underlying implementation.
674///
675/// If there is a cross-namespace reference to an *existing* object
676/// that is not allowed by a ReferenceGrant, the controller must ensure the
677/// "ResolvedRefs" condition on the Route is set to `status: False`,
678/// with the "RefNotPermitted" reason and not configure this backend in the
679/// underlying implementation.
680///
681/// In either error case, the Message of the `ResolvedRefs` Condition
682/// should be used to provide more detail about the problem.
683///
684/// Support: Extended for Kubernetes Service
685///
686/// Support: Implementation-specific for any other resource
687#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
688pub struct GrpcRouteRulesBackendRefsFiltersRequestMirrorBackendRef {
689 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
690 /// When unspecified or empty string, core API group is inferred.
691 #[serde(default, skip_serializing_if = "Option::is_none")]
692 pub group: Option<String>,
693 /// Kind is the Kubernetes resource kind of the referent. For example
694 /// "Service".
695 ///
696 /// Defaults to "Service" when not specified.
697 ///
698 /// ExternalName services can refer to CNAME DNS records that may live
699 /// outside of the cluster and as such are difficult to reason about in
700 /// terms of conformance. They also may not be safe to forward to (see
701 /// CVE-2021-25740 for more information). Implementations SHOULD NOT
702 /// support ExternalName Services.
703 ///
704 /// Support: Core (Services with a type other than ExternalName)
705 ///
706 /// Support: Implementation-specific (Services with type ExternalName)
707 #[serde(default, skip_serializing_if = "Option::is_none")]
708 pub kind: Option<String>,
709 /// Name is the name of the referent.
710 pub name: String,
711 /// Namespace is the namespace of the backend. When unspecified, the local
712 /// namespace is inferred.
713 ///
714 /// Note that when a namespace different than the local namespace is specified,
715 /// a ReferenceGrant object is required in the referent namespace to allow that
716 /// namespace's owner to accept the reference. See the ReferenceGrant
717 /// documentation for details.
718 ///
719 /// Support: Core
720 #[serde(default, skip_serializing_if = "Option::is_none")]
721 pub namespace: Option<String>,
722 /// Port specifies the destination port number to use for this resource.
723 /// Port is required when the referent is a Kubernetes Service. In this
724 /// case, the port number is the service port number, not the target port.
725 /// For other resources, destination port might be derived from the referent
726 /// resource or this field.
727 #[serde(default, skip_serializing_if = "Option::is_none")]
728 pub port: Option<i32>,
729}
730
731/// Fraction represents the fraction of requests that should be
732/// mirrored to BackendRef.
733///
734/// Only one of Fraction or Percent may be specified. If neither field
735/// is specified, 100% of requests will be mirrored.
736#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
737pub struct GrpcRouteRulesBackendRefsFiltersRequestMirrorFraction {
738 #[serde(default, skip_serializing_if = "Option::is_none")]
739 pub denominator: Option<i32>,
740 pub numerator: i32,
741}
742
743/// ResponseHeaderModifier defines a schema for a filter that modifies response
744/// headers.
745///
746/// Support: Extended
747#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
748pub struct GrpcRouteRulesBackendRefsFiltersResponseHeaderModifier {
749 /// Add adds the given header(s) (name, value) to the request
750 /// before the action. It appends to any existing values associated
751 /// with the header name.
752 ///
753 /// Input:
754 /// GET /foo HTTP/1.1
755 /// my-header: foo
756 ///
757 /// Config:
758 /// add:
759 /// - name: "my-header"
760 /// value: "bar,baz"
761 ///
762 /// Output:
763 /// GET /foo HTTP/1.1
764 /// my-header: foo,bar,baz
765 #[serde(default, skip_serializing_if = "Option::is_none")]
766 pub add: Option<Vec<GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd>>,
767 /// Remove the given header(s) from the HTTP request before the action. The
768 /// value of Remove is a list of HTTP header names. Note that the header
769 /// names are case-insensitive (see
770 /// <https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).>
771 ///
772 /// Input:
773 /// GET /foo HTTP/1.1
774 /// my-header1: foo
775 /// my-header2: bar
776 /// my-header3: baz
777 ///
778 /// Config:
779 /// remove: ["my-header1", "my-header3"]
780 ///
781 /// Output:
782 /// GET /foo HTTP/1.1
783 /// my-header2: bar
784 #[serde(default, skip_serializing_if = "Option::is_none")]
785 pub remove: Option<Vec<String>>,
786 /// Set overwrites the request with the given header (name, value)
787 /// before the action.
788 ///
789 /// Input:
790 /// GET /foo HTTP/1.1
791 /// my-header: foo
792 ///
793 /// Config:
794 /// set:
795 /// - name: "my-header"
796 /// value: "bar"
797 ///
798 /// Output:
799 /// GET /foo HTTP/1.1
800 /// my-header: bar
801 #[serde(default, skip_serializing_if = "Option::is_none")]
802 pub set: Option<Vec<GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet>>,
803}
804
805/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
806#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
807pub struct GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierAdd {
808 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
809 /// case-insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2).>
810 ///
811 /// If multiple entries specify equivalent header names, the first entry with
812 /// an equivalent name MUST be considered for a match. Subsequent entries
813 /// with an equivalent header name MUST be ignored. Due to the
814 /// case-insensitivity of header names, "foo" and "Foo" are considered
815 /// equivalent.
816 pub name: String,
817 /// Value is the value of HTTP Header to be matched.
818 pub value: String,
819}
820
821/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
822#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
823pub struct GrpcRouteRulesBackendRefsFiltersResponseHeaderModifierSet {
824 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
825 /// case-insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2).>
826 ///
827 /// If multiple entries specify equivalent header names, the first entry with
828 /// an equivalent name MUST be considered for a match. Subsequent entries
829 /// with an equivalent header name MUST be ignored. Due to the
830 /// case-insensitivity of header names, "foo" and "Foo" are considered
831 /// equivalent.
832 pub name: String,
833 /// Value is the value of HTTP Header to be matched.
834 pub value: String,
835}
836
837/// GRPCRouteFilter defines processing steps that must be completed during the
838/// request or response lifecycle. GRPCRouteFilters are meant as an extension
839/// point to express processing that may be done in Gateway implementations. Some
840/// examples include request or response modification, implementing
841/// authentication strategies, rate-limiting, and traffic shaping. API
842/// guarantee/conformance is defined based on the type of the filter.
843#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
844pub enum GrpcRouteRulesBackendRefsFiltersType {
845 ResponseHeaderModifier,
846 RequestHeaderModifier,
847 RequestMirror,
848 ExtensionRef,
849}
850
851/// GRPCRouteFilter defines processing steps that must be completed during the
852/// request or response lifecycle. GRPCRouteFilters are meant as an extension
853/// point to express processing that may be done in Gateway implementations. Some
854/// examples include request or response modification, implementing
855/// authentication strategies, rate-limiting, and traffic shaping. API
856/// guarantee/conformance is defined based on the type of the filter.
857#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
858pub struct GrpcRouteRulesFilters {
859 /// ExtensionRef is an optional, implementation-specific extension to the
860 /// "filter" behavior. For example, resource "myroutefilter" in group
861 /// "networking.example.net"). ExtensionRef MUST NOT be used for core and
862 /// extended filters.
863 ///
864 /// Support: Implementation-specific
865 ///
866 /// This filter can be used multiple times within the same rule.
867 #[serde(default, skip_serializing_if = "Option::is_none", rename = "extensionRef")]
868 pub extension_ref: Option<GrpcRouteRulesFiltersExtensionRef>,
869 /// RequestHeaderModifier defines a schema for a filter that modifies request
870 /// headers.
871 ///
872 /// Support: Core
873 #[serde(default, skip_serializing_if = "Option::is_none", rename = "requestHeaderModifier")]
874 pub request_header_modifier: Option<GrpcRouteRulesFiltersRequestHeaderModifier>,
875 /// RequestMirror defines a schema for a filter that mirrors requests.
876 /// Requests are sent to the specified destination, but responses from
877 /// that destination are ignored.
878 ///
879 /// This filter can be used multiple times within the same rule. Note that
880 /// not all implementations will be able to support mirroring to multiple
881 /// backends.
882 ///
883 /// Support: Extended
884 #[serde(default, skip_serializing_if = "Option::is_none", rename = "requestMirror")]
885 pub request_mirror: Option<GrpcRouteRulesFiltersRequestMirror>,
886 /// ResponseHeaderModifier defines a schema for a filter that modifies response
887 /// headers.
888 ///
889 /// Support: Extended
890 #[serde(default, skip_serializing_if = "Option::is_none", rename = "responseHeaderModifier")]
891 pub response_header_modifier: Option<GrpcRouteRulesFiltersResponseHeaderModifier>,
892 /// Type identifies the type of filter to apply. As with other API fields,
893 /// types are classified into three conformance levels:
894 ///
895 /// - Core: Filter types and their corresponding configuration defined by
896 /// "Support: Core" in this package, e.g. "RequestHeaderModifier". All
897 /// implementations supporting GRPCRoute MUST support core filters.
898 ///
899 /// - Extended: Filter types and their corresponding configuration defined by
900 /// "Support: Extended" in this package, e.g. "RequestMirror". Implementers
901 /// are encouraged to support extended filters.
902 ///
903 /// - Implementation-specific: Filters that are defined and supported by specific vendors.
904 /// In the future, filters showing convergence in behavior across multiple
905 /// implementations will be considered for inclusion in extended or core
906 /// conformance levels. Filter-specific configuration for such filters
907 /// is specified using the ExtensionRef field. `Type` MUST be set to
908 /// "ExtensionRef" for custom filters.
909 ///
910 /// Implementers are encouraged to define custom implementation types to
911 /// extend the core API with implementation-specific behavior.
912 ///
913 /// If a reference to a custom filter type cannot be resolved, the filter
914 /// MUST NOT be skipped. Instead, requests that would have been processed by
915 /// that filter MUST receive a HTTP error response.
916 #[serde(rename = "type")]
917 pub r#type: GrpcRouteRulesFiltersType,
918}
919
920/// ExtensionRef is an optional, implementation-specific extension to the
921/// "filter" behavior. For example, resource "myroutefilter" in group
922/// "networking.example.net"). ExtensionRef MUST NOT be used for core and
923/// extended filters.
924///
925/// Support: Implementation-specific
926///
927/// This filter can be used multiple times within the same rule.
928#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
929pub struct GrpcRouteRulesFiltersExtensionRef {
930 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
931 /// When unspecified or empty string, core API group is inferred.
932 pub group: String,
933 /// Kind is kind of the referent. For example "HTTPRoute" or "Service".
934 pub kind: String,
935 /// Name is the name of the referent.
936 pub name: String,
937}
938
939/// RequestHeaderModifier defines a schema for a filter that modifies request
940/// headers.
941///
942/// Support: Core
943#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
944pub struct GrpcRouteRulesFiltersRequestHeaderModifier {
945 /// Add adds the given header(s) (name, value) to the request
946 /// before the action. It appends to any existing values associated
947 /// with the header name.
948 ///
949 /// Input:
950 /// GET /foo HTTP/1.1
951 /// my-header: foo
952 ///
953 /// Config:
954 /// add:
955 /// - name: "my-header"
956 /// value: "bar,baz"
957 ///
958 /// Output:
959 /// GET /foo HTTP/1.1
960 /// my-header: foo,bar,baz
961 #[serde(default, skip_serializing_if = "Option::is_none")]
962 pub add: Option<Vec<GrpcRouteRulesFiltersRequestHeaderModifierAdd>>,
963 /// Remove the given header(s) from the HTTP request before the action. The
964 /// value of Remove is a list of HTTP header names. Note that the header
965 /// names are case-insensitive (see
966 /// <https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).>
967 ///
968 /// Input:
969 /// GET /foo HTTP/1.1
970 /// my-header1: foo
971 /// my-header2: bar
972 /// my-header3: baz
973 ///
974 /// Config:
975 /// remove: ["my-header1", "my-header3"]
976 ///
977 /// Output:
978 /// GET /foo HTTP/1.1
979 /// my-header2: bar
980 #[serde(default, skip_serializing_if = "Option::is_none")]
981 pub remove: Option<Vec<String>>,
982 /// Set overwrites the request with the given header (name, value)
983 /// before the action.
984 ///
985 /// Input:
986 /// GET /foo HTTP/1.1
987 /// my-header: foo
988 ///
989 /// Config:
990 /// set:
991 /// - name: "my-header"
992 /// value: "bar"
993 ///
994 /// Output:
995 /// GET /foo HTTP/1.1
996 /// my-header: bar
997 #[serde(default, skip_serializing_if = "Option::is_none")]
998 pub set: Option<Vec<GrpcRouteRulesFiltersRequestHeaderModifierSet>>,
999}
1000
1001/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
1002#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1003pub struct GrpcRouteRulesFiltersRequestHeaderModifierAdd {
1004 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
1005 /// case-insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2).>
1006 ///
1007 /// If multiple entries specify equivalent header names, the first entry with
1008 /// an equivalent name MUST be considered for a match. Subsequent entries
1009 /// with an equivalent header name MUST be ignored. Due to the
1010 /// case-insensitivity of header names, "foo" and "Foo" are considered
1011 /// equivalent.
1012 pub name: String,
1013 /// Value is the value of HTTP Header to be matched.
1014 pub value: String,
1015}
1016
1017/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
1018#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1019pub struct GrpcRouteRulesFiltersRequestHeaderModifierSet {
1020 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
1021 /// case-insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2).>
1022 ///
1023 /// If multiple entries specify equivalent header names, the first entry with
1024 /// an equivalent name MUST be considered for a match. Subsequent entries
1025 /// with an equivalent header name MUST be ignored. Due to the
1026 /// case-insensitivity of header names, "foo" and "Foo" are considered
1027 /// equivalent.
1028 pub name: String,
1029 /// Value is the value of HTTP Header to be matched.
1030 pub value: String,
1031}
1032
1033/// RequestMirror defines a schema for a filter that mirrors requests.
1034/// Requests are sent to the specified destination, but responses from
1035/// that destination are ignored.
1036///
1037/// This filter can be used multiple times within the same rule. Note that
1038/// not all implementations will be able to support mirroring to multiple
1039/// backends.
1040///
1041/// Support: Extended
1042#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1043pub struct GrpcRouteRulesFiltersRequestMirror {
1044 /// BackendRef references a resource where mirrored requests are sent.
1045 ///
1046 /// Mirrored requests must be sent only to a single destination endpoint
1047 /// within this BackendRef, irrespective of how many endpoints are present
1048 /// within this BackendRef.
1049 ///
1050 /// If the referent cannot be found, this BackendRef is invalid and must be
1051 /// dropped from the Gateway. The controller must ensure the "ResolvedRefs"
1052 /// condition on the Route status is set to `status: False` and not configure
1053 /// this backend in the underlying implementation.
1054 ///
1055 /// If there is a cross-namespace reference to an *existing* object
1056 /// that is not allowed by a ReferenceGrant, the controller must ensure the
1057 /// "ResolvedRefs" condition on the Route is set to `status: False`,
1058 /// with the "RefNotPermitted" reason and not configure this backend in the
1059 /// underlying implementation.
1060 ///
1061 /// In either error case, the Message of the `ResolvedRefs` Condition
1062 /// should be used to provide more detail about the problem.
1063 ///
1064 /// Support: Extended for Kubernetes Service
1065 ///
1066 /// Support: Implementation-specific for any other resource
1067 #[serde(rename = "backendRef")]
1068 pub backend_ref: GrpcRouteRulesFiltersRequestMirrorBackendRef,
1069 /// Fraction represents the fraction of requests that should be
1070 /// mirrored to BackendRef.
1071 ///
1072 /// Only one of Fraction or Percent may be specified. If neither field
1073 /// is specified, 100% of requests will be mirrored.
1074 #[serde(default, skip_serializing_if = "Option::is_none")]
1075 pub fraction: Option<GrpcRouteRulesFiltersRequestMirrorFraction>,
1076 /// Percent represents the percentage of requests that should be
1077 /// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of
1078 /// requests) and its maximum value is 100 (indicating 100% of requests).
1079 ///
1080 /// Only one of Fraction or Percent may be specified. If neither field
1081 /// is specified, 100% of requests will be mirrored.
1082 #[serde(default, skip_serializing_if = "Option::is_none")]
1083 pub percent: Option<i32>,
1084}
1085
1086/// BackendRef references a resource where mirrored requests are sent.
1087///
1088/// Mirrored requests must be sent only to a single destination endpoint
1089/// within this BackendRef, irrespective of how many endpoints are present
1090/// within this BackendRef.
1091///
1092/// If the referent cannot be found, this BackendRef is invalid and must be
1093/// dropped from the Gateway. The controller must ensure the "ResolvedRefs"
1094/// condition on the Route status is set to `status: False` and not configure
1095/// this backend in the underlying implementation.
1096///
1097/// If there is a cross-namespace reference to an *existing* object
1098/// that is not allowed by a ReferenceGrant, the controller must ensure the
1099/// "ResolvedRefs" condition on the Route is set to `status: False`,
1100/// with the "RefNotPermitted" reason and not configure this backend in the
1101/// underlying implementation.
1102///
1103/// In either error case, the Message of the `ResolvedRefs` Condition
1104/// should be used to provide more detail about the problem.
1105///
1106/// Support: Extended for Kubernetes Service
1107///
1108/// Support: Implementation-specific for any other resource
1109#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1110pub struct GrpcRouteRulesFiltersRequestMirrorBackendRef {
1111 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
1112 /// When unspecified or empty string, core API group is inferred.
1113 #[serde(default, skip_serializing_if = "Option::is_none")]
1114 pub group: Option<String>,
1115 /// Kind is the Kubernetes resource kind of the referent. For example
1116 /// "Service".
1117 ///
1118 /// Defaults to "Service" when not specified.
1119 ///
1120 /// ExternalName services can refer to CNAME DNS records that may live
1121 /// outside of the cluster and as such are difficult to reason about in
1122 /// terms of conformance. They also may not be safe to forward to (see
1123 /// CVE-2021-25740 for more information). Implementations SHOULD NOT
1124 /// support ExternalName Services.
1125 ///
1126 /// Support: Core (Services with a type other than ExternalName)
1127 ///
1128 /// Support: Implementation-specific (Services with type ExternalName)
1129 #[serde(default, skip_serializing_if = "Option::is_none")]
1130 pub kind: Option<String>,
1131 /// Name is the name of the referent.
1132 pub name: String,
1133 /// Namespace is the namespace of the backend. When unspecified, the local
1134 /// namespace is inferred.
1135 ///
1136 /// Note that when a namespace different than the local namespace is specified,
1137 /// a ReferenceGrant object is required in the referent namespace to allow that
1138 /// namespace's owner to accept the reference. See the ReferenceGrant
1139 /// documentation for details.
1140 ///
1141 /// Support: Core
1142 #[serde(default, skip_serializing_if = "Option::is_none")]
1143 pub namespace: Option<String>,
1144 /// Port specifies the destination port number to use for this resource.
1145 /// Port is required when the referent is a Kubernetes Service. In this
1146 /// case, the port number is the service port number, not the target port.
1147 /// For other resources, destination port might be derived from the referent
1148 /// resource or this field.
1149 #[serde(default, skip_serializing_if = "Option::is_none")]
1150 pub port: Option<i32>,
1151}
1152
1153/// Fraction represents the fraction of requests that should be
1154/// mirrored to BackendRef.
1155///
1156/// Only one of Fraction or Percent may be specified. If neither field
1157/// is specified, 100% of requests will be mirrored.
1158#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1159pub struct GrpcRouteRulesFiltersRequestMirrorFraction {
1160 #[serde(default, skip_serializing_if = "Option::is_none")]
1161 pub denominator: Option<i32>,
1162 pub numerator: i32,
1163}
1164
1165/// ResponseHeaderModifier defines a schema for a filter that modifies response
1166/// headers.
1167///
1168/// Support: Extended
1169#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1170pub struct GrpcRouteRulesFiltersResponseHeaderModifier {
1171 /// Add adds the given header(s) (name, value) to the request
1172 /// before the action. It appends to any existing values associated
1173 /// with the header name.
1174 ///
1175 /// Input:
1176 /// GET /foo HTTP/1.1
1177 /// my-header: foo
1178 ///
1179 /// Config:
1180 /// add:
1181 /// - name: "my-header"
1182 /// value: "bar,baz"
1183 ///
1184 /// Output:
1185 /// GET /foo HTTP/1.1
1186 /// my-header: foo,bar,baz
1187 #[serde(default, skip_serializing_if = "Option::is_none")]
1188 pub add: Option<Vec<GrpcRouteRulesFiltersResponseHeaderModifierAdd>>,
1189 /// Remove the given header(s) from the HTTP request before the action. The
1190 /// value of Remove is a list of HTTP header names. Note that the header
1191 /// names are case-insensitive (see
1192 /// <https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).>
1193 ///
1194 /// Input:
1195 /// GET /foo HTTP/1.1
1196 /// my-header1: foo
1197 /// my-header2: bar
1198 /// my-header3: baz
1199 ///
1200 /// Config:
1201 /// remove: ["my-header1", "my-header3"]
1202 ///
1203 /// Output:
1204 /// GET /foo HTTP/1.1
1205 /// my-header2: bar
1206 #[serde(default, skip_serializing_if = "Option::is_none")]
1207 pub remove: Option<Vec<String>>,
1208 /// Set overwrites the request with the given header (name, value)
1209 /// before the action.
1210 ///
1211 /// Input:
1212 /// GET /foo HTTP/1.1
1213 /// my-header: foo
1214 ///
1215 /// Config:
1216 /// set:
1217 /// - name: "my-header"
1218 /// value: "bar"
1219 ///
1220 /// Output:
1221 /// GET /foo HTTP/1.1
1222 /// my-header: bar
1223 #[serde(default, skip_serializing_if = "Option::is_none")]
1224 pub set: Option<Vec<GrpcRouteRulesFiltersResponseHeaderModifierSet>>,
1225}
1226
1227/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
1228#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1229pub struct GrpcRouteRulesFiltersResponseHeaderModifierAdd {
1230 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
1231 /// case-insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2).>
1232 ///
1233 /// If multiple entries specify equivalent header names, the first entry with
1234 /// an equivalent name MUST be considered for a match. Subsequent entries
1235 /// with an equivalent header name MUST be ignored. Due to the
1236 /// case-insensitivity of header names, "foo" and "Foo" are considered
1237 /// equivalent.
1238 pub name: String,
1239 /// Value is the value of HTTP Header to be matched.
1240 pub value: String,
1241}
1242
1243/// HTTPHeader represents an HTTP Header name and value as defined by RFC 7230.
1244#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1245pub struct GrpcRouteRulesFiltersResponseHeaderModifierSet {
1246 /// Name is the name of the HTTP Header to be matched. Name matching MUST be
1247 /// case-insensitive. (See <https://tools.ietf.org/html/rfc7230#section-3.2).>
1248 ///
1249 /// If multiple entries specify equivalent header names, the first entry with
1250 /// an equivalent name MUST be considered for a match. Subsequent entries
1251 /// with an equivalent header name MUST be ignored. Due to the
1252 /// case-insensitivity of header names, "foo" and "Foo" are considered
1253 /// equivalent.
1254 pub name: String,
1255 /// Value is the value of HTTP Header to be matched.
1256 pub value: String,
1257}
1258
1259/// GRPCRouteFilter defines processing steps that must be completed during the
1260/// request or response lifecycle. GRPCRouteFilters are meant as an extension
1261/// point to express processing that may be done in Gateway implementations. Some
1262/// examples include request or response modification, implementing
1263/// authentication strategies, rate-limiting, and traffic shaping. API
1264/// guarantee/conformance is defined based on the type of the filter.
1265#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1266pub enum GrpcRouteRulesFiltersType {
1267 ResponseHeaderModifier,
1268 RequestHeaderModifier,
1269 RequestMirror,
1270 ExtensionRef,
1271}
1272
1273/// GRPCRouteMatch defines the predicate used to match requests to a given
1274/// action. Multiple match types are ANDed together, i.e. the match will
1275/// evaluate to true only if all conditions are satisfied.
1276///
1277/// For example, the match below will match a gRPC request only if its service
1278/// is `foo` AND it contains the `version: v1` header:
1279///
1280/// ```text
1281/// matches:
1282/// - method:
1283/// type: Exact
1284/// service: "foo"
1285/// - headers:
1286/// name: "version"
1287/// value "v1"
1288/// ```
1289#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1290pub struct GrpcRouteRulesMatches {
1291 /// Headers specifies gRPC request header matchers. Multiple match values are
1292 /// ANDed together, meaning, a request MUST match all the specified headers
1293 /// to select the route.
1294 #[serde(default, skip_serializing_if = "Option::is_none")]
1295 pub headers: Option<Vec<GrpcRouteRulesMatchesHeaders>>,
1296 /// Method specifies a gRPC request service/method matcher. If this field is
1297 /// not specified, all services and methods will match.
1298 #[serde(default, skip_serializing_if = "Option::is_none")]
1299 pub method: Option<GrpcRouteRulesMatchesMethod>,
1300}
1301
1302/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request
1303/// headers.
1304#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1305pub struct GrpcRouteRulesMatchesHeaders {
1306 /// Name is the name of the gRPC Header to be matched.
1307 ///
1308 /// If multiple entries specify equivalent header names, only the first
1309 /// entry with an equivalent name MUST be considered for a match. Subsequent
1310 /// entries with an equivalent header name MUST be ignored. Due to the
1311 /// case-insensitivity of header names, "foo" and "Foo" are considered
1312 /// equivalent.
1313 pub name: String,
1314 /// Type specifies how to match against the value of the header.
1315 #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
1316 pub r#type: Option<GrpcRouteRulesMatchesHeadersType>,
1317 /// Value is the value of the gRPC Header to be matched.
1318 pub value: String,
1319}
1320
1321/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request
1322/// headers.
1323#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1324pub enum GrpcRouteRulesMatchesHeadersType {
1325 Exact,
1326 RegularExpression,
1327}
1328
1329/// Method specifies a gRPC request service/method matcher. If this field is
1330/// not specified, all services and methods will match.
1331#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1332pub struct GrpcRouteRulesMatchesMethod {
1333 /// Value of the method to match against. If left empty or omitted, will
1334 /// match all services.
1335 ///
1336 /// At least one of Service and Method MUST be a non-empty string.
1337 #[serde(default, skip_serializing_if = "Option::is_none")]
1338 pub method: Option<String>,
1339 /// Value of the service to match against. If left empty or omitted, will
1340 /// match any service.
1341 ///
1342 /// At least one of Service and Method MUST be a non-empty string.
1343 #[serde(default, skip_serializing_if = "Option::is_none")]
1344 pub service: Option<String>,
1345 /// Type specifies how to match against the service and/or method.
1346 /// Support: Core (Exact with service and method specified)
1347 ///
1348 /// Support: Implementation-specific (Exact with method specified but no service specified)
1349 ///
1350 /// Support: Implementation-specific (RegularExpression)
1351 #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
1352 pub r#type: Option<GrpcRouteRulesMatchesMethodType>,
1353}
1354
1355/// Method specifies a gRPC request service/method matcher. If this field is
1356/// not specified, all services and methods will match.
1357#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1358pub enum GrpcRouteRulesMatchesMethodType {
1359 Exact,
1360 RegularExpression,
1361}
1362
1363/// Status defines the current state of GRPCRoute.
1364#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1365pub struct GrpcRouteStatus {
1366 /// Parents is a list of parent resources (usually Gateways) that are
1367 /// associated with the route, and the status of the route with respect to
1368 /// each parent. When this route attaches to a parent, the controller that
1369 /// manages the parent must add an entry to this list when the controller
1370 /// first sees the route and should update the entry as appropriate when the
1371 /// route or gateway is modified.
1372 ///
1373 /// Note that parent references that cannot be resolved by an implementation
1374 /// of this API will not be added to this list. Implementations of this API
1375 /// can only populate Route status for the Gateways/parent resources they are
1376 /// responsible for.
1377 ///
1378 /// A maximum of 32 Gateways will be represented in this list. An empty list
1379 /// means the route has not been attached to any Gateway.
1380 pub parents: Vec<GrpcRouteStatusParents>,
1381}
1382
1383/// RouteParentStatus describes the status of a route with respect to an
1384/// associated Parent.
1385#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1386pub struct GrpcRouteStatusParents {
1387 /// Conditions describes the status of the route with respect to the Gateway.
1388 /// Note that the route's availability is also subject to the Gateway's own
1389 /// status conditions and listener status.
1390 ///
1391 /// If the Route's ParentRef specifies an existing Gateway that supports
1392 /// Routes of this kind AND that Gateway's controller has sufficient access,
1393 /// then that Gateway's controller MUST set the "Accepted" condition on the
1394 /// Route, to indicate whether the route has been accepted or rejected by the
1395 /// Gateway, and why.
1396 ///
1397 /// A Route MUST be considered "Accepted" if at least one of the Route's
1398 /// rules is implemented by the Gateway.
1399 ///
1400 /// There are a number of cases where the "Accepted" condition may not be set
1401 /// due to lack of controller visibility, that includes when:
1402 ///
1403 /// * The Route refers to a nonexistent parent.
1404 /// * The Route is of a type that the controller does not support.
1405 /// * The Route is in a namespace to which the controller does not have access.
1406 pub conditions: Vec<Condition>,
1407 /// ControllerName is a domain/path string that indicates the name of the
1408 /// controller that wrote this status. This corresponds with the
1409 /// controllerName field on GatewayClass.
1410 ///
1411 /// Example: "example.net/gateway-controller".
1412 ///
1413 /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are
1414 /// valid Kubernetes names
1415 /// (<https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).>
1416 ///
1417 /// Controllers MUST populate this field when writing status. Controllers should ensure that
1418 /// entries to status populated with their ControllerName are cleaned up when they are no
1419 /// longer necessary.
1420 #[serde(rename = "controllerName")]
1421 pub controller_name: String,
1422 /// ParentRef corresponds with a ParentRef in the spec that this
1423 /// RouteParentStatus struct describes the status of.
1424 #[serde(rename = "parentRef")]
1425 pub parent_ref: GrpcRouteStatusParentsParentRef,
1426}
1427
1428/// ParentRef corresponds with a ParentRef in the spec that this
1429/// RouteParentStatus struct describes the status of.
1430#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
1431pub struct GrpcRouteStatusParentsParentRef {
1432 /// Group is the group of the referent.
1433 /// When unspecified, "gateway.networking.k8s.io" is inferred.
1434 /// To set the core API group (such as for a "Service" kind referent),
1435 /// Group must be explicitly set to "" (empty string).
1436 ///
1437 /// Support: Core
1438 #[serde(default, skip_serializing_if = "Option::is_none")]
1439 pub group: Option<String>,
1440 /// Kind is kind of the referent.
1441 ///
1442 /// There are two kinds of parent resources with "Core" support:
1443 ///
1444 /// * Gateway (Gateway conformance profile)
1445 /// * Service (Mesh conformance profile, ClusterIP Services only)
1446 ///
1447 /// Support for other resources is Implementation-Specific.
1448 #[serde(default, skip_serializing_if = "Option::is_none")]
1449 pub kind: Option<String>,
1450 /// Name is the name of the referent.
1451 ///
1452 /// Support: Core
1453 pub name: String,
1454 /// Namespace is the namespace of the referent. When unspecified, this refers
1455 /// to the local namespace of the Route.
1456 ///
1457 /// Note that there are specific rules for ParentRefs which cross namespace
1458 /// boundaries. Cross-namespace references are only valid if they are explicitly
1459 /// allowed by something in the namespace they are referring to. For example:
1460 /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
1461 /// generic way to enable any other kind of cross-namespace reference.
1462 ///
1463 /// Support: Core
1464 #[serde(default, skip_serializing_if = "Option::is_none")]
1465 pub namespace: Option<String>,
1466 /// Port is the network port this Route targets. It can be interpreted
1467 /// differently based on the type of parent resource.
1468 ///
1469 /// When the parent resource is a Gateway, this targets all listeners
1470 /// listening on the specified port that also support this kind of Route(and
1471 /// select this Route). It's not recommended to set `Port` unless the
1472 /// networking behaviors specified in a Route must apply to a specific port
1473 /// as opposed to a listener(s) whose port(s) may be changed. When both Port
1474 /// and SectionName are specified, the name and port of the selected listener
1475 /// must match both specified values.
1476 ///
1477 /// Implementations MAY choose to support other parent resources.
1478 /// Implementations supporting other types of parent resources MUST clearly
1479 /// document how/if Port is interpreted.
1480 ///
1481 /// For the purpose of status, an attachment is considered successful as
1482 /// long as the parent resource accepts it partially. For example, Gateway
1483 /// listeners can restrict which Routes can attach to them by Route kind,
1484 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment
1485 /// from the referencing Route, the Route MUST be considered successfully
1486 /// attached. If no Gateway listeners accept attachment from this Route,
1487 /// the Route MUST be considered detached from the Gateway.
1488 ///
1489 /// Support: Extended
1490 #[serde(default, skip_serializing_if = "Option::is_none")]
1491 pub port: Option<i32>,
1492 /// SectionName is the name of a section within the target resource. In the
1493 /// following resources, SectionName is interpreted as the following:
1494 ///
1495 /// * Gateway: Listener name. When both Port (experimental) and SectionName
1496 /// are specified, the name and port of the selected listener must match
1497 /// both specified values.
1498 /// * Service: Port name. When both Port (experimental) and SectionName
1499 /// are specified, the name and port of the selected listener must match
1500 /// both specified values.
1501 ///
1502 /// Implementations MAY choose to support attaching Routes to other resources.
1503 /// If that is the case, they MUST clearly document how SectionName is
1504 /// interpreted.
1505 ///
1506 /// When unspecified (empty string), this will reference the entire resource.
1507 /// For the purpose of status, an attachment is considered successful if at
1508 /// least one section in the parent resource accepts it. For example, Gateway
1509 /// listeners can restrict which Routes can attach to them by Route kind,
1510 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from
1511 /// the referencing Route, the Route MUST be considered successfully
1512 /// attached. If no Gateway listeners accept attachment from this Route, the
1513 /// Route MUST be considered detached from the Gateway.
1514 ///
1515 /// Support: Core
1516 #[serde(default, skip_serializing_if = "Option::is_none", rename = "sectionName")]
1517 pub section_name: Option<String>,
1518}