gateway_api/apis/experimental/
udproutes.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 UDPRoute.
15#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
16#[kube(
17    group = "gateway.networking.k8s.io",
18    version = "v1alpha2",
19    kind = "UDPRoute",
20    plural = "udproutes"
21)]
22#[kube(namespaced)]
23#[kube(status = "UDPRouteStatus")]
24#[kube(derive = "Default")]
25#[kube(derive = "PartialEq")]
26pub struct UDPRouteSpec {
27    /// ParentRefs references the resources (usually Gateways) that a Route wants
28    /// to be attached to. Note that the referenced parent resource needs to
29    /// allow this for the attachment to be complete. For Gateways, that means
30    /// the Gateway needs to allow attachment from Routes of this kind and
31    /// namespace. For Services, that means the Service must either be in the same
32    /// namespace for a "producer" route, or the mesh implementation must support
33    /// and allow "consumer" routes for the referenced Service. ReferenceGrant is
34    /// not applicable for governing ParentRefs to Services - it is not possible to
35    /// create a "producer" route for a Service in a different namespace from the
36    /// Route.
37    ///
38    /// There are two kinds of parent resources with "Core" support:
39    ///
40    /// * Gateway (Gateway conformance profile)
41    /// * Service (Mesh conformance profile, ClusterIP Services only)
42    ///
43    /// This API may be extended in the future to support additional kinds of parent
44    /// resources.
45    ///
46    /// ParentRefs must be _distinct_. This means either that:
47    ///
48    /// * They select different objects.  If this is the case, then parentRef
49    ///   entries are distinct. In terms of fields, this means that the
50    ///   multi-part key defined by `group`, `kind`, `namespace`, and `name` must
51    ///   be unique across all parentRef entries in the Route.
52    /// * They do not select different objects, but for each optional field used,
53    ///   each ParentRef that selects the same object must set the same set of
54    ///   optional fields to different values. If one ParentRef sets a
55    ///   combination of optional fields, all must set the same combination.
56    ///
57    /// Some examples:
58    ///
59    /// * If one ParentRef sets `sectionName`, all ParentRefs referencing the
60    ///   same object must also set `sectionName`.
61    /// * If one ParentRef sets `port`, all ParentRefs referencing the same
62    ///   object must also set `port`.
63    /// * If one ParentRef sets `sectionName` and `port`, all ParentRefs
64    ///   referencing the same object must also set `sectionName` and `port`.
65    ///
66    /// It is possible to separately reference multiple distinct objects that may
67    /// be collapsed by an implementation. For example, some implementations may
68    /// choose to merge compatible Gateway Listeners together. If that is the
69    /// case, the list of routes attached to those resources should also be
70    /// merged.
71    ///
72    /// Note that for ParentRefs that cross namespace boundaries, there are specific
73    /// rules. Cross-namespace references are only valid if they are explicitly
74    /// allowed by something in the namespace they are referring to. For example,
75    /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
76    /// generic way to enable other kinds of cross-namespace reference.
77    ///
78    ///
79    /// ParentRefs from a Route to a Service in the same namespace are "producer"
80    /// routes, which apply default routing rules to inbound connections from
81    /// any namespace to the Service.
82    ///
83    /// ParentRefs from a Route to a Service in a different namespace are
84    /// "consumer" routes, and these routing rules are only applied to outbound
85    /// connections originating from the same namespace as the Route, for which
86    /// the intended destination of the connections are a Service targeted as a
87    /// ParentRef of the Route.
88    #[serde(
89        default,
90        skip_serializing_if = "Option::is_none",
91        rename = "parentRefs"
92    )]
93    pub parent_refs: Option<Vec<UDPRouteParentRefs>>,
94    /// Rules are a list of UDP matchers and actions.
95    pub rules: Vec<UDPRouteRules>,
96    /// UseDefaultGateways indicates the default Gateway scope to use for this
97    /// Route. If unset (the default) or set to None, the Route will not be
98    /// attached to any default Gateway; if set, it will be attached to any
99    /// default Gateway supporting the named scope, subject to the usual rules
100    /// about which Routes a Gateway is allowed to claim.
101    ///
102    /// Think carefully before using this functionality! The set of default
103    /// Gateways supporting the requested scope can change over time without
104    /// any notice to the Route author, and in many situations it will not be
105    /// appropriate to request a default Gateway for a given Route -- for
106    /// example, a Route with specific security requirements should almost
107    /// certainly not use a default Gateway.
108    #[serde(
109        default,
110        skip_serializing_if = "Option::is_none",
111        rename = "useDefaultGateways"
112    )]
113    pub use_default_gateways: Option<UDPRouteUseDefaultGateways>,
114}
115
116/// ParentReference identifies an API object (usually a Gateway) that can be considered
117/// a parent of this resource (usually a route). There are two kinds of parent resources
118/// with "Core" support:
119///
120/// * Gateway (Gateway conformance profile)
121/// * Service (Mesh conformance profile, ClusterIP Services only)
122///
123/// This API may be extended in the future to support additional kinds of parent
124/// resources.
125///
126/// The API object must be valid in the cluster; the Group and Kind must
127/// be registered in the cluster for this reference to be valid.
128#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
129pub struct UDPRouteParentRefs {
130    /// Group is the group of the referent.
131    /// When unspecified, "gateway.networking.k8s.io" is inferred.
132    /// To set the core API group (such as for a "Service" kind referent),
133    /// Group must be explicitly set to "" (empty string).
134    ///
135    /// Support: Core
136    #[serde(default, skip_serializing_if = "Option::is_none")]
137    pub group: Option<String>,
138    /// Kind is kind of the referent.
139    ///
140    /// There are two kinds of parent resources with "Core" support:
141    ///
142    /// * Gateway (Gateway conformance profile)
143    /// * Service (Mesh conformance profile, ClusterIP Services only)
144    ///
145    /// Support for other resources is Implementation-Specific.
146    #[serde(default, skip_serializing_if = "Option::is_none")]
147    pub kind: Option<String>,
148    /// Name is the name of the referent.
149    ///
150    /// Support: Core
151    pub name: String,
152    /// Namespace is the namespace of the referent. When unspecified, this refers
153    /// to the local namespace of the Route.
154    ///
155    /// Note that there are specific rules for ParentRefs which cross namespace
156    /// boundaries. Cross-namespace references are only valid if they are explicitly
157    /// allowed by something in the namespace they are referring to. For example:
158    /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
159    /// generic way to enable any other kind of cross-namespace reference.
160    ///
161    ///
162    /// ParentRefs from a Route to a Service in the same namespace are "producer"
163    /// routes, which apply default routing rules to inbound connections from
164    /// any namespace to the Service.
165    ///
166    /// ParentRefs from a Route to a Service in a different namespace are
167    /// "consumer" routes, and these routing rules are only applied to outbound
168    /// connections originating from the same namespace as the Route, for which
169    /// the intended destination of the connections are a Service targeted as a
170    /// ParentRef of the Route.
171    ///
172    ///
173    /// Support: Core
174    #[serde(default, skip_serializing_if = "Option::is_none")]
175    pub namespace: Option<String>,
176    /// Port is the network port this Route targets. It can be interpreted
177    /// differently based on the type of parent resource.
178    ///
179    /// When the parent resource is a Gateway, this targets all listeners
180    /// listening on the specified port that also support this kind of Route(and
181    /// select this Route). It's not recommended to set `Port` unless the
182    /// networking behaviors specified in a Route must apply to a specific port
183    /// as opposed to a listener(s) whose port(s) may be changed. When both Port
184    /// and SectionName are specified, the name and port of the selected listener
185    /// must match both specified values.
186    ///
187    ///
188    /// When the parent resource is a Service, this targets a specific port in the
189    /// Service spec. When both Port (experimental) and SectionName are specified,
190    /// the name and port of the selected port must match both specified values.
191    ///
192    ///
193    /// Implementations MAY choose to support other parent resources.
194    /// Implementations supporting other types of parent resources MUST clearly
195    /// document how/if Port is interpreted.
196    ///
197    /// For the purpose of status, an attachment is considered successful as
198    /// long as the parent resource accepts it partially. For example, Gateway
199    /// listeners can restrict which Routes can attach to them by Route kind,
200    /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment
201    /// from the referencing Route, the Route MUST be considered successfully
202    /// attached. If no Gateway listeners accept attachment from this Route,
203    /// the Route MUST be considered detached from the Gateway.
204    ///
205    /// Support: Extended
206    #[serde(default, skip_serializing_if = "Option::is_none")]
207    pub port: Option<i32>,
208    /// SectionName is the name of a section within the target resource. In the
209    /// following resources, SectionName is interpreted as the following:
210    ///
211    /// * Gateway: Listener name. When both Port (experimental) and SectionName
212    /// are specified, the name and port of the selected listener must match
213    /// both specified values.
214    /// * Service: Port name. When both Port (experimental) and SectionName
215    /// are specified, the name and port of the selected listener must match
216    /// both specified values.
217    ///
218    /// Implementations MAY choose to support attaching Routes to other resources.
219    /// If that is the case, they MUST clearly document how SectionName is
220    /// interpreted.
221    ///
222    /// When unspecified (empty string), this will reference the entire resource.
223    /// For the purpose of status, an attachment is considered successful if at
224    /// least one section in the parent resource accepts it. For example, Gateway
225    /// listeners can restrict which Routes can attach to them by Route kind,
226    /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from
227    /// the referencing Route, the Route MUST be considered successfully
228    /// attached. If no Gateway listeners accept attachment from this Route, the
229    /// Route MUST be considered detached from the Gateway.
230    ///
231    /// Support: Core
232    #[serde(
233        default,
234        skip_serializing_if = "Option::is_none",
235        rename = "sectionName"
236    )]
237    pub section_name: Option<String>,
238}
239
240/// UDPRouteRule is the configuration for a given rule.
241#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
242pub struct UDPRouteRules {
243    /// BackendRefs defines the backend(s) where matching requests should be
244    /// sent. If unspecified or invalid (refers to a nonexistent resource or a
245    /// Service with no endpoints), the underlying implementation MUST actively
246    /// reject connection attempts to this backend. Packet drops must
247    /// respect weight; if an invalid backend is requested to have 80% of
248    /// the packets, then 80% of packets must be dropped instead.
249    ///
250    /// Support: Core for Kubernetes Service
251    ///
252    /// Support: Extended for Kubernetes ServiceImport
253    ///
254    /// Support: Implementation-specific for any other resource
255    ///
256    /// Support for weight: Extended
257    #[serde(rename = "backendRefs")]
258    pub backend_refs: Vec<UDPRouteRulesBackendRefs>,
259    /// Name is the name of the route rule. This name MUST be unique within a Route if it is set.
260    ///
261    /// Support: Extended
262    #[serde(default, skip_serializing_if = "Option::is_none")]
263    pub name: Option<String>,
264}
265
266/// BackendRef defines how a Route should forward a request to a Kubernetes
267/// resource.
268///
269/// Note that when a namespace different than the local namespace is specified, a
270/// ReferenceGrant object is required in the referent namespace to allow that
271/// namespace's owner to accept the reference. See the ReferenceGrant
272/// documentation for details.
273///
274///
275/// When the BackendRef points to a Kubernetes Service, implementations SHOULD
276/// honor the appProtocol field if it is set for the target Service Port.
277///
278/// Implementations supporting appProtocol SHOULD recognize the Kubernetes
279/// Standard Application Protocols defined in KEP-3726.
280///
281/// If a Service appProtocol isn't specified, an implementation MAY infer the
282/// backend protocol through its own means. Implementations MAY infer the
283/// protocol from the Route type referring to the backend Service.
284///
285/// If a Route is not able to send traffic to the backend using the specified
286/// protocol then the backend is considered invalid. Implementations MUST set the
287/// "ResolvedRefs" condition to "False" with the "UnsupportedProtocol" reason.
288///
289///
290/// Note that when the BackendTLSPolicy object is enabled by the implementation,
291/// there are some extra rules about validity to consider here. See the fields
292/// where this struct is used for more information about the exact behavior.
293#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
294pub struct UDPRouteRulesBackendRefs {
295    /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
296    /// When unspecified or empty string, core API group is inferred.
297    #[serde(default, skip_serializing_if = "Option::is_none")]
298    pub group: Option<String>,
299    /// Kind is the Kubernetes resource kind of the referent. For example
300    /// "Service".
301    ///
302    /// Defaults to "Service" when not specified.
303    ///
304    /// ExternalName services can refer to CNAME DNS records that may live
305    /// outside of the cluster and as such are difficult to reason about in
306    /// terms of conformance. They also may not be safe to forward to (see
307    /// CVE-2021-25740 for more information). Implementations SHOULD NOT
308    /// support ExternalName Services.
309    ///
310    /// Support: Core (Services with a type other than ExternalName)
311    ///
312    /// Support: Implementation-specific (Services with type ExternalName)
313    #[serde(default, skip_serializing_if = "Option::is_none")]
314    pub kind: Option<String>,
315    /// Name is the name of the referent.
316    pub name: String,
317    /// Namespace is the namespace of the backend. When unspecified, the local
318    /// namespace is inferred.
319    ///
320    /// Note that when a namespace different than the local namespace is specified,
321    /// a ReferenceGrant object is required in the referent namespace to allow that
322    /// namespace's owner to accept the reference. See the ReferenceGrant
323    /// documentation for details.
324    ///
325    /// Support: Core
326    #[serde(default, skip_serializing_if = "Option::is_none")]
327    pub namespace: Option<String>,
328    /// Port specifies the destination port number to use for this resource.
329    /// Port is required when the referent is a Kubernetes Service. In this
330    /// case, the port number is the service port number, not the target port.
331    /// For other resources, destination port might be derived from the referent
332    /// resource or this field.
333    #[serde(default, skip_serializing_if = "Option::is_none")]
334    pub port: Option<i32>,
335    /// Weight specifies the proportion of requests forwarded to the referenced
336    /// backend. This is computed as weight/(sum of all weights in this
337    /// BackendRefs list). For non-zero values, there may be some epsilon from
338    /// the exact proportion defined here depending on the precision an
339    /// implementation supports. Weight is not a percentage and the sum of
340    /// weights does not need to equal 100.
341    ///
342    /// If only one backend is specified and it has a weight greater than 0, 100%
343    /// of the traffic is forwarded to that backend. If weight is set to 0, no
344    /// traffic should be forwarded for this entry. If unspecified, weight
345    /// defaults to 1.
346    ///
347    /// Support for this field varies based on the context where used.
348    #[serde(default, skip_serializing_if = "Option::is_none")]
349    pub weight: Option<i32>,
350}
351
352/// Spec defines the desired state of UDPRoute.
353#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
354pub enum UDPRouteUseDefaultGateways {
355    All,
356    None,
357}
358
359/// Status defines the current state of UDPRoute.
360#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
361pub struct UDPRouteStatus {
362    /// Parents is a list of parent resources (usually Gateways) that are
363    /// associated with the route, and the status of the route with respect to
364    /// each parent. When this route attaches to a parent, the controller that
365    /// manages the parent must add an entry to this list when the controller
366    /// first sees the route and should update the entry as appropriate when the
367    /// route or gateway is modified.
368    ///
369    /// Note that parent references that cannot be resolved by an implementation
370    /// of this API will not be added to this list. Implementations of this API
371    /// can only populate Route status for the Gateways/parent resources they are
372    /// responsible for.
373    ///
374    /// A maximum of 32 Gateways will be represented in this list. An empty list
375    /// means the route has not been attached to any Gateway.
376    pub parents: Vec<UDPRouteStatusParents>,
377}
378
379/// RouteParentStatus describes the status of a route with respect to an
380/// associated Parent.
381#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
382pub struct UDPRouteStatusParents {
383    /// Conditions describes the status of the route with respect to the Gateway.
384    /// Note that the route's availability is also subject to the Gateway's own
385    /// status conditions and listener status.
386    ///
387    /// If the Route's ParentRef specifies an existing Gateway that supports
388    /// Routes of this kind AND that Gateway's controller has sufficient access,
389    /// then that Gateway's controller MUST set the "Accepted" condition on the
390    /// Route, to indicate whether the route has been accepted or rejected by the
391    /// Gateway, and why.
392    ///
393    /// A Route MUST be considered "Accepted" if at least one of the Route's
394    /// rules is implemented by the Gateway.
395    ///
396    /// There are a number of cases where the "Accepted" condition may not be set
397    /// due to lack of controller visibility, that includes when:
398    ///
399    /// * The Route refers to a nonexistent parent.
400    /// * The Route is of a type that the controller does not support.
401    /// * The Route is in a namespace the controller does not have access to.
402    pub conditions: Vec<Condition>,
403    /// ControllerName is a domain/path string that indicates the name of the
404    /// controller that wrote this status. This corresponds with the
405    /// controllerName field on GatewayClass.
406    ///
407    /// Example: "example.net/gateway-controller".
408    ///
409    /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are
410    /// valid Kubernetes names
411    /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).
412    ///
413    /// Controllers MUST populate this field when writing status. Controllers should ensure that
414    /// entries to status populated with their ControllerName are cleaned up when they are no
415    /// longer necessary.
416    #[serde(rename = "controllerName")]
417    pub controller_name: String,
418    /// ParentRef corresponds with a ParentRef in the spec that this
419    /// RouteParentStatus struct describes the status of.
420    #[serde(rename = "parentRef")]
421    pub parent_ref: UDPRouteStatusParentsParentRef,
422}
423
424/// ParentRef corresponds with a ParentRef in the spec that this
425/// RouteParentStatus struct describes the status of.
426#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
427pub struct UDPRouteStatusParentsParentRef {
428    /// Group is the group of the referent.
429    /// When unspecified, "gateway.networking.k8s.io" is inferred.
430    /// To set the core API group (such as for a "Service" kind referent),
431    /// Group must be explicitly set to "" (empty string).
432    ///
433    /// Support: Core
434    #[serde(default, skip_serializing_if = "Option::is_none")]
435    pub group: Option<String>,
436    /// Kind is kind of the referent.
437    ///
438    /// There are two kinds of parent resources with "Core" support:
439    ///
440    /// * Gateway (Gateway conformance profile)
441    /// * Service (Mesh conformance profile, ClusterIP Services only)
442    ///
443    /// Support for other resources is Implementation-Specific.
444    #[serde(default, skip_serializing_if = "Option::is_none")]
445    pub kind: Option<String>,
446    /// Name is the name of the referent.
447    ///
448    /// Support: Core
449    pub name: String,
450    /// Namespace is the namespace of the referent. When unspecified, this refers
451    /// to the local namespace of the Route.
452    ///
453    /// Note that there are specific rules for ParentRefs which cross namespace
454    /// boundaries. Cross-namespace references are only valid if they are explicitly
455    /// allowed by something in the namespace they are referring to. For example:
456    /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
457    /// generic way to enable any other kind of cross-namespace reference.
458    ///
459    ///
460    /// ParentRefs from a Route to a Service in the same namespace are "producer"
461    /// routes, which apply default routing rules to inbound connections from
462    /// any namespace to the Service.
463    ///
464    /// ParentRefs from a Route to a Service in a different namespace are
465    /// "consumer" routes, and these routing rules are only applied to outbound
466    /// connections originating from the same namespace as the Route, for which
467    /// the intended destination of the connections are a Service targeted as a
468    /// ParentRef of the Route.
469    ///
470    ///
471    /// Support: Core
472    #[serde(default, skip_serializing_if = "Option::is_none")]
473    pub namespace: Option<String>,
474    /// Port is the network port this Route targets. It can be interpreted
475    /// differently based on the type of parent resource.
476    ///
477    /// When the parent resource is a Gateway, this targets all listeners
478    /// listening on the specified port that also support this kind of Route(and
479    /// select this Route). It's not recommended to set `Port` unless the
480    /// networking behaviors specified in a Route must apply to a specific port
481    /// as opposed to a listener(s) whose port(s) may be changed. When both Port
482    /// and SectionName are specified, the name and port of the selected listener
483    /// must match both specified values.
484    ///
485    ///
486    /// When the parent resource is a Service, this targets a specific port in the
487    /// Service spec. When both Port (experimental) and SectionName are specified,
488    /// the name and port of the selected port must match both specified values.
489    ///
490    ///
491    /// Implementations MAY choose to support other parent resources.
492    /// Implementations supporting other types of parent resources MUST clearly
493    /// document how/if Port is interpreted.
494    ///
495    /// For the purpose of status, an attachment is considered successful as
496    /// long as the parent resource accepts it partially. For example, Gateway
497    /// listeners can restrict which Routes can attach to them by Route kind,
498    /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment
499    /// from the referencing Route, the Route MUST be considered successfully
500    /// attached. If no Gateway listeners accept attachment from this Route,
501    /// the Route MUST be considered detached from the Gateway.
502    ///
503    /// Support: Extended
504    #[serde(default, skip_serializing_if = "Option::is_none")]
505    pub port: Option<i32>,
506    /// SectionName is the name of a section within the target resource. In the
507    /// following resources, SectionName is interpreted as the following:
508    ///
509    /// * Gateway: Listener name. When both Port (experimental) and SectionName
510    /// are specified, the name and port of the selected listener must match
511    /// both specified values.
512    /// * Service: Port name. When both Port (experimental) and SectionName
513    /// are specified, the name and port of the selected listener must match
514    /// both specified values.
515    ///
516    /// Implementations MAY choose to support attaching Routes to other resources.
517    /// If that is the case, they MUST clearly document how SectionName is
518    /// interpreted.
519    ///
520    /// When unspecified (empty string), this will reference the entire resource.
521    /// For the purpose of status, an attachment is considered successful if at
522    /// least one section in the parent resource accepts it. For example, Gateway
523    /// listeners can restrict which Routes can attach to them by Route kind,
524    /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from
525    /// the referencing Route, the Route MUST be considered successfully
526    /// attached. If no Gateway listeners accept attachment from this Route, the
527    /// Route MUST be considered detached from the Gateway.
528    ///
529    /// Support: Core
530    #[serde(
531        default,
532        skip_serializing_if = "Option::is_none",
533        rename = "sectionName"
534    )]
535    pub section_name: Option<String>,
536}