gateway_api/apis/standard/backendtlspolicies.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 pub use std::collections::BTreeMap;
12}
13use self::prelude::*;
14
15/// Spec defines the desired state of BackendTLSPolicy.
16#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
17#[kube(
18 group = "gateway.networking.k8s.io",
19 version = "v1",
20 kind = "BackendTLSPolicy",
21 plural = "backendtlspolicies"
22)]
23#[kube(namespaced)]
24#[kube(status = "BackendTLSPolicyStatus")]
25#[kube(derive = "Default")]
26#[kube(derive = "PartialEq")]
27pub struct BackendTLSPolicySpec {
28 /// Options are a list of key/value pairs to enable extended TLS
29 /// configuration for each implementation. For example, configuring the
30 /// minimum TLS version or supported cipher suites.
31 ///
32 /// A set of common keys MAY be defined by the API in the future. To avoid
33 /// any ambiguity, implementation-specific definitions MUST use
34 /// domain-prefixed names, such as `example.com/my-custom-option`.
35 /// Un-prefixed names are reserved for key names defined by Gateway API.
36 ///
37 /// Support: Implementation-specific
38 #[serde(default, skip_serializing_if = "Option::is_none")]
39 pub options: Option<BTreeMap<String, String>>,
40 /// TargetRefs identifies an API object to apply the policy to.
41 /// Only Services have Extended support. Implementations MAY support
42 /// additional objects, with Implementation Specific support.
43 /// Note that this config applies to the entire referenced resource
44 /// by default, but this default may change in the future to provide
45 /// a more granular application of the policy.
46 ///
47 /// TargetRefs must be _distinct_. This means either that:
48 ///
49 /// * They select different targets. If this is the case, then targetRef
50 /// entries are distinct. In terms of fields, this means that the
51 /// multi-part key defined by `group`, `kind`, and `name` must
52 /// be unique across all targetRef entries in the BackendTLSPolicy.
53 /// * They select different sectionNames in the same target.
54 ///
55 /// When more than one BackendTLSPolicy selects the same target and
56 /// sectionName, implementations MUST determine precedence using the
57 /// following criteria, continuing on ties:
58 ///
59 /// * The older policy by creation timestamp takes precedence. For
60 /// example, a policy with a creation timestamp of "2021-07-15
61 /// 01:02:03" MUST be given precedence over a policy with a
62 /// creation timestamp of "2021-07-15 01:02:04".
63 /// * The policy appearing first in alphabetical order by {name}.
64 /// For example, a policy named `bar` is given precedence over a
65 /// policy named `baz`.
66 ///
67 /// For any BackendTLSPolicy that does not take precedence, the
68 /// implementation MUST ensure the `Accepted` Condition is set to
69 /// `status: False`, with Reason `Conflicted`.
70 ///
71 /// Support: Extended for Kubernetes Service
72 ///
73 /// Support: Implementation-specific for any other resource
74 #[serde(rename = "targetRefs")]
75 pub target_refs: Vec<BackendTLSPolicyTargetRefs>,
76 /// Validation contains backend TLS validation configuration.
77 pub validation: BackendTLSPolicyValidation,
78}
79
80/// LocalPolicyTargetReferenceWithSectionName identifies an API object to apply a
81/// direct policy to. This should be used as part of Policy resources that can
82/// target single resources. For more information on how this policy attachment
83/// mode works, and a sample Policy resource, refer to the policy attachment
84/// documentation for Gateway API.
85///
86/// Note: This should only be used for direct policy attachment when references
87/// to SectionName are actually needed. In all other cases,
88/// LocalPolicyTargetReference should be used.
89#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
90pub struct BackendTLSPolicyTargetRefs {
91 /// Group is the group of the target resource.
92 pub group: String,
93 /// Kind is kind of the target resource.
94 pub kind: String,
95 /// Name is the name of the target resource.
96 pub name: String,
97 /// SectionName is the name of a section within the target resource. When
98 /// unspecified, this targetRef targets the entire resource. In the following
99 /// resources, SectionName is interpreted as the following:
100 ///
101 /// * Gateway: Listener name
102 /// * HTTPRoute: HTTPRouteRule name
103 /// * Service: Port name
104 ///
105 /// If a SectionName is specified, but does not exist on the targeted object,
106 /// the Policy must fail to attach, and the policy implementation should record
107 /// a `ResolvedRefs` or similar Condition in the Policy's status.
108 #[serde(
109 default,
110 skip_serializing_if = "Option::is_none",
111 rename = "sectionName"
112 )]
113 pub section_name: Option<String>,
114}
115
116/// Validation contains backend TLS validation configuration.
117#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
118pub struct BackendTLSPolicyValidation {
119 /// CACertificateRefs contains one or more references to Kubernetes objects that
120 /// contain a PEM-encoded TLS CA certificate bundle, which is used to
121 /// validate a TLS handshake between the Gateway and backend Pod.
122 ///
123 /// If CACertificateRefs is empty or unspecified, then WellKnownCACertificates must be
124 /// specified. Only one of CACertificateRefs or WellKnownCACertificates may be specified,
125 /// not both. If CACertificateRefs is empty or unspecified, the configuration for
126 /// WellKnownCACertificates MUST be honored instead if supported by the implementation.
127 ///
128 /// A CACertificateRef is invalid if:
129 ///
130 /// * It refers to a resource that cannot be resolved (e.g., the referenced resource
131 /// does not exist) or is misconfigured (e.g., a ConfigMap does not contain a key
132 /// named `ca.crt`). In this case, the Reason must be set to `InvalidCACertificateRef`
133 /// and the Message of the Condition must indicate which reference is invalid and why.
134 ///
135 /// * It refers to an unknown or unsupported kind of resource. In this case, the Reason
136 /// must be set to `InvalidKind` and the Message of the Condition must explain which
137 /// kind of resource is unknown or unsupported.
138 ///
139 /// * It refers to a resource in another namespace. This may change in future
140 /// spec updates.
141 ///
142 /// Implementations MAY choose to perform further validation of the certificate
143 /// content (e.g., checking expiry or enforcing specific formats). In such cases,
144 /// an implementation-specific Reason and Message must be set for the invalid reference.
145 ///
146 /// In all cases, the implementation MUST ensure the `ResolvedRefs` Condition on
147 /// the BackendTLSPolicy is set to `status: False`, with a Reason and Message
148 /// that indicate the cause of the error. Connections using an invalid
149 /// CACertificateRef MUST fail, and the client MUST receive an HTTP 5xx error
150 /// response. If ALL CACertificateRefs are invalid, the implementation MUST also
151 /// ensure the `Accepted` Condition on the BackendTLSPolicy is set to
152 /// `status: False`, with a Reason `NoValidCACertificate`.
153 ///
154 /// A single CACertificateRef to a Kubernetes ConfigMap kind has "Core" support.
155 /// Implementations MAY choose to support attaching multiple certificates to
156 /// a backend, but this behavior is implementation-specific.
157 ///
158 /// Support: Core - An optional single reference to a Kubernetes ConfigMap,
159 /// with the CA certificate in a key named `ca.crt`.
160 ///
161 /// Support: Implementation-specific - More than one reference, other kinds
162 /// of resources, or a single reference that includes multiple certificates.
163 #[serde(
164 default,
165 skip_serializing_if = "Option::is_none",
166 rename = "caCertificateRefs"
167 )]
168 pub ca_certificate_refs: Option<Vec<BackendTLSPolicyValidationCaCertificateRefs>>,
169 /// Hostname is used for two purposes in the connection between Gateways and
170 /// backends:
171 ///
172 /// 1. Hostname MUST be used as the SNI to connect to the backend (RFC 6066).
173 /// 2. Hostname MUST be used for authentication and MUST match the certificate
174 /// served by the matching backend, unless SubjectAltNames is specified.
175 /// 3. If SubjectAltNames are specified, Hostname can be used for certificate selection
176 /// but MUST NOT be used for authentication. If you want to use the value
177 /// of the Hostname field for authentication, you MUST add it to the SubjectAltNames list.
178 ///
179 /// Support: Core
180 pub hostname: String,
181 /// SubjectAltNames contains one or more Subject Alternative Names.
182 /// When specified the certificate served from the backend MUST
183 /// have at least one Subject Alternate Name matching one of the specified SubjectAltNames.
184 ///
185 /// Support: Extended
186 #[serde(
187 default,
188 skip_serializing_if = "Option::is_none",
189 rename = "subjectAltNames"
190 )]
191 pub subject_alt_names: Option<Vec<BackendTLSPolicyValidationSubjectAltNames>>,
192 /// WellKnownCACertificates specifies whether system CA certificates may be used in
193 /// the TLS handshake between the gateway and backend pod.
194 ///
195 /// If WellKnownCACertificates is unspecified or empty (""), then CACertificateRefs
196 /// must be specified with at least one entry for a valid configuration. Only one of
197 /// CACertificateRefs or WellKnownCACertificates may be specified, not both.
198 /// If an implementation does not support the WellKnownCACertificates field, or
199 /// the supplied value is not recognized, the implementation MUST ensure the
200 /// `Accepted` Condition on the BackendTLSPolicy is set to `status: False`, with
201 /// a Reason `Invalid`.
202 ///
203 /// Support: Implementation-specific
204 #[serde(
205 default,
206 skip_serializing_if = "Option::is_none",
207 rename = "wellKnownCACertificates"
208 )]
209 pub well_known_ca_certificates: Option<BackendTLSPolicyValidationWellKnownCaCertificates>,
210}
211
212/// LocalObjectReference identifies an API object within the namespace of the
213/// referrer.
214/// The API object must be valid in the cluster; the Group and Kind must
215/// be registered in the cluster for this reference to be valid.
216///
217/// References to objects with invalid Group and Kind are not valid, and must
218/// be rejected by the implementation, with appropriate Conditions set
219/// on the containing object.
220#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
221pub struct BackendTLSPolicyValidationCaCertificateRefs {
222 /// Group is the group of the referent. For example, "gateway.networking.k8s.io".
223 /// When unspecified or empty string, core API group is inferred.
224 pub group: String,
225 /// Kind is kind of the referent. For example "HTTPRoute" or "Service".
226 pub kind: String,
227 /// Name is the name of the referent.
228 pub name: String,
229}
230
231/// SubjectAltName represents Subject Alternative Name.
232#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
233pub struct BackendTLSPolicyValidationSubjectAltNames {
234 /// Hostname contains Subject Alternative Name specified in DNS name format.
235 /// Required when Type is set to Hostname, ignored otherwise.
236 ///
237 /// Support: Core
238 #[serde(default, skip_serializing_if = "Option::is_none")]
239 pub hostname: Option<String>,
240 /// Type determines the format of the Subject Alternative Name. Always required.
241 ///
242 /// Support: Core
243 #[serde(rename = "type")]
244 pub r#type: BackendTLSPolicyValidationSubjectAltNamesType,
245 /// URI contains Subject Alternative Name specified in a full URI format.
246 /// It MUST include both a scheme (e.g., "http" or "ftp") and a scheme-specific-part.
247 /// Common values include SPIFFE IDs like "spiffe://mycluster.example.com/ns/myns/sa/svc1sa".
248 /// Required when Type is set to URI, ignored otherwise.
249 ///
250 /// Support: Core
251 #[serde(default, skip_serializing_if = "Option::is_none")]
252 pub uri: Option<String>,
253}
254
255/// SubjectAltName represents Subject Alternative Name.
256#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
257pub enum BackendTLSPolicyValidationSubjectAltNamesType {
258 Hostname,
259 #[serde(rename = "URI")]
260 Uri,
261}
262
263/// Validation contains backend TLS validation configuration.
264#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
265pub enum BackendTLSPolicyValidationWellKnownCaCertificates {
266 System,
267}
268
269/// Status defines the current state of BackendTLSPolicy.
270#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
271pub struct BackendTLSPolicyStatus {
272 /// Ancestors is a list of ancestor resources (usually Gateways) that are
273 /// associated with the policy, and the status of the policy with respect to
274 /// each ancestor. When this policy attaches to a parent, the controller that
275 /// manages the parent and the ancestors MUST add an entry to this list when
276 /// the controller first sees the policy and SHOULD update the entry as
277 /// appropriate when the relevant ancestor is modified.
278 ///
279 /// Note that choosing the relevant ancestor is left to the Policy designers;
280 /// an important part of Policy design is designing the right object level at
281 /// which to namespace this status.
282 ///
283 /// Note also that implementations MUST ONLY populate ancestor status for
284 /// the Ancestor resources they are responsible for. Implementations MUST
285 /// use the ControllerName field to uniquely identify the entries in this list
286 /// that they are responsible for.
287 ///
288 /// Note that to achieve this, the list of PolicyAncestorStatus structs
289 /// MUST be treated as a map with a composite key, made up of the AncestorRef
290 /// and ControllerName fields combined.
291 ///
292 /// A maximum of 16 ancestors will be represented in this list. An empty list
293 /// means the Policy is not relevant for any ancestors.
294 ///
295 /// If this slice is full, implementations MUST NOT add further entries.
296 /// Instead they MUST consider the policy unimplementable and signal that
297 /// on any related resources such as the ancestor that would be referenced
298 /// here. For example, if this list was full on BackendTLSPolicy, no
299 /// additional Gateways would be able to reference the Service targeted by
300 /// the BackendTLSPolicy.
301 pub ancestors: Vec<BackendTLSPolicyStatusAncestors>,
302}
303
304/// PolicyAncestorStatus describes the status of a route with respect to an
305/// associated Ancestor.
306///
307/// Ancestors refer to objects that are either the Target of a policy or above it
308/// in terms of object hierarchy. For example, if a policy targets a Service, the
309/// Policy's Ancestors are, in order, the Service, the HTTPRoute, the Gateway, and
310/// the GatewayClass. Almost always, in this hierarchy, the Gateway will be the most
311/// useful object to place Policy status on, so we recommend that implementations
312/// SHOULD use Gateway as the PolicyAncestorStatus object unless the designers
313/// have a _very_ good reason otherwise.
314///
315/// In the context of policy attachment, the Ancestor is used to distinguish which
316/// resource results in a distinct application of this policy. For example, if a policy
317/// targets a Service, it may have a distinct result per attached Gateway.
318///
319/// Policies targeting the same resource may have different effects depending on the
320/// ancestors of those resources. For example, different Gateways targeting the same
321/// Service may have different capabilities, especially if they have different underlying
322/// implementations.
323///
324/// For example, in BackendTLSPolicy, the Policy attaches to a Service that is
325/// used as a backend in a HTTPRoute that is itself attached to a Gateway.
326/// In this case, the relevant object for status is the Gateway, and that is the
327/// ancestor object referred to in this status.
328///
329/// Note that a parent is also an ancestor, so for objects where the parent is the
330/// relevant object for status, this struct SHOULD still be used.
331///
332/// This struct is intended to be used in a slice that's effectively a map,
333/// with a composite key made up of the AncestorRef and the ControllerName.
334#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
335pub struct BackendTLSPolicyStatusAncestors {
336 /// AncestorRef corresponds with a ParentRef in the spec that this
337 /// PolicyAncestorStatus struct describes the status of.
338 #[serde(rename = "ancestorRef")]
339 pub ancestor_ref: BackendTLSPolicyStatusAncestorsAncestorRef,
340 /// Conditions describes the status of the Policy with respect to the given Ancestor.
341 pub conditions: Vec<Condition>,
342 /// ControllerName is a domain/path string that indicates the name of the
343 /// controller that wrote this status. This corresponds with the
344 /// controllerName field on GatewayClass.
345 ///
346 /// Example: "example.net/gateway-controller".
347 ///
348 /// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are
349 /// valid Kubernetes names
350 /// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).
351 ///
352 /// Controllers MUST populate this field when writing status. Controllers should ensure that
353 /// entries to status populated with their ControllerName are cleaned up when they are no
354 /// longer necessary.
355 #[serde(rename = "controllerName")]
356 pub controller_name: String,
357}
358
359/// AncestorRef corresponds with a ParentRef in the spec that this
360/// PolicyAncestorStatus struct describes the status of.
361#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq)]
362pub struct BackendTLSPolicyStatusAncestorsAncestorRef {
363 /// Group is the group of the referent.
364 /// When unspecified, "gateway.networking.k8s.io" is inferred.
365 /// To set the core API group (such as for a "Service" kind referent),
366 /// Group must be explicitly set to "" (empty string).
367 ///
368 /// Support: Core
369 #[serde(default, skip_serializing_if = "Option::is_none")]
370 pub group: Option<String>,
371 /// Kind is kind of the referent.
372 ///
373 /// There are two kinds of parent resources with "Core" support:
374 ///
375 /// * Gateway (Gateway conformance profile)
376 /// * Service (Mesh conformance profile, ClusterIP Services only)
377 ///
378 /// Support for other resources is Implementation-Specific.
379 #[serde(default, skip_serializing_if = "Option::is_none")]
380 pub kind: Option<String>,
381 /// Name is the name of the referent.
382 ///
383 /// Support: Core
384 pub name: String,
385 /// Namespace is the namespace of the referent. When unspecified, this refers
386 /// to the local namespace of the Route.
387 ///
388 /// Note that there are specific rules for ParentRefs which cross namespace
389 /// boundaries. Cross-namespace references are only valid if they are explicitly
390 /// allowed by something in the namespace they are referring to. For example:
391 /// Gateway has the AllowedRoutes field, and ReferenceGrant provides a
392 /// generic way to enable any other kind of cross-namespace reference.
393 ///
394 /// Support: Core
395 #[serde(default, skip_serializing_if = "Option::is_none")]
396 pub namespace: Option<String>,
397 /// Port is the network port this Route targets. It can be interpreted
398 /// differently based on the type of parent resource.
399 ///
400 /// When the parent resource is a Gateway, this targets all listeners
401 /// listening on the specified port that also support this kind of Route(and
402 /// select this Route). It's not recommended to set `Port` unless the
403 /// networking behaviors specified in a Route must apply to a specific port
404 /// as opposed to a listener(s) whose port(s) may be changed. When both Port
405 /// and SectionName are specified, the name and port of the selected listener
406 /// must match both specified values.
407 ///
408 /// Implementations MAY choose to support other parent resources.
409 /// Implementations supporting other types of parent resources MUST clearly
410 /// document how/if Port is interpreted.
411 ///
412 /// For the purpose of status, an attachment is considered successful as
413 /// long as the parent resource accepts it partially. For example, Gateway
414 /// listeners can restrict which Routes can attach to them by Route kind,
415 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment
416 /// from the referencing Route, the Route MUST be considered successfully
417 /// attached. If no Gateway listeners accept attachment from this Route,
418 /// the Route MUST be considered detached from the Gateway.
419 ///
420 /// Support: Extended
421 #[serde(default, skip_serializing_if = "Option::is_none")]
422 pub port: Option<i32>,
423 /// SectionName is the name of a section within the target resource. In the
424 /// following resources, SectionName is interpreted as the following:
425 ///
426 /// * Gateway: Listener name. When both Port (experimental) and SectionName
427 /// are specified, the name and port of the selected listener must match
428 /// both specified values.
429 /// * Service: Port name. When both Port (experimental) and SectionName
430 /// are specified, the name and port of the selected listener must match
431 /// both specified values.
432 ///
433 /// Implementations MAY choose to support attaching Routes to other resources.
434 /// If that is the case, they MUST clearly document how SectionName is
435 /// interpreted.
436 ///
437 /// When unspecified (empty string), this will reference the entire resource.
438 /// For the purpose of status, an attachment is considered successful if at
439 /// least one section in the parent resource accepts it. For example, Gateway
440 /// listeners can restrict which Routes can attach to them by Route kind,
441 /// namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from
442 /// the referencing Route, the Route MUST be considered successfully
443 /// attached. If no Gateway listeners accept attachment from this Route, the
444 /// Route MUST be considered detached from the Gateway.
445 ///
446 /// Support: Core
447 #[serde(
448 default,
449 skip_serializing_if = "Option::is_none",
450 rename = "sectionName"
451 )]
452 pub section_name: Option<String>,
453}