cluster_api_rs/api/capi_cluster.rs
1// WARNING: generated by kopium - manual changes will be overwritten
2// kopium command: kopium --smart-derive-elision -D Default -D PartialEq -A -d -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 k8s_openapi::apimachinery::pkg::util::intstr::IntOrString;
9 pub use kube::CustomResource;
10 pub use schemars::JsonSchema;
11 pub use serde::{Deserialize, Serialize};
12 pub use std::collections::BTreeMap;
13}
14
15use self::prelude::*;
16
17/// spec is the desired state of Cluster.
18#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
19#[kube(
20 group = "cluster.x-k8s.io",
21 version = "v1beta2",
22 kind = "Cluster",
23 plural = "clusters"
24)]
25#[kube(namespaced)]
26#[kube(status = "ClusterStatus")]
27#[kube(derive = "Default")]
28#[kube(derive = "PartialEq")]
29pub struct ClusterSpec {
30 /// availabilityGates specifies additional conditions to include when evaluating Cluster Available condition.
31 ///
32 /// If this field is not defined and the Cluster implements a managed topology, availabilityGates
33 /// from the corresponding ClusterClass will be used, if any.
34 #[serde(
35 default,
36 skip_serializing_if = "Option::is_none",
37 rename = "availabilityGates"
38 )]
39 pub availability_gates: Option<Vec<ClusterAvailabilityGates>>,
40 /// clusterNetwork represents the cluster network configuration.
41 #[serde(
42 default,
43 skip_serializing_if = "Option::is_none",
44 rename = "clusterNetwork"
45 )]
46 pub cluster_network: Option<ClusterClusterNetwork>,
47 /// controlPlaneEndpoint represents the endpoint used to communicate with the control plane.
48 #[serde(
49 default,
50 skip_serializing_if = "Option::is_none",
51 rename = "controlPlaneEndpoint"
52 )]
53 pub control_plane_endpoint: Option<ClusterControlPlaneEndpoint>,
54 /// controlPlaneRef is an optional reference to a provider-specific resource that holds
55 /// the details for provisioning the Control Plane for a Cluster.
56 #[serde(
57 default,
58 skip_serializing_if = "Option::is_none",
59 rename = "controlPlaneRef"
60 )]
61 pub control_plane_ref: Option<ClusterControlPlaneRef>,
62 /// infrastructureRef is a reference to a provider-specific resource that holds the details
63 /// for provisioning infrastructure for a cluster in said provider.
64 #[serde(
65 default,
66 skip_serializing_if = "Option::is_none",
67 rename = "infrastructureRef"
68 )]
69 pub infrastructure_ref: Option<ClusterInfrastructureRef>,
70 /// paused can be used to prevent controllers from processing the Cluster and all its associated objects.
71 #[serde(default, skip_serializing_if = "Option::is_none")]
72 pub paused: Option<bool>,
73 /// topology encapsulates the topology for the cluster.
74 /// NOTE: It is required to enable the ClusterTopology
75 /// feature gate flag to activate managed topologies support;
76 /// this feature is highly experimental, and parts of it might still be not implemented.
77 #[serde(default, skip_serializing_if = "Option::is_none")]
78 pub topology: Option<ClusterTopology>,
79}
80
81/// ClusterAvailabilityGate contains the type of a Cluster condition to be used as availability gate.
82#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
83pub struct ClusterAvailabilityGates {
84 /// conditionType refers to a condition with matching type in the Cluster's condition list.
85 /// If the conditions doesn't exist, it will be treated as unknown.
86 /// Note: Both Cluster API conditions or conditions added by 3rd party controllers can be used as availability gates.
87 #[serde(rename = "conditionType")]
88 pub condition_type: String,
89 /// polarity of the conditionType specified in this availabilityGate.
90 /// Valid values are Positive, Negative and omitted.
91 /// When omitted, the default behaviour will be Positive.
92 /// A positive polarity means that the condition should report a true status under normal conditions.
93 /// A negative polarity means that the condition should report a false status under normal conditions.
94 #[serde(default, skip_serializing_if = "Option::is_none")]
95 pub polarity: Option<ClusterAvailabilityGatesPolarity>,
96}
97
98/// ClusterAvailabilityGate contains the type of a Cluster condition to be used as availability gate.
99#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
100pub enum ClusterAvailabilityGatesPolarity {
101 Positive,
102 Negative,
103}
104
105/// clusterNetwork represents the cluster network configuration.
106#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
107pub struct ClusterClusterNetwork {
108 /// apiServerPort specifies the port the API Server should bind to.
109 /// Defaults to 6443.
110 #[serde(
111 default,
112 skip_serializing_if = "Option::is_none",
113 rename = "apiServerPort"
114 )]
115 pub api_server_port: Option<i32>,
116 /// pods is the network ranges from which Pod networks are allocated.
117 #[serde(default, skip_serializing_if = "Option::is_none")]
118 pub pods: Option<ClusterClusterNetworkPods>,
119 /// serviceDomain is the domain name for services.
120 #[serde(
121 default,
122 skip_serializing_if = "Option::is_none",
123 rename = "serviceDomain"
124 )]
125 pub service_domain: Option<String>,
126 /// services is the network ranges from which service VIPs are allocated.
127 #[serde(default, skip_serializing_if = "Option::is_none")]
128 pub services: Option<ClusterClusterNetworkServices>,
129}
130
131/// pods is the network ranges from which Pod networks are allocated.
132#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
133pub struct ClusterClusterNetworkPods {
134 /// cidrBlocks is a list of CIDR blocks.
135 #[serde(rename = "cidrBlocks")]
136 pub cidr_blocks: Vec<String>,
137}
138
139/// services is the network ranges from which service VIPs are allocated.
140#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
141pub struct ClusterClusterNetworkServices {
142 /// cidrBlocks is a list of CIDR blocks.
143 #[serde(rename = "cidrBlocks")]
144 pub cidr_blocks: Vec<String>,
145}
146
147/// controlPlaneEndpoint represents the endpoint used to communicate with the control plane.
148#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
149pub struct ClusterControlPlaneEndpoint {
150 /// host is the hostname on which the API server is serving.
151 #[serde(default, skip_serializing_if = "Option::is_none")]
152 pub host: Option<String>,
153 /// port is the port on which the API server is serving.
154 #[serde(default, skip_serializing_if = "Option::is_none")]
155 pub port: Option<i32>,
156}
157
158/// controlPlaneRef is an optional reference to a provider-specific resource that holds
159/// the details for provisioning the Control Plane for a Cluster.
160#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
161pub struct ClusterControlPlaneRef {
162 /// apiGroup is the group of the resource being referenced.
163 /// apiGroup must be fully qualified domain name.
164 /// The corresponding version for this reference will be looked up from the contract
165 /// labels of the corresponding CRD of the resource being referenced.
166 #[serde(rename = "apiGroup")]
167 pub api_group: String,
168 /// kind of the resource being referenced.
169 /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
170 pub kind: String,
171 /// name of the resource being referenced.
172 /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
173 pub name: String,
174}
175
176/// infrastructureRef is a reference to a provider-specific resource that holds the details
177/// for provisioning infrastructure for a cluster in said provider.
178#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
179pub struct ClusterInfrastructureRef {
180 /// apiGroup is the group of the resource being referenced.
181 /// apiGroup must be fully qualified domain name.
182 /// The corresponding version for this reference will be looked up from the contract
183 /// labels of the corresponding CRD of the resource being referenced.
184 #[serde(rename = "apiGroup")]
185 pub api_group: String,
186 /// kind of the resource being referenced.
187 /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
188 pub kind: String,
189 /// name of the resource being referenced.
190 /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
191 pub name: String,
192}
193
194/// topology encapsulates the topology for the cluster.
195/// NOTE: It is required to enable the ClusterTopology
196/// feature gate flag to activate managed topologies support;
197/// this feature is highly experimental, and parts of it might still be not implemented.
198#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
199pub struct ClusterTopology {
200 /// classRef is the ref to the ClusterClass that should be used for the topology.
201 #[serde(rename = "classRef")]
202 pub class_ref: ClusterTopologyClassRef,
203 /// controlPlane describes the cluster control plane.
204 #[serde(
205 default,
206 skip_serializing_if = "Option::is_none",
207 rename = "controlPlane"
208 )]
209 pub control_plane: Option<ClusterTopologyControlPlane>,
210 /// variables can be used to customize the Cluster through
211 /// patches. They must comply to the corresponding
212 /// VariableClasses defined in the ClusterClass.
213 #[serde(default, skip_serializing_if = "Option::is_none")]
214 pub variables: Option<Vec<ClusterTopologyVariables>>,
215 /// version is the Kubernetes version of the cluster.
216 pub version: String,
217 /// workers encapsulates the different constructs that form the worker nodes
218 /// for the cluster.
219 #[serde(default, skip_serializing_if = "Option::is_none")]
220 pub workers: Option<ClusterTopologyWorkers>,
221}
222
223/// classRef is the ref to the ClusterClass that should be used for the topology.
224#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
225pub struct ClusterTopologyClassRef {
226 /// name is the name of the ClusterClass that should be used for the topology.
227 /// name must be a valid ClusterClass name and because of that be at most 253 characters in length
228 /// and it must consist only of lower case alphanumeric characters, hyphens (-) and periods (.), and must start
229 /// and end with an alphanumeric character.
230 pub name: String,
231 /// namespace is the namespace of the ClusterClass that should be used for the topology.
232 /// If namespace is empty or not set, it is defaulted to the namespace of the Cluster object.
233 /// namespace must be a valid namespace name and because of that be at most 63 characters in length
234 /// and it must consist only of lower case alphanumeric characters or hyphens (-), and must start
235 /// and end with an alphanumeric character.
236 #[serde(default, skip_serializing_if = "Option::is_none")]
237 pub namespace: Option<String>,
238}
239
240/// controlPlane describes the cluster control plane.
241#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
242pub struct ClusterTopologyControlPlane {
243 /// deletion contains configuration options for Machine deletion.
244 #[serde(default, skip_serializing_if = "Option::is_none")]
245 pub deletion: Option<ClusterTopologyControlPlaneDeletion>,
246 /// healthCheck allows to enable, disable and override control plane health check
247 /// configuration from the ClusterClass for this control plane.
248 #[serde(
249 default,
250 skip_serializing_if = "Option::is_none",
251 rename = "healthCheck"
252 )]
253 pub health_check: Option<ClusterTopologyControlPlaneHealthCheck>,
254 /// metadata is the metadata applied to the ControlPlane and the Machines of the ControlPlane
255 /// if the ControlPlaneTemplate referenced by the ClusterClass is machine based. If not, it
256 /// is applied only to the ControlPlane.
257 /// At runtime this metadata is merged with the corresponding metadata from the ClusterClass.
258 #[serde(default, skip_serializing_if = "Option::is_none")]
259 pub metadata: Option<ClusterTopologyControlPlaneMetadata>,
260 /// readinessGates specifies additional conditions to include when evaluating Machine Ready condition.
261 ///
262 /// This field can be used e.g. to instruct the machine controller to include in the computation for Machine's ready
263 /// computation a condition, managed by an external controllers, reporting the status of special software/hardware installed on the Machine.
264 ///
265 /// If this field is not defined, readinessGates from the corresponding ControlPlaneClass will be used, if any.
266 ///
267 /// NOTE: Specific control plane provider implementations might automatically extend the list of readinessGates;
268 /// e.g. the kubeadm control provider adds ReadinessGates for the APIServerPodHealthy, SchedulerPodHealthy conditions, etc.
269 #[serde(
270 default,
271 skip_serializing_if = "Option::is_none",
272 rename = "readinessGates"
273 )]
274 pub readiness_gates: Option<Vec<ClusterTopologyControlPlaneReadinessGates>>,
275 /// replicas is the number of control plane nodes.
276 /// If the value is not set, the ControlPlane object is created without the number of Replicas
277 /// and it's assumed that the control plane controller does not implement support for this field.
278 /// When specified against a control plane provider that lacks support for this field, this value will be ignored.
279 #[serde(default, skip_serializing_if = "Option::is_none")]
280 pub replicas: Option<i32>,
281 /// variables can be used to customize the ControlPlane through patches.
282 #[serde(default, skip_serializing_if = "Option::is_none")]
283 pub variables: Option<ClusterTopologyControlPlaneVariables>,
284}
285
286/// deletion contains configuration options for Machine deletion.
287#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
288pub struct ClusterTopologyControlPlaneDeletion {
289 /// nodeDeletionTimeoutSeconds defines how long the controller will attempt to delete the Node that the Machine
290 /// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
291 /// Defaults to 10 seconds.
292 #[serde(
293 default,
294 skip_serializing_if = "Option::is_none",
295 rename = "nodeDeletionTimeoutSeconds"
296 )]
297 pub node_deletion_timeout_seconds: Option<i32>,
298 /// nodeDrainTimeoutSeconds is the total amount of time that the controller will spend on draining a node.
299 /// The default value is 0, meaning that the node can be drained without any time limitations.
300 /// NOTE: nodeDrainTimeoutSeconds is different from `kubectl drain --timeout`
301 #[serde(
302 default,
303 skip_serializing_if = "Option::is_none",
304 rename = "nodeDrainTimeoutSeconds"
305 )]
306 pub node_drain_timeout_seconds: Option<i32>,
307 /// nodeVolumeDetachTimeoutSeconds is the total amount of time that the controller will spend on waiting for all volumes
308 /// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
309 #[serde(
310 default,
311 skip_serializing_if = "Option::is_none",
312 rename = "nodeVolumeDetachTimeoutSeconds"
313 )]
314 pub node_volume_detach_timeout_seconds: Option<i32>,
315}
316
317/// healthCheck allows to enable, disable and override control plane health check
318/// configuration from the ClusterClass for this control plane.
319#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
320pub struct ClusterTopologyControlPlaneHealthCheck {
321 /// checks are the checks that are used to evaluate if a Machine is healthy.
322 ///
323 /// If one of checks and remediation fields are set, the system assumes that an healthCheck override is defined,
324 /// and as a consequence the checks and remediation fields from Cluster will be used instead of the
325 /// corresponding fields in ClusterClass.
326 ///
327 /// Independent of this configuration the MachineHealthCheck controller will always
328 /// flag Machines with `cluster.x-k8s.io/remediate-machine` annotation and
329 /// Machines with deleted Nodes as unhealthy.
330 ///
331 /// Furthermore, if checks.nodeStartupTimeoutSeconds is not set it
332 /// is defaulted to 10 minutes and evaluated accordingly.
333 #[serde(default, skip_serializing_if = "Option::is_none")]
334 pub checks: Option<ClusterTopologyControlPlaneHealthCheckChecks>,
335 /// enabled controls if a MachineHealthCheck should be created for the target machines.
336 ///
337 /// If false: No MachineHealthCheck will be created.
338 ///
339 /// If not set(default): A MachineHealthCheck will be created if it is defined here or
340 /// in the associated ClusterClass. If no MachineHealthCheck is defined then none will be created.
341 ///
342 /// If true: A MachineHealthCheck is guaranteed to be created. Cluster validation will
343 /// block if `enable` is true and no MachineHealthCheck definition is available.
344 #[serde(default, skip_serializing_if = "Option::is_none")]
345 pub enabled: Option<bool>,
346 /// remediation configures if and how remediations are triggered if a Machine is unhealthy.
347 ///
348 /// If one of checks and remediation fields are set, the system assumes that an healthCheck override is defined,
349 /// and as a consequence the checks and remediation fields from cluster will be used instead of the
350 /// corresponding fields in ClusterClass.
351 ///
352 /// If an health check override is defined and remediation or remediation.triggerIf is not set,
353 /// remediation will always be triggered for unhealthy Machines.
354 ///
355 /// If an health check override is defined and remediation or remediation.templateRef is not set,
356 /// the OwnerRemediated condition will be set on unhealthy Machines to trigger remediation via
357 /// the owner of the Machines, for example a MachineSet or a KubeadmControlPlane.
358 #[serde(default, skip_serializing_if = "Option::is_none")]
359 pub remediation: Option<ClusterTopologyControlPlaneHealthCheckRemediation>,
360}
361
362/// checks are the checks that are used to evaluate if a Machine is healthy.
363///
364/// If one of checks and remediation fields are set, the system assumes that an healthCheck override is defined,
365/// and as a consequence the checks and remediation fields from Cluster will be used instead of the
366/// corresponding fields in ClusterClass.
367///
368/// Independent of this configuration the MachineHealthCheck controller will always
369/// flag Machines with `cluster.x-k8s.io/remediate-machine` annotation and
370/// Machines with deleted Nodes as unhealthy.
371///
372/// Furthermore, if checks.nodeStartupTimeoutSeconds is not set it
373/// is defaulted to 10 minutes and evaluated accordingly.
374#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
375pub struct ClusterTopologyControlPlaneHealthCheckChecks {
376 /// nodeStartupTimeoutSeconds allows to set the maximum time for MachineHealthCheck
377 /// to consider a Machine unhealthy if a corresponding Node isn't associated
378 /// through a `Spec.ProviderID` field.
379 ///
380 /// The duration set in this field is compared to the greatest of:
381 /// - Cluster's infrastructure ready condition timestamp (if and when available)
382 /// - Control Plane's initialized condition timestamp (if and when available)
383 /// - Machine's infrastructure ready condition timestamp (if and when available)
384 /// - Machine's metadata creation timestamp
385 ///
386 /// Defaults to 10 minutes.
387 /// If you wish to disable this feature, set the value explicitly to 0.
388 #[serde(
389 default,
390 skip_serializing_if = "Option::is_none",
391 rename = "nodeStartupTimeoutSeconds"
392 )]
393 pub node_startup_timeout_seconds: Option<i32>,
394 /// unhealthyNodeConditions contains a list of conditions that determine
395 /// whether a node is considered unhealthy. The conditions are combined in a
396 /// logical OR, i.e. if any of the conditions is met, the node is unhealthy.
397 #[serde(
398 default,
399 skip_serializing_if = "Option::is_none",
400 rename = "unhealthyNodeConditions"
401 )]
402 pub unhealthy_node_conditions:
403 Option<Vec<ClusterTopologyControlPlaneHealthCheckChecksUnhealthyNodeConditions>>,
404}
405
406/// UnhealthyNodeCondition represents a Node condition type and value with a timeout
407/// specified as a duration. When the named condition has been in the given
408/// status for at least the timeout value, a node is considered unhealthy.
409#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
410pub struct ClusterTopologyControlPlaneHealthCheckChecksUnhealthyNodeConditions {
411 /// status of the condition, one of True, False, Unknown.
412 pub status: String,
413 /// timeoutSeconds is the duration that a node must be in a given status for,
414 /// after which the node is considered unhealthy.
415 /// For example, with a value of "1h", the node must match the status
416 /// for at least 1 hour before being considered unhealthy.
417 #[serde(rename = "timeoutSeconds")]
418 pub timeout_seconds: i32,
419 /// type of Node condition
420 #[serde(rename = "type")]
421 pub r#type: String,
422}
423
424/// remediation configures if and how remediations are triggered if a Machine is unhealthy.
425///
426/// If one of checks and remediation fields are set, the system assumes that an healthCheck override is defined,
427/// and as a consequence the checks and remediation fields from cluster will be used instead of the
428/// corresponding fields in ClusterClass.
429///
430/// If an health check override is defined and remediation or remediation.triggerIf is not set,
431/// remediation will always be triggered for unhealthy Machines.
432///
433/// If an health check override is defined and remediation or remediation.templateRef is not set,
434/// the OwnerRemediated condition will be set on unhealthy Machines to trigger remediation via
435/// the owner of the Machines, for example a MachineSet or a KubeadmControlPlane.
436#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
437pub struct ClusterTopologyControlPlaneHealthCheckRemediation {
438 /// templateRef is a reference to a remediation template
439 /// provided by an infrastructure provider.
440 ///
441 /// This field is completely optional, when filled, the MachineHealthCheck controller
442 /// creates a new object from the template referenced and hands off remediation of the machine to
443 /// a controller that lives outside of Cluster API.
444 #[serde(
445 default,
446 skip_serializing_if = "Option::is_none",
447 rename = "templateRef"
448 )]
449 pub template_ref: Option<ClusterTopologyControlPlaneHealthCheckRemediationTemplateRef>,
450 /// triggerIf configures if remediations are triggered.
451 /// If this field is not set, remediations are always triggered.
452 #[serde(default, skip_serializing_if = "Option::is_none", rename = "triggerIf")]
453 pub trigger_if: Option<ClusterTopologyControlPlaneHealthCheckRemediationTriggerIf>,
454}
455
456/// templateRef is a reference to a remediation template
457/// provided by an infrastructure provider.
458///
459/// This field is completely optional, when filled, the MachineHealthCheck controller
460/// creates a new object from the template referenced and hands off remediation of the machine to
461/// a controller that lives outside of Cluster API.
462#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
463pub struct ClusterTopologyControlPlaneHealthCheckRemediationTemplateRef {
464 /// apiVersion of the remediation template.
465 /// apiVersion must be fully qualified domain name followed by / and a version.
466 /// NOTE: This field must be kept in sync with the APIVersion of the remediation template.
467 #[serde(rename = "apiVersion")]
468 pub api_version: String,
469 /// kind of the remediation template.
470 /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
471 pub kind: String,
472 /// name of the remediation template.
473 /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
474 pub name: String,
475}
476
477/// triggerIf configures if remediations are triggered.
478/// If this field is not set, remediations are always triggered.
479#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
480pub struct ClusterTopologyControlPlaneHealthCheckRemediationTriggerIf {
481 /// unhealthyInRange specifies that remediations are only triggered if the number of
482 /// unhealthy Machines is in the configured range.
483 /// Takes precedence over unhealthyLessThanOrEqualTo.
484 /// Eg. "[3-5]" - This means that remediation will be allowed only when:
485 /// (a) there are at least 3 unhealthy Machines (and)
486 /// (b) there are at most 5 unhealthy Machines
487 #[serde(
488 default,
489 skip_serializing_if = "Option::is_none",
490 rename = "unhealthyInRange"
491 )]
492 pub unhealthy_in_range: Option<String>,
493 /// unhealthyLessThanOrEqualTo specifies that remediations are only triggered if the number of
494 /// unhealthy Machines is less than or equal to the configured value.
495 /// unhealthyInRange takes precedence if set.
496 #[serde(
497 default,
498 skip_serializing_if = "Option::is_none",
499 rename = "unhealthyLessThanOrEqualTo"
500 )]
501 pub unhealthy_less_than_or_equal_to: Option<IntOrString>,
502}
503
504/// metadata is the metadata applied to the ControlPlane and the Machines of the ControlPlane
505/// if the ControlPlaneTemplate referenced by the ClusterClass is machine based. If not, it
506/// is applied only to the ControlPlane.
507/// At runtime this metadata is merged with the corresponding metadata from the ClusterClass.
508#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
509pub struct ClusterTopologyControlPlaneMetadata {
510 /// annotations is an unstructured key value map stored with a resource that may be
511 /// set by external tools to store and retrieve arbitrary metadata. They are not
512 /// queryable and should be preserved when modifying objects.
513 /// More info: <http://kubernetes.io/docs/user-guide/annotations>
514 #[serde(default, skip_serializing_if = "Option::is_none")]
515 pub annotations: Option<BTreeMap<String, String>>,
516 /// labels is a map of string keys and values that can be used to organize and categorize
517 /// (scope and select) objects. May match selectors of replication controllers
518 /// and services.
519 /// More info: <http://kubernetes.io/docs/user-guide/labels>
520 #[serde(default, skip_serializing_if = "Option::is_none")]
521 pub labels: Option<BTreeMap<String, String>>,
522}
523
524/// MachineReadinessGate contains the type of a Machine condition to be used as a readiness gate.
525#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
526pub struct ClusterTopologyControlPlaneReadinessGates {
527 /// conditionType refers to a condition with matching type in the Machine's condition list.
528 /// If the conditions doesn't exist, it will be treated as unknown.
529 /// Note: Both Cluster API conditions or conditions added by 3rd party controllers can be used as readiness gates.
530 #[serde(rename = "conditionType")]
531 pub condition_type: String,
532 /// polarity of the conditionType specified in this readinessGate.
533 /// Valid values are Positive, Negative and omitted.
534 /// When omitted, the default behaviour will be Positive.
535 /// A positive polarity means that the condition should report a true status under normal conditions.
536 /// A negative polarity means that the condition should report a false status under normal conditions.
537 #[serde(default, skip_serializing_if = "Option::is_none")]
538 pub polarity: Option<ClusterTopologyControlPlaneReadinessGatesPolarity>,
539}
540
541/// MachineReadinessGate contains the type of a Machine condition to be used as a readiness gate.
542#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
543pub enum ClusterTopologyControlPlaneReadinessGatesPolarity {
544 Positive,
545 Negative,
546}
547
548/// variables can be used to customize the ControlPlane through patches.
549#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
550pub struct ClusterTopologyControlPlaneVariables {
551 /// overrides can be used to override Cluster level variables.
552 #[serde(default, skip_serializing_if = "Option::is_none")]
553 pub overrides: Option<Vec<ClusterTopologyControlPlaneVariablesOverrides>>,
554}
555
556/// ClusterVariable can be used to customize the Cluster through patches. Each ClusterVariable is associated with a
557/// Variable definition in the ClusterClass `status` variables.
558#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
559pub struct ClusterTopologyControlPlaneVariablesOverrides {
560 /// name of the variable.
561 pub name: String,
562 /// value of the variable.
563 /// Note: the value will be validated against the schema of the corresponding ClusterClassVariable
564 /// from the ClusterClass.
565 /// Note: We have to use apiextensionsv1.JSON instead of a custom JSON type, because controller-tools has a
566 /// hard-coded schema for apiextensionsv1.JSON which cannot be produced by another type via controller-tools,
567 /// i.e. it is not possible to have no type field.
568 /// Ref: <https://github.com/kubernetes-sigs/controller-tools/blob/d0e03a142d0ecdd5491593e941ee1d6b5d91dba6/pkg/crd/known_types.go#L106-L111>
569 pub value: serde_json::Value,
570}
571
572/// ClusterVariable can be used to customize the Cluster through patches. Each ClusterVariable is associated with a
573/// Variable definition in the ClusterClass `status` variables.
574#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
575pub struct ClusterTopologyVariables {
576 /// name of the variable.
577 pub name: String,
578 /// value of the variable.
579 /// Note: the value will be validated against the schema of the corresponding ClusterClassVariable
580 /// from the ClusterClass.
581 /// Note: We have to use apiextensionsv1.JSON instead of a custom JSON type, because controller-tools has a
582 /// hard-coded schema for apiextensionsv1.JSON which cannot be produced by another type via controller-tools,
583 /// i.e. it is not possible to have no type field.
584 /// Ref: <https://github.com/kubernetes-sigs/controller-tools/blob/d0e03a142d0ecdd5491593e941ee1d6b5d91dba6/pkg/crd/known_types.go#L106-L111>
585 pub value: serde_json::Value,
586}
587
588/// workers encapsulates the different constructs that form the worker nodes
589/// for the cluster.
590#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
591pub struct ClusterTopologyWorkers {
592 /// machineDeployments is a list of machine deployments in the cluster.
593 #[serde(
594 default,
595 skip_serializing_if = "Option::is_none",
596 rename = "machineDeployments"
597 )]
598 pub machine_deployments: Option<Vec<ClusterTopologyWorkersMachineDeployments>>,
599 /// machinePools is a list of machine pools in the cluster.
600 #[serde(
601 default,
602 skip_serializing_if = "Option::is_none",
603 rename = "machinePools"
604 )]
605 pub machine_pools: Option<Vec<ClusterTopologyWorkersMachinePools>>,
606}
607
608/// MachineDeploymentTopology specifies the different parameters for a set of worker nodes in the topology.
609/// This set of nodes is managed by a MachineDeployment object whose lifecycle is managed by the Cluster controller.
610#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
611pub struct ClusterTopologyWorkersMachineDeployments {
612 /// class is the name of the MachineDeploymentClass used to create the set of worker nodes.
613 /// This should match one of the deployment classes defined in the ClusterClass object
614 /// mentioned in the `Cluster.Spec.Class` field.
615 pub class: String,
616 /// deletion contains configuration options for Machine deletion.
617 #[serde(default, skip_serializing_if = "Option::is_none")]
618 pub deletion: Option<ClusterTopologyWorkersMachineDeploymentsDeletion>,
619 /// failureDomain is the failure domain the machines will be created in.
620 /// Must match a key in the FailureDomains map stored on the cluster object.
621 #[serde(
622 default,
623 skip_serializing_if = "Option::is_none",
624 rename = "failureDomain"
625 )]
626 pub failure_domain: Option<String>,
627 /// healthCheck allows to enable, disable and override MachineDeployment health check
628 /// configuration from the ClusterClass for this MachineDeployment.
629 #[serde(
630 default,
631 skip_serializing_if = "Option::is_none",
632 rename = "healthCheck"
633 )]
634 pub health_check: Option<ClusterTopologyWorkersMachineDeploymentsHealthCheck>,
635 /// metadata is the metadata applied to the MachineDeployment and the machines of the MachineDeployment.
636 /// At runtime this metadata is merged with the corresponding metadata from the ClusterClass.
637 #[serde(default, skip_serializing_if = "Option::is_none")]
638 pub metadata: Option<ClusterTopologyWorkersMachineDeploymentsMetadata>,
639 /// minReadySeconds is the minimum number of seconds for which a newly created machine should
640 /// be ready.
641 /// Defaults to 0 (machine will be considered available as soon as it
642 /// is ready)
643 #[serde(
644 default,
645 skip_serializing_if = "Option::is_none",
646 rename = "minReadySeconds"
647 )]
648 pub min_ready_seconds: Option<i32>,
649 /// name is the unique identifier for this MachineDeploymentTopology.
650 /// The value is used with other unique identifiers to create a MachineDeployment's Name
651 /// (e.g. cluster's name, etc). In case the name is greater than the allowed maximum length,
652 /// the values are hashed together.
653 pub name: String,
654 /// readinessGates specifies additional conditions to include when evaluating Machine Ready condition.
655 ///
656 /// This field can be used e.g. to instruct the machine controller to include in the computation for Machine's ready
657 /// computation a condition, managed by an external controllers, reporting the status of special software/hardware installed on the Machine.
658 ///
659 /// If this field is not defined, readinessGates from the corresponding MachineDeploymentClass will be used, if any.
660 #[serde(
661 default,
662 skip_serializing_if = "Option::is_none",
663 rename = "readinessGates"
664 )]
665 pub readiness_gates: Option<Vec<ClusterTopologyWorkersMachineDeploymentsReadinessGates>>,
666 /// replicas is the number of worker nodes belonging to this set.
667 /// If the value is nil, the MachineDeployment is created without the number of Replicas (defaulting to 1)
668 /// and it's assumed that an external entity (like cluster autoscaler) is responsible for the management
669 /// of this value.
670 #[serde(default, skip_serializing_if = "Option::is_none")]
671 pub replicas: Option<i32>,
672 /// rollout allows you to configure the behaviour of rolling updates to the MachineDeployment Machines.
673 /// It allows you to define the strategy used during rolling replacements.
674 #[serde(default, skip_serializing_if = "Option::is_none")]
675 pub rollout: Option<ClusterTopologyWorkersMachineDeploymentsRollout>,
676 /// variables can be used to customize the MachineDeployment through patches.
677 #[serde(default, skip_serializing_if = "Option::is_none")]
678 pub variables: Option<ClusterTopologyWorkersMachineDeploymentsVariables>,
679}
680
681/// deletion contains configuration options for Machine deletion.
682#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
683pub struct ClusterTopologyWorkersMachineDeploymentsDeletion {
684 /// nodeDeletionTimeoutSeconds defines how long the controller will attempt to delete the Node that the Machine
685 /// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
686 /// Defaults to 10 seconds.
687 #[serde(
688 default,
689 skip_serializing_if = "Option::is_none",
690 rename = "nodeDeletionTimeoutSeconds"
691 )]
692 pub node_deletion_timeout_seconds: Option<i32>,
693 /// nodeDrainTimeoutSeconds is the total amount of time that the controller will spend on draining a node.
694 /// The default value is 0, meaning that the node can be drained without any time limitations.
695 /// NOTE: nodeDrainTimeoutSeconds is different from `kubectl drain --timeout`
696 #[serde(
697 default,
698 skip_serializing_if = "Option::is_none",
699 rename = "nodeDrainTimeoutSeconds"
700 )]
701 pub node_drain_timeout_seconds: Option<i32>,
702 /// nodeVolumeDetachTimeoutSeconds is the total amount of time that the controller will spend on waiting for all volumes
703 /// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
704 #[serde(
705 default,
706 skip_serializing_if = "Option::is_none",
707 rename = "nodeVolumeDetachTimeoutSeconds"
708 )]
709 pub node_volume_detach_timeout_seconds: Option<i32>,
710 /// order defines the order in which Machines are deleted when downscaling.
711 /// Defaults to "Random". Valid values are "Random, "Newest", "Oldest"
712 #[serde(default, skip_serializing_if = "Option::is_none")]
713 pub order: Option<ClusterTopologyWorkersMachineDeploymentsDeletionOrder>,
714}
715
716/// deletion contains configuration options for Machine deletion.
717#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
718pub enum ClusterTopologyWorkersMachineDeploymentsDeletionOrder {
719 Random,
720 Newest,
721 Oldest,
722}
723
724/// healthCheck allows to enable, disable and override MachineDeployment health check
725/// configuration from the ClusterClass for this MachineDeployment.
726#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
727pub struct ClusterTopologyWorkersMachineDeploymentsHealthCheck {
728 /// checks are the checks that are used to evaluate if a Machine is healthy.
729 ///
730 /// If one of checks and remediation fields are set, the system assumes that an healthCheck override is defined,
731 /// and as a consequence the checks and remediation fields from Cluster will be used instead of the
732 /// corresponding fields in ClusterClass.
733 ///
734 /// Independent of this configuration the MachineHealthCheck controller will always
735 /// flag Machines with `cluster.x-k8s.io/remediate-machine` annotation and
736 /// Machines with deleted Nodes as unhealthy.
737 ///
738 /// Furthermore, if checks.nodeStartupTimeoutSeconds is not set it
739 /// is defaulted to 10 minutes and evaluated accordingly.
740 #[serde(default, skip_serializing_if = "Option::is_none")]
741 pub checks: Option<ClusterTopologyWorkersMachineDeploymentsHealthCheckChecks>,
742 /// enabled controls if a MachineHealthCheck should be created for the target machines.
743 ///
744 /// If false: No MachineHealthCheck will be created.
745 ///
746 /// If not set(default): A MachineHealthCheck will be created if it is defined here or
747 /// in the associated ClusterClass. If no MachineHealthCheck is defined then none will be created.
748 ///
749 /// If true: A MachineHealthCheck is guaranteed to be created. Cluster validation will
750 /// block if `enable` is true and no MachineHealthCheck definition is available.
751 #[serde(default, skip_serializing_if = "Option::is_none")]
752 pub enabled: Option<bool>,
753 /// remediation configures if and how remediations are triggered if a Machine is unhealthy.
754 ///
755 /// If one of checks and remediation fields are set, the system assumes that an healthCheck override is defined,
756 /// and as a consequence the checks and remediation fields from cluster will be used instead of the
757 /// corresponding fields in ClusterClass.
758 ///
759 /// If an health check override is defined and remediation or remediation.triggerIf is not set,
760 /// remediation will always be triggered for unhealthy Machines.
761 ///
762 /// If an health check override is defined and remediation or remediation.templateRef is not set,
763 /// the OwnerRemediated condition will be set on unhealthy Machines to trigger remediation via
764 /// the owner of the Machines, for example a MachineSet or a KubeadmControlPlane.
765 #[serde(default, skip_serializing_if = "Option::is_none")]
766 pub remediation: Option<ClusterTopologyWorkersMachineDeploymentsHealthCheckRemediation>,
767}
768
769/// checks are the checks that are used to evaluate if a Machine is healthy.
770///
771/// If one of checks and remediation fields are set, the system assumes that an healthCheck override is defined,
772/// and as a consequence the checks and remediation fields from Cluster will be used instead of the
773/// corresponding fields in ClusterClass.
774///
775/// Independent of this configuration the MachineHealthCheck controller will always
776/// flag Machines with `cluster.x-k8s.io/remediate-machine` annotation and
777/// Machines with deleted Nodes as unhealthy.
778///
779/// Furthermore, if checks.nodeStartupTimeoutSeconds is not set it
780/// is defaulted to 10 minutes and evaluated accordingly.
781#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
782pub struct ClusterTopologyWorkersMachineDeploymentsHealthCheckChecks {
783 /// nodeStartupTimeoutSeconds allows to set the maximum time for MachineHealthCheck
784 /// to consider a Machine unhealthy if a corresponding Node isn't associated
785 /// through a `Spec.ProviderID` field.
786 ///
787 /// The duration set in this field is compared to the greatest of:
788 /// - Cluster's infrastructure ready condition timestamp (if and when available)
789 /// - Control Plane's initialized condition timestamp (if and when available)
790 /// - Machine's infrastructure ready condition timestamp (if and when available)
791 /// - Machine's metadata creation timestamp
792 ///
793 /// Defaults to 10 minutes.
794 /// If you wish to disable this feature, set the value explicitly to 0.
795 #[serde(
796 default,
797 skip_serializing_if = "Option::is_none",
798 rename = "nodeStartupTimeoutSeconds"
799 )]
800 pub node_startup_timeout_seconds: Option<i32>,
801 /// unhealthyNodeConditions contains a list of conditions that determine
802 /// whether a node is considered unhealthy. The conditions are combined in a
803 /// logical OR, i.e. if any of the conditions is met, the node is unhealthy.
804 #[serde(
805 default,
806 skip_serializing_if = "Option::is_none",
807 rename = "unhealthyNodeConditions"
808 )]
809 pub unhealthy_node_conditions: Option<
810 Vec<ClusterTopologyWorkersMachineDeploymentsHealthCheckChecksUnhealthyNodeConditions>,
811 >,
812}
813
814/// UnhealthyNodeCondition represents a Node condition type and value with a timeout
815/// specified as a duration. When the named condition has been in the given
816/// status for at least the timeout value, a node is considered unhealthy.
817#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
818pub struct ClusterTopologyWorkersMachineDeploymentsHealthCheckChecksUnhealthyNodeConditions {
819 /// status of the condition, one of True, False, Unknown.
820 pub status: String,
821 /// timeoutSeconds is the duration that a node must be in a given status for,
822 /// after which the node is considered unhealthy.
823 /// For example, with a value of "1h", the node must match the status
824 /// for at least 1 hour before being considered unhealthy.
825 #[serde(rename = "timeoutSeconds")]
826 pub timeout_seconds: i32,
827 /// type of Node condition
828 #[serde(rename = "type")]
829 pub r#type: String,
830}
831
832/// remediation configures if and how remediations are triggered if a Machine is unhealthy.
833///
834/// If one of checks and remediation fields are set, the system assumes that an healthCheck override is defined,
835/// and as a consequence the checks and remediation fields from cluster will be used instead of the
836/// corresponding fields in ClusterClass.
837///
838/// If an health check override is defined and remediation or remediation.triggerIf is not set,
839/// remediation will always be triggered for unhealthy Machines.
840///
841/// If an health check override is defined and remediation or remediation.templateRef is not set,
842/// the OwnerRemediated condition will be set on unhealthy Machines to trigger remediation via
843/// the owner of the Machines, for example a MachineSet or a KubeadmControlPlane.
844#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
845pub struct ClusterTopologyWorkersMachineDeploymentsHealthCheckRemediation {
846 /// maxInFlight determines how many in flight remediations should happen at the same time.
847 ///
848 /// Remediation only happens on the MachineSet with the most current revision, while
849 /// older MachineSets (usually present during rollout operations) aren't allowed to remediate.
850 ///
851 /// Note: In general (independent of remediations), unhealthy machines are always
852 /// prioritized during scale down operations over healthy ones.
853 ///
854 /// MaxInFlight can be set to a fixed number or a percentage.
855 /// Example: when this is set to 20%, the MachineSet controller deletes at most 20% of
856 /// the desired replicas.
857 ///
858 /// If not set, remediation is limited to all machines (bounded by replicas)
859 /// under the active MachineSet's management.
860 #[serde(
861 default,
862 skip_serializing_if = "Option::is_none",
863 rename = "maxInFlight"
864 )]
865 pub max_in_flight: Option<IntOrString>,
866 /// templateRef is a reference to a remediation template
867 /// provided by an infrastructure provider.
868 ///
869 /// This field is completely optional, when filled, the MachineHealthCheck controller
870 /// creates a new object from the template referenced and hands off remediation of the machine to
871 /// a controller that lives outside of Cluster API.
872 #[serde(
873 default,
874 skip_serializing_if = "Option::is_none",
875 rename = "templateRef"
876 )]
877 pub template_ref:
878 Option<ClusterTopologyWorkersMachineDeploymentsHealthCheckRemediationTemplateRef>,
879 /// triggerIf configures if remediations are triggered.
880 /// If this field is not set, remediations are always triggered.
881 #[serde(default, skip_serializing_if = "Option::is_none", rename = "triggerIf")]
882 pub trigger_if: Option<ClusterTopologyWorkersMachineDeploymentsHealthCheckRemediationTriggerIf>,
883}
884
885/// templateRef is a reference to a remediation template
886/// provided by an infrastructure provider.
887///
888/// This field is completely optional, when filled, the MachineHealthCheck controller
889/// creates a new object from the template referenced and hands off remediation of the machine to
890/// a controller that lives outside of Cluster API.
891#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
892pub struct ClusterTopologyWorkersMachineDeploymentsHealthCheckRemediationTemplateRef {
893 /// apiVersion of the remediation template.
894 /// apiVersion must be fully qualified domain name followed by / and a version.
895 /// NOTE: This field must be kept in sync with the APIVersion of the remediation template.
896 #[serde(rename = "apiVersion")]
897 pub api_version: String,
898 /// kind of the remediation template.
899 /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
900 pub kind: String,
901 /// name of the remediation template.
902 /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
903 pub name: String,
904}
905
906/// triggerIf configures if remediations are triggered.
907/// If this field is not set, remediations are always triggered.
908#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
909pub struct ClusterTopologyWorkersMachineDeploymentsHealthCheckRemediationTriggerIf {
910 /// unhealthyInRange specifies that remediations are only triggered if the number of
911 /// unhealthy Machines is in the configured range.
912 /// Takes precedence over unhealthyLessThanOrEqualTo.
913 /// Eg. "[3-5]" - This means that remediation will be allowed only when:
914 /// (a) there are at least 3 unhealthy Machines (and)
915 /// (b) there are at most 5 unhealthy Machines
916 #[serde(
917 default,
918 skip_serializing_if = "Option::is_none",
919 rename = "unhealthyInRange"
920 )]
921 pub unhealthy_in_range: Option<String>,
922 /// unhealthyLessThanOrEqualTo specifies that remediations are only triggered if the number of
923 /// unhealthy Machines is less than or equal to the configured value.
924 /// unhealthyInRange takes precedence if set.
925 #[serde(
926 default,
927 skip_serializing_if = "Option::is_none",
928 rename = "unhealthyLessThanOrEqualTo"
929 )]
930 pub unhealthy_less_than_or_equal_to: Option<IntOrString>,
931}
932
933/// metadata is the metadata applied to the MachineDeployment and the machines of the MachineDeployment.
934/// At runtime this metadata is merged with the corresponding metadata from the ClusterClass.
935#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
936pub struct ClusterTopologyWorkersMachineDeploymentsMetadata {
937 /// annotations is an unstructured key value map stored with a resource that may be
938 /// set by external tools to store and retrieve arbitrary metadata. They are not
939 /// queryable and should be preserved when modifying objects.
940 /// More info: <http://kubernetes.io/docs/user-guide/annotations>
941 #[serde(default, skip_serializing_if = "Option::is_none")]
942 pub annotations: Option<BTreeMap<String, String>>,
943 /// labels is a map of string keys and values that can be used to organize and categorize
944 /// (scope and select) objects. May match selectors of replication controllers
945 /// and services.
946 /// More info: <http://kubernetes.io/docs/user-guide/labels>
947 #[serde(default, skip_serializing_if = "Option::is_none")]
948 pub labels: Option<BTreeMap<String, String>>,
949}
950
951/// MachineReadinessGate contains the type of a Machine condition to be used as a readiness gate.
952#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
953pub struct ClusterTopologyWorkersMachineDeploymentsReadinessGates {
954 /// conditionType refers to a condition with matching type in the Machine's condition list.
955 /// If the conditions doesn't exist, it will be treated as unknown.
956 /// Note: Both Cluster API conditions or conditions added by 3rd party controllers can be used as readiness gates.
957 #[serde(rename = "conditionType")]
958 pub condition_type: String,
959 /// polarity of the conditionType specified in this readinessGate.
960 /// Valid values are Positive, Negative and omitted.
961 /// When omitted, the default behaviour will be Positive.
962 /// A positive polarity means that the condition should report a true status under normal conditions.
963 /// A negative polarity means that the condition should report a false status under normal conditions.
964 #[serde(default, skip_serializing_if = "Option::is_none")]
965 pub polarity: Option<ClusterTopologyWorkersMachineDeploymentsReadinessGatesPolarity>,
966}
967
968/// MachineReadinessGate contains the type of a Machine condition to be used as a readiness gate.
969#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
970pub enum ClusterTopologyWorkersMachineDeploymentsReadinessGatesPolarity {
971 Positive,
972 Negative,
973}
974
975/// rollout allows you to configure the behaviour of rolling updates to the MachineDeployment Machines.
976/// It allows you to define the strategy used during rolling replacements.
977#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
978pub struct ClusterTopologyWorkersMachineDeploymentsRollout {
979 /// strategy specifies how to roll out control plane Machines.
980 #[serde(default, skip_serializing_if = "Option::is_none")]
981 pub strategy: Option<ClusterTopologyWorkersMachineDeploymentsRolloutStrategy>,
982}
983
984/// strategy specifies how to roll out control plane Machines.
985#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
986pub struct ClusterTopologyWorkersMachineDeploymentsRolloutStrategy {
987 /// rollingUpdate is the rolling update config params. Present only if
988 /// type = RollingUpdate.
989 #[serde(
990 default,
991 skip_serializing_if = "Option::is_none",
992 rename = "rollingUpdate"
993 )]
994 pub rolling_update:
995 Option<ClusterTopologyWorkersMachineDeploymentsRolloutStrategyRollingUpdate>,
996 /// type of rollout. Allowed values are RollingUpdate and OnDelete.
997 /// Default is RollingUpdate.
998 #[serde(rename = "type")]
999 pub r#type: ClusterTopologyWorkersMachineDeploymentsRolloutStrategyType,
1000}
1001
1002/// rollingUpdate is the rolling update config params. Present only if
1003/// type = RollingUpdate.
1004#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1005pub struct ClusterTopologyWorkersMachineDeploymentsRolloutStrategyRollingUpdate {
1006 /// maxSurge is the maximum number of machines that can be scheduled above the
1007 /// desired number of machines.
1008 /// Value can be an absolute number (ex: 5) or a percentage of
1009 /// desired machines (ex: 10%).
1010 /// This can not be 0 if MaxUnavailable is 0.
1011 /// Absolute number is calculated from percentage by rounding up.
1012 /// Defaults to 1.
1013 /// Example: when this is set to 30%, the new MachineSet can be scaled
1014 /// up immediately when the rolling update starts, such that the total
1015 /// number of old and new machines do not exceed 130% of desired
1016 /// machines. Once old machines have been killed, new MachineSet can
1017 /// be scaled up further, ensuring that total number of machines running
1018 /// at any time during the update is at most 130% of desired machines.
1019 #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxSurge")]
1020 pub max_surge: Option<IntOrString>,
1021 /// maxUnavailable is the maximum number of machines that can be unavailable during the update.
1022 /// Value can be an absolute number (ex: 5) or a percentage of desired
1023 /// machines (ex: 10%).
1024 /// Absolute number is calculated from percentage by rounding down.
1025 /// This can not be 0 if MaxSurge is 0.
1026 /// Defaults to 0.
1027 /// Example: when this is set to 30%, the old MachineSet can be scaled
1028 /// down to 70% of desired machines immediately when the rolling update
1029 /// starts. Once new machines are ready, old MachineSet can be scaled
1030 /// down further, followed by scaling up the new MachineSet, ensuring
1031 /// that the total number of machines available at all times
1032 /// during the update is at least 70% of desired machines.
1033 #[serde(
1034 default,
1035 skip_serializing_if = "Option::is_none",
1036 rename = "maxUnavailable"
1037 )]
1038 pub max_unavailable: Option<IntOrString>,
1039}
1040
1041/// strategy specifies how to roll out control plane Machines.
1042#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
1043pub enum ClusterTopologyWorkersMachineDeploymentsRolloutStrategyType {
1044 RollingUpdate,
1045 OnDelete,
1046}
1047
1048/// variables can be used to customize the MachineDeployment through patches.
1049#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1050pub struct ClusterTopologyWorkersMachineDeploymentsVariables {
1051 /// overrides can be used to override Cluster level variables.
1052 #[serde(default, skip_serializing_if = "Option::is_none")]
1053 pub overrides: Option<Vec<ClusterTopologyWorkersMachineDeploymentsVariablesOverrides>>,
1054}
1055
1056/// ClusterVariable can be used to customize the Cluster through patches. Each ClusterVariable is associated with a
1057/// Variable definition in the ClusterClass `status` variables.
1058#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1059pub struct ClusterTopologyWorkersMachineDeploymentsVariablesOverrides {
1060 /// name of the variable.
1061 pub name: String,
1062 /// value of the variable.
1063 /// Note: the value will be validated against the schema of the corresponding ClusterClassVariable
1064 /// from the ClusterClass.
1065 /// Note: We have to use apiextensionsv1.JSON instead of a custom JSON type, because controller-tools has a
1066 /// hard-coded schema for apiextensionsv1.JSON which cannot be produced by another type via controller-tools,
1067 /// i.e. it is not possible to have no type field.
1068 /// Ref: <https://github.com/kubernetes-sigs/controller-tools/blob/d0e03a142d0ecdd5491593e941ee1d6b5d91dba6/pkg/crd/known_types.go#L106-L111>
1069 pub value: serde_json::Value,
1070}
1071
1072/// MachinePoolTopology specifies the different parameters for a pool of worker nodes in the topology.
1073/// This pool of nodes is managed by a MachinePool object whose lifecycle is managed by the Cluster controller.
1074#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1075pub struct ClusterTopologyWorkersMachinePools {
1076 /// class is the name of the MachinePoolClass used to create the pool of worker nodes.
1077 /// This should match one of the deployment classes defined in the ClusterClass object
1078 /// mentioned in the `Cluster.Spec.Class` field.
1079 pub class: String,
1080 /// deletion contains configuration options for Machine deletion.
1081 #[serde(default, skip_serializing_if = "Option::is_none")]
1082 pub deletion: Option<ClusterTopologyWorkersMachinePoolsDeletion>,
1083 /// failureDomains is the list of failure domains the machine pool will be created in.
1084 /// Must match a key in the FailureDomains map stored on the cluster object.
1085 #[serde(
1086 default,
1087 skip_serializing_if = "Option::is_none",
1088 rename = "failureDomains"
1089 )]
1090 pub failure_domains: Option<Vec<String>>,
1091 /// metadata is the metadata applied to the MachinePool.
1092 /// At runtime this metadata is merged with the corresponding metadata from the ClusterClass.
1093 #[serde(default, skip_serializing_if = "Option::is_none")]
1094 pub metadata: Option<ClusterTopologyWorkersMachinePoolsMetadata>,
1095 /// minReadySeconds is the minimum number of seconds for which a newly created machine pool should
1096 /// be ready.
1097 /// Defaults to 0 (machine will be considered available as soon as it
1098 /// is ready)
1099 #[serde(
1100 default,
1101 skip_serializing_if = "Option::is_none",
1102 rename = "minReadySeconds"
1103 )]
1104 pub min_ready_seconds: Option<i32>,
1105 /// name is the unique identifier for this MachinePoolTopology.
1106 /// The value is used with other unique identifiers to create a MachinePool's Name
1107 /// (e.g. cluster's name, etc). In case the name is greater than the allowed maximum length,
1108 /// the values are hashed together.
1109 pub name: String,
1110 /// replicas is the number of nodes belonging to this pool.
1111 /// If the value is nil, the MachinePool is created without the number of Replicas (defaulting to 1)
1112 /// and it's assumed that an external entity (like cluster autoscaler) is responsible for the management
1113 /// of this value.
1114 #[serde(default, skip_serializing_if = "Option::is_none")]
1115 pub replicas: Option<i32>,
1116 /// variables can be used to customize the MachinePool through patches.
1117 #[serde(default, skip_serializing_if = "Option::is_none")]
1118 pub variables: Option<ClusterTopologyWorkersMachinePoolsVariables>,
1119}
1120
1121/// deletion contains configuration options for Machine deletion.
1122#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1123pub struct ClusterTopologyWorkersMachinePoolsDeletion {
1124 /// nodeDeletionTimeoutSeconds defines how long the controller will attempt to delete the Node that the MachinePool
1125 /// hosts after the MachinePool is marked for deletion. A duration of 0 will retry deletion indefinitely.
1126 /// Defaults to 10 seconds.
1127 #[serde(
1128 default,
1129 skip_serializing_if = "Option::is_none",
1130 rename = "nodeDeletionTimeoutSeconds"
1131 )]
1132 pub node_deletion_timeout_seconds: Option<i32>,
1133 /// nodeDrainTimeoutSeconds is the total amount of time that the controller will spend on draining a node.
1134 /// The default value is 0, meaning that the node can be drained without any time limitations.
1135 /// NOTE: nodeDrainTimeoutSeconds is different from `kubectl drain --timeout`
1136 #[serde(
1137 default,
1138 skip_serializing_if = "Option::is_none",
1139 rename = "nodeDrainTimeoutSeconds"
1140 )]
1141 pub node_drain_timeout_seconds: Option<i32>,
1142 /// nodeVolumeDetachTimeoutSeconds is the total amount of time that the controller will spend on waiting for all volumes
1143 /// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
1144 #[serde(
1145 default,
1146 skip_serializing_if = "Option::is_none",
1147 rename = "nodeVolumeDetachTimeoutSeconds"
1148 )]
1149 pub node_volume_detach_timeout_seconds: Option<i32>,
1150}
1151
1152/// metadata is the metadata applied to the MachinePool.
1153/// At runtime this metadata is merged with the corresponding metadata from the ClusterClass.
1154#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1155pub struct ClusterTopologyWorkersMachinePoolsMetadata {
1156 /// annotations is an unstructured key value map stored with a resource that may be
1157 /// set by external tools to store and retrieve arbitrary metadata. They are not
1158 /// queryable and should be preserved when modifying objects.
1159 /// More info: <http://kubernetes.io/docs/user-guide/annotations>
1160 #[serde(default, skip_serializing_if = "Option::is_none")]
1161 pub annotations: Option<BTreeMap<String, String>>,
1162 /// labels is a map of string keys and values that can be used to organize and categorize
1163 /// (scope and select) objects. May match selectors of replication controllers
1164 /// and services.
1165 /// More info: <http://kubernetes.io/docs/user-guide/labels>
1166 #[serde(default, skip_serializing_if = "Option::is_none")]
1167 pub labels: Option<BTreeMap<String, String>>,
1168}
1169
1170/// variables can be used to customize the MachinePool through patches.
1171#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1172pub struct ClusterTopologyWorkersMachinePoolsVariables {
1173 /// overrides can be used to override Cluster level variables.
1174 #[serde(default, skip_serializing_if = "Option::is_none")]
1175 pub overrides: Option<Vec<ClusterTopologyWorkersMachinePoolsVariablesOverrides>>,
1176}
1177
1178/// ClusterVariable can be used to customize the Cluster through patches. Each ClusterVariable is associated with a
1179/// Variable definition in the ClusterClass `status` variables.
1180#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1181pub struct ClusterTopologyWorkersMachinePoolsVariablesOverrides {
1182 /// name of the variable.
1183 pub name: String,
1184 /// value of the variable.
1185 /// Note: the value will be validated against the schema of the corresponding ClusterClassVariable
1186 /// from the ClusterClass.
1187 /// Note: We have to use apiextensionsv1.JSON instead of a custom JSON type, because controller-tools has a
1188 /// hard-coded schema for apiextensionsv1.JSON which cannot be produced by another type via controller-tools,
1189 /// i.e. it is not possible to have no type field.
1190 /// Ref: <https://github.com/kubernetes-sigs/controller-tools/blob/d0e03a142d0ecdd5491593e941ee1d6b5d91dba6/pkg/crd/known_types.go#L106-L111>
1191 pub value: serde_json::Value,
1192}
1193
1194/// status is the observed state of Cluster.
1195#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1196pub struct ClusterStatus {
1197 /// conditions represents the observations of a Cluster's current state.
1198 /// Known condition types are Available, InfrastructureReady, ControlPlaneInitialized, ControlPlaneAvailable, WorkersAvailable, MachinesReady
1199 /// MachinesUpToDate, RemoteConnectionProbe, ScalingUp, ScalingDown, Remediating, Deleting, Paused.
1200 /// Additionally, a TopologyReconciled condition will be added in case the Cluster is referencing a ClusterClass / defining a managed Topology.
1201 #[serde(default, skip_serializing_if = "Option::is_none")]
1202 pub conditions: Option<Vec<Condition>>,
1203 /// controlPlane groups all the observations about Cluster's ControlPlane current state.
1204 #[serde(
1205 default,
1206 skip_serializing_if = "Option::is_none",
1207 rename = "controlPlane"
1208 )]
1209 pub control_plane: Option<ClusterStatusControlPlane>,
1210 /// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
1211 #[serde(default, skip_serializing_if = "Option::is_none")]
1212 pub deprecated: Option<ClusterStatusDeprecated>,
1213 /// failureDomains is a slice of failure domain objects synced from the infrastructure provider.
1214 #[serde(
1215 default,
1216 skip_serializing_if = "Option::is_none",
1217 rename = "failureDomains"
1218 )]
1219 pub failure_domains: Option<Vec<ClusterStatusFailureDomains>>,
1220 /// initialization provides observations of the Cluster initialization process.
1221 /// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial Cluster provisioning.
1222 #[serde(default, skip_serializing_if = "Option::is_none")]
1223 pub initialization: Option<ClusterStatusInitialization>,
1224 /// observedGeneration is the latest generation observed by the controller.
1225 #[serde(
1226 default,
1227 skip_serializing_if = "Option::is_none",
1228 rename = "observedGeneration"
1229 )]
1230 pub observed_generation: Option<i64>,
1231 /// phase represents the current phase of cluster actuation.
1232 #[serde(default, skip_serializing_if = "Option::is_none")]
1233 pub phase: Option<ClusterStatusPhase>,
1234 /// workers groups all the observations about Cluster's Workers current state.
1235 #[serde(default, skip_serializing_if = "Option::is_none")]
1236 pub workers: Option<ClusterStatusWorkers>,
1237}
1238
1239/// controlPlane groups all the observations about Cluster's ControlPlane current state.
1240#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1241pub struct ClusterStatusControlPlane {
1242 /// availableReplicas is the total number of available control plane machines in this cluster. A machine is considered available when Machine's Available condition is true.
1243 #[serde(
1244 default,
1245 skip_serializing_if = "Option::is_none",
1246 rename = "availableReplicas"
1247 )]
1248 pub available_replicas: Option<i32>,
1249 /// desiredReplicas is the total number of desired control plane machines in this cluster.
1250 #[serde(
1251 default,
1252 skip_serializing_if = "Option::is_none",
1253 rename = "desiredReplicas"
1254 )]
1255 pub desired_replicas: Option<i32>,
1256 /// readyReplicas is the total number of ready control plane machines in this cluster. A machine is considered ready when Machine's Ready condition is true.
1257 #[serde(
1258 default,
1259 skip_serializing_if = "Option::is_none",
1260 rename = "readyReplicas"
1261 )]
1262 pub ready_replicas: Option<i32>,
1263 /// replicas is the total number of control plane machines in this cluster.
1264 /// NOTE: replicas also includes machines still being provisioned or being deleted.
1265 #[serde(default, skip_serializing_if = "Option::is_none")]
1266 pub replicas: Option<i32>,
1267 /// upToDateReplicas is the number of up-to-date control plane machines in this cluster. A machine is considered up-to-date when Machine's UpToDate condition is true.
1268 #[serde(
1269 default,
1270 skip_serializing_if = "Option::is_none",
1271 rename = "upToDateReplicas"
1272 )]
1273 pub up_to_date_replicas: Option<i32>,
1274}
1275
1276/// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
1277#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1278pub struct ClusterStatusDeprecated {
1279 /// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
1280 #[serde(default, skip_serializing_if = "Option::is_none")]
1281 pub v1beta1: Option<ClusterStatusDeprecatedV1beta1>,
1282}
1283
1284/// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
1285#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1286pub struct ClusterStatusDeprecatedV1beta1 {
1287 /// conditions defines current service state of the cluster.
1288 ///
1289 /// Deprecated: This field is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see <https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md> for more details.
1290 #[serde(default, skip_serializing_if = "Option::is_none")]
1291 pub conditions: Option<Vec<Condition>>,
1292 /// failureMessage indicates that there is a fatal problem reconciling the
1293 /// state, and will be set to a descriptive error message.
1294 ///
1295 /// Deprecated: This field is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see <https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md> for more details.
1296 #[serde(
1297 default,
1298 skip_serializing_if = "Option::is_none",
1299 rename = "failureMessage"
1300 )]
1301 pub failure_message: Option<String>,
1302 /// failureReason indicates that there is a fatal problem reconciling the
1303 /// state, and will be set to a token value suitable for
1304 /// programmatic interpretation.
1305 ///
1306 /// Deprecated: This field is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see <https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md> for more details.
1307 #[serde(
1308 default,
1309 skip_serializing_if = "Option::is_none",
1310 rename = "failureReason"
1311 )]
1312 pub failure_reason: Option<String>,
1313}
1314
1315/// FailureDomain is the Schema for Cluster API failure domains.
1316/// It allows controllers to understand how many failure domains a cluster can optionally span across.
1317#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1318pub struct ClusterStatusFailureDomains {
1319 /// attributes is a free form map of attributes an infrastructure provider might use or require.
1320 #[serde(default, skip_serializing_if = "Option::is_none")]
1321 pub attributes: Option<BTreeMap<String, String>>,
1322 /// controlPlane determines if this failure domain is suitable for use by control plane machines.
1323 #[serde(
1324 default,
1325 skip_serializing_if = "Option::is_none",
1326 rename = "controlPlane"
1327 )]
1328 pub control_plane: Option<bool>,
1329 /// name is the name of the failure domain.
1330 pub name: String,
1331}
1332
1333/// initialization provides observations of the Cluster initialization process.
1334/// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial Cluster provisioning.
1335#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1336pub struct ClusterStatusInitialization {
1337 /// controlPlaneInitialized denotes when the control plane is functional enough to accept requests.
1338 /// This information is usually used as a signal for starting all the provisioning operations that depends on
1339 /// a functional API server, but do not require a full HA control plane to exists, like e.g. join worker Machines,
1340 /// install core addons like CNI, CPI, CSI etc.
1341 /// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate provisioning.
1342 /// The value of this field is never updated after initialization is completed.
1343 #[serde(
1344 default,
1345 skip_serializing_if = "Option::is_none",
1346 rename = "controlPlaneInitialized"
1347 )]
1348 pub control_plane_initialized: Option<bool>,
1349 /// infrastructureProvisioned is true when the infrastructure provider reports that Cluster's infrastructure is fully provisioned.
1350 /// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate provisioning.
1351 /// The value of this field is never updated after provisioning is completed.
1352 #[serde(
1353 default,
1354 skip_serializing_if = "Option::is_none",
1355 rename = "infrastructureProvisioned"
1356 )]
1357 pub infrastructure_provisioned: Option<bool>,
1358}
1359
1360/// status is the observed state of Cluster.
1361#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
1362pub enum ClusterStatusPhase {
1363 Pending,
1364 Provisioning,
1365 Provisioned,
1366 Deleting,
1367 Failed,
1368 Unknown,
1369}
1370
1371/// workers groups all the observations about Cluster's Workers current state.
1372#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
1373pub struct ClusterStatusWorkers {
1374 /// availableReplicas is the total number of available worker machines in this cluster. A machine is considered available when Machine's Available condition is true.
1375 #[serde(
1376 default,
1377 skip_serializing_if = "Option::is_none",
1378 rename = "availableReplicas"
1379 )]
1380 pub available_replicas: Option<i32>,
1381 /// desiredReplicas is the total number of desired worker machines in this cluster.
1382 #[serde(
1383 default,
1384 skip_serializing_if = "Option::is_none",
1385 rename = "desiredReplicas"
1386 )]
1387 pub desired_replicas: Option<i32>,
1388 /// readyReplicas is the total number of ready worker machines in this cluster. A machine is considered ready when Machine's Ready condition is true.
1389 #[serde(
1390 default,
1391 skip_serializing_if = "Option::is_none",
1392 rename = "readyReplicas"
1393 )]
1394 pub ready_replicas: Option<i32>,
1395 /// replicas is the total number of worker machines in this cluster.
1396 /// NOTE: replicas also includes machines still being provisioned or being deleted.
1397 #[serde(default, skip_serializing_if = "Option::is_none")]
1398 pub replicas: Option<i32>,
1399 /// upToDateReplicas is the number of up-to-date worker machines in this cluster. A machine is considered up-to-date when Machine's UpToDate condition is true.
1400 #[serde(
1401 default,
1402 skip_serializing_if = "Option::is_none",
1403 rename = "upToDateReplicas"
1404 )]
1405 pub up_to_date_replicas: Option<i32>,
1406}