cluster_api_rs/api/capi_machine.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 kube::CustomResource;
9 pub use schemars::JsonSchema;
10 pub use serde::{Deserialize, Serialize};
11}
12
13use self::prelude::*;
14
15/// spec is the desired state of Machine.
16#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
17#[kube(
18 group = "cluster.x-k8s.io",
19 version = "v1beta2",
20 kind = "Machine",
21 plural = "machines"
22)]
23#[kube(namespaced)]
24#[kube(status = "MachineStatus")]
25#[kube(derive = "Default")]
26#[kube(derive = "PartialEq")]
27pub struct MachineSpec {
28 /// bootstrap is a reference to a local struct which encapsulates
29 /// fields to configure the Machine’s bootstrapping mechanism.
30 pub bootstrap: MachineBootstrap,
31 /// clusterName is the name of the Cluster this object belongs to.
32 #[serde(rename = "clusterName")]
33 pub cluster_name: String,
34 /// deletion contains configuration options for Machine deletion.
35 #[serde(default, skip_serializing_if = "Option::is_none")]
36 pub deletion: Option<MachineDeletion>,
37 /// failureDomain is the failure domain the machine will be created in.
38 /// Must match the name of a FailureDomain from the Cluster status.
39 #[serde(
40 default,
41 skip_serializing_if = "Option::is_none",
42 rename = "failureDomain"
43 )]
44 pub failure_domain: Option<String>,
45 /// infrastructureRef is a required reference to a custom resource
46 /// offered by an infrastructure provider.
47 #[serde(rename = "infrastructureRef")]
48 pub infrastructure_ref: MachineInfrastructureRef,
49 /// minReadySeconds is the minimum number of seconds for which a Machine should be ready before considering it available.
50 /// Defaults to 0 (Machine will be considered available as soon as the Machine is ready)
51 #[serde(
52 default,
53 skip_serializing_if = "Option::is_none",
54 rename = "minReadySeconds"
55 )]
56 pub min_ready_seconds: Option<i32>,
57 /// providerID is the identification ID of the machine provided by the provider.
58 /// This field must match the provider ID as seen on the node object corresponding to this machine.
59 /// This field is required by higher level consumers of cluster-api. Example use case is cluster autoscaler
60 /// with cluster-api as provider. Clean-up logic in the autoscaler compares machines to nodes to find out
61 /// machines at provider which could not get registered as Kubernetes nodes. With cluster-api as a
62 /// generic out-of-tree provider for autoscaler, this field is required by autoscaler to be
63 /// able to have a provider view of the list of machines. Another list of nodes is queried from the k8s apiserver
64 /// and then a comparison is done to find out unregistered machines and are marked for delete.
65 /// This field will be set by the actuators and consumed by higher level entities like autoscaler that will
66 /// be interfacing with cluster-api as generic provider.
67 #[serde(
68 default,
69 skip_serializing_if = "Option::is_none",
70 rename = "providerID"
71 )]
72 pub provider_id: Option<String>,
73 /// readinessGates specifies additional conditions to include when evaluating Machine Ready condition.
74 ///
75 /// This field can be used e.g. by Cluster API control plane providers to extend the semantic of the
76 /// Ready condition for the Machine they control, like the kubeadm control provider adding ReadinessGates
77 /// for the APIServerPodHealthy, SchedulerPodHealthy conditions, etc.
78 ///
79 /// Another example are external controllers, e.g. responsible to install special software/hardware on the Machines;
80 /// they can include the status of those components with a new condition and add this condition to ReadinessGates.
81 ///
82 /// NOTE: In case readinessGates conditions start with the APIServer, ControllerManager, Scheduler prefix, and all those
83 /// readiness gates condition are reporting the same message, when computing the Machine's Ready condition those
84 /// readinessGates will be replaced by a single entry reporting "Control plane components: " + message.
85 /// This helps to improve readability of conditions bubbling up to the Machine's owner resource / to the Cluster).
86 #[serde(
87 default,
88 skip_serializing_if = "Option::is_none",
89 rename = "readinessGates"
90 )]
91 pub readiness_gates: Option<Vec<MachineReadinessGates>>,
92 /// version defines the desired Kubernetes version.
93 /// This field is meant to be optionally used by bootstrap providers.
94 #[serde(default, skip_serializing_if = "Option::is_none")]
95 pub version: Option<String>,
96}
97
98/// bootstrap is a reference to a local struct which encapsulates
99/// fields to configure the Machine’s bootstrapping mechanism.
100#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
101pub struct MachineBootstrap {
102 /// configRef is a reference to a bootstrap provider-specific resource
103 /// that holds configuration details. The reference is optional to
104 /// allow users/operators to specify Bootstrap.DataSecretName without
105 /// the need of a controller.
106 #[serde(default, skip_serializing_if = "Option::is_none", rename = "configRef")]
107 pub config_ref: Option<MachineBootstrapConfigRef>,
108 /// dataSecretName is the name of the secret that stores the bootstrap data script.
109 /// If nil, the Machine should remain in the Pending state.
110 #[serde(
111 default,
112 skip_serializing_if = "Option::is_none",
113 rename = "dataSecretName"
114 )]
115 pub data_secret_name: Option<String>,
116}
117
118/// configRef is a reference to a bootstrap provider-specific resource
119/// that holds configuration details. The reference is optional to
120/// allow users/operators to specify Bootstrap.DataSecretName without
121/// the need of a controller.
122#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
123pub struct MachineBootstrapConfigRef {
124 /// apiGroup is the group of the resource being referenced.
125 /// apiGroup must be fully qualified domain name.
126 /// The corresponding version for this reference will be looked up from the contract
127 /// labels of the corresponding CRD of the resource being referenced.
128 #[serde(rename = "apiGroup")]
129 pub api_group: String,
130 /// kind of the resource being referenced.
131 /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
132 pub kind: String,
133 /// name of the resource being referenced.
134 /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
135 pub name: String,
136}
137
138/// deletion contains configuration options for Machine deletion.
139#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
140pub struct MachineDeletion {
141 /// nodeDeletionTimeoutSeconds defines how long the controller will attempt to delete the Node that the Machine
142 /// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
143 /// Defaults to 10 seconds.
144 #[serde(
145 default,
146 skip_serializing_if = "Option::is_none",
147 rename = "nodeDeletionTimeoutSeconds"
148 )]
149 pub node_deletion_timeout_seconds: Option<i32>,
150 /// nodeDrainTimeoutSeconds is the total amount of time that the controller will spend on draining a node.
151 /// The default value is 0, meaning that the node can be drained without any time limitations.
152 /// NOTE: nodeDrainTimeoutSeconds is different from `kubectl drain --timeout`
153 #[serde(
154 default,
155 skip_serializing_if = "Option::is_none",
156 rename = "nodeDrainTimeoutSeconds"
157 )]
158 pub node_drain_timeout_seconds: Option<i32>,
159 /// nodeVolumeDetachTimeoutSeconds is the total amount of time that the controller will spend on waiting for all volumes
160 /// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
161 #[serde(
162 default,
163 skip_serializing_if = "Option::is_none",
164 rename = "nodeVolumeDetachTimeoutSeconds"
165 )]
166 pub node_volume_detach_timeout_seconds: Option<i32>,
167}
168
169/// infrastructureRef is a required reference to a custom resource
170/// offered by an infrastructure provider.
171#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
172pub struct MachineInfrastructureRef {
173 /// apiGroup is the group of the resource being referenced.
174 /// apiGroup must be fully qualified domain name.
175 /// The corresponding version for this reference will be looked up from the contract
176 /// labels of the corresponding CRD of the resource being referenced.
177 #[serde(rename = "apiGroup")]
178 pub api_group: String,
179 /// kind of the resource being referenced.
180 /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
181 pub kind: String,
182 /// name of the resource being referenced.
183 /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
184 pub name: String,
185}
186
187/// MachineReadinessGate contains the type of a Machine condition to be used as a readiness gate.
188#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
189pub struct MachineReadinessGates {
190 /// conditionType refers to a condition with matching type in the Machine's condition list.
191 /// If the conditions doesn't exist, it will be treated as unknown.
192 /// Note: Both Cluster API conditions or conditions added by 3rd party controllers can be used as readiness gates.
193 #[serde(rename = "conditionType")]
194 pub condition_type: String,
195 /// polarity of the conditionType specified in this readinessGate.
196 /// Valid values are Positive, Negative and omitted.
197 /// When omitted, the default behaviour will be Positive.
198 /// A positive polarity means that the condition should report a true status under normal conditions.
199 /// A negative polarity means that the condition should report a false status under normal conditions.
200 #[serde(default, skip_serializing_if = "Option::is_none")]
201 pub polarity: Option<MachineReadinessGatesPolarity>,
202}
203
204/// MachineReadinessGate contains the type of a Machine condition to be used as a readiness gate.
205#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
206pub enum MachineReadinessGatesPolarity {
207 Positive,
208 Negative,
209}
210
211/// status is the observed state of Machine.
212#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
213pub struct MachineStatus {
214 /// addresses is a list of addresses assigned to the machine.
215 /// This field is copied from the infrastructure provider reference.
216 #[serde(default, skip_serializing_if = "Option::is_none")]
217 pub addresses: Option<Vec<MachineStatusAddresses>>,
218 /// certificatesExpiryDate is the expiry date of the machine certificates.
219 /// This value is only set for control plane machines.
220 #[serde(
221 default,
222 skip_serializing_if = "Option::is_none",
223 rename = "certificatesExpiryDate"
224 )]
225 pub certificates_expiry_date: Option<String>,
226 /// conditions represents the observations of a Machine's current state.
227 /// Known condition types are Available, Ready, UpToDate, BootstrapConfigReady, InfrastructureReady, NodeReady,
228 /// NodeHealthy, Deleting, Paused.
229 /// If a MachineHealthCheck is targeting this machine, also HealthCheckSucceeded, OwnerRemediated conditions are added.
230 /// Additionally control plane Machines controlled by KubeadmControlPlane will have following additional conditions:
231 /// APIServerPodHealthy, ControllerManagerPodHealthy, SchedulerPodHealthy, EtcdPodHealthy, EtcdMemberHealthy.
232 #[serde(default, skip_serializing_if = "Option::is_none")]
233 pub conditions: Option<Vec<Condition>>,
234 /// deletion contains information relating to removal of the Machine.
235 /// Only present when the Machine has a deletionTimestamp and drain or wait for volume detach started.
236 #[serde(default, skip_serializing_if = "Option::is_none")]
237 pub deletion: Option<MachineStatusDeletion>,
238 /// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
239 #[serde(default, skip_serializing_if = "Option::is_none")]
240 pub deprecated: Option<MachineStatusDeprecated>,
241 /// initialization provides observations of the Machine initialization process.
242 /// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial Machine provisioning.
243 #[serde(default, skip_serializing_if = "Option::is_none")]
244 pub initialization: Option<MachineStatusInitialization>,
245 /// lastUpdated identifies when the phase of the Machine last transitioned.
246 #[serde(
247 default,
248 skip_serializing_if = "Option::is_none",
249 rename = "lastUpdated"
250 )]
251 pub last_updated: Option<String>,
252 /// nodeInfo is a set of ids/uuids to uniquely identify the node.
253 /// More info: <https://kubernetes.io/docs/concepts/nodes/node/#info>
254 #[serde(default, skip_serializing_if = "Option::is_none", rename = "nodeInfo")]
255 pub node_info: Option<MachineStatusNodeInfo>,
256 /// nodeRef will point to the corresponding Node if it exists.
257 #[serde(default, skip_serializing_if = "Option::is_none", rename = "nodeRef")]
258 pub node_ref: Option<MachineStatusNodeRef>,
259 /// observedGeneration is the latest generation observed by the controller.
260 #[serde(
261 default,
262 skip_serializing_if = "Option::is_none",
263 rename = "observedGeneration"
264 )]
265 pub observed_generation: Option<i64>,
266 /// phase represents the current phase of machine actuation.
267 #[serde(default, skip_serializing_if = "Option::is_none")]
268 pub phase: Option<MachineStatusPhase>,
269}
270
271/// MachineAddress contains information for the node's address.
272#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
273pub struct MachineStatusAddresses {
274 /// address is the machine address.
275 pub address: String,
276 /// type is the machine address type, one of Hostname, ExternalIP, InternalIP, ExternalDNS or InternalDNS.
277 #[serde(rename = "type")]
278 pub r#type: MachineStatusAddressesType,
279}
280
281/// MachineAddress contains information for the node's address.
282#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
283pub enum MachineStatusAddressesType {
284 Hostname,
285 #[serde(rename = "ExternalIP")]
286 ExternalIp,
287 #[serde(rename = "InternalIP")]
288 InternalIp,
289 #[serde(rename = "ExternalDNS")]
290 ExternalDns,
291 #[serde(rename = "InternalDNS")]
292 InternalDns,
293}
294
295/// deletion contains information relating to removal of the Machine.
296/// Only present when the Machine has a deletionTimestamp and drain or wait for volume detach started.
297#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
298pub struct MachineStatusDeletion {
299 /// nodeDrainStartTime is the time when the drain of the node started and is used to determine
300 /// if the nodeDrainTimeoutSeconds is exceeded.
301 /// Only present when the Machine has a deletionTimestamp and draining the node had been started.
302 #[serde(
303 default,
304 skip_serializing_if = "Option::is_none",
305 rename = "nodeDrainStartTime"
306 )]
307 pub node_drain_start_time: Option<String>,
308 /// waitForNodeVolumeDetachStartTime is the time when waiting for volume detachment started
309 /// and is used to determine if the nodeVolumeDetachTimeoutSeconds is exceeded.
310 /// Detaching volumes from nodes is usually done by CSI implementations and the current state
311 /// is observed from the node's `.Status.VolumesAttached` field.
312 /// Only present when the Machine has a deletionTimestamp and waiting for volume detachments had been started.
313 #[serde(
314 default,
315 skip_serializing_if = "Option::is_none",
316 rename = "waitForNodeVolumeDetachStartTime"
317 )]
318 pub wait_for_node_volume_detach_start_time: Option<String>,
319}
320
321/// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
322#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
323pub struct MachineStatusDeprecated {
324 /// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
325 ///
326 /// 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.
327 #[serde(default, skip_serializing_if = "Option::is_none")]
328 pub v1beta1: Option<MachineStatusDeprecatedV1beta1>,
329}
330
331/// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
332///
333/// 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.
334#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
335pub struct MachineStatusDeprecatedV1beta1 {
336 /// conditions defines current service state of the Machine.
337 ///
338 /// 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.
339 #[serde(default, skip_serializing_if = "Option::is_none")]
340 pub conditions: Option<Vec<Condition>>,
341 /// failureMessage will be set in the event that there is a terminal problem
342 /// reconciling the Machine and will contain a more verbose string suitable
343 /// for logging and human consumption.
344 ///
345 /// This field should not be set for transitive errors that a controller
346 /// faces that are expected to be fixed automatically over
347 /// time (like service outages), but instead indicate that something is
348 /// fundamentally wrong with the Machine's spec or the configuration of
349 /// the controller, and that manual intervention is required. Examples
350 /// of terminal errors would be invalid combinations of settings in the
351 /// spec, values that are unsupported by the controller, or the
352 /// responsible controller itself being critically misconfigured.
353 ///
354 /// Any transient errors that occur during the reconciliation of Machines
355 /// can be added as events to the Machine object and/or logged in the
356 /// controller's output.
357 ///
358 /// 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.
359 #[serde(
360 default,
361 skip_serializing_if = "Option::is_none",
362 rename = "failureMessage"
363 )]
364 pub failure_message: Option<String>,
365 /// failureReason will be set in the event that there is a terminal problem
366 /// reconciling the Machine and will contain a succinct value suitable
367 /// for machine interpretation.
368 ///
369 /// This field should not be set for transitive errors that a controller
370 /// faces that are expected to be fixed automatically over
371 /// time (like service outages), but instead indicate that something is
372 /// fundamentally wrong with the Machine's spec or the configuration of
373 /// the controller, and that manual intervention is required. Examples
374 /// of terminal errors would be invalid combinations of settings in the
375 /// spec, values that are unsupported by the controller, or the
376 /// responsible controller itself being critically misconfigured.
377 ///
378 /// Any transient errors that occur during the reconciliation of Machines
379 /// can be added as events to the Machine object and/or logged in the
380 /// controller's output.
381 ///
382 /// 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.
383 #[serde(
384 default,
385 skip_serializing_if = "Option::is_none",
386 rename = "failureReason"
387 )]
388 pub failure_reason: Option<String>,
389}
390
391/// initialization provides observations of the Machine initialization process.
392/// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial Machine provisioning.
393#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
394pub struct MachineStatusInitialization {
395 /// bootstrapDataSecretCreated is true when the bootstrap provider reports that the Machine's boostrap secret is created.
396 /// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate provisioning.
397 /// The value of this field is never updated after provisioning is completed.
398 #[serde(
399 default,
400 skip_serializing_if = "Option::is_none",
401 rename = "bootstrapDataSecretCreated"
402 )]
403 pub bootstrap_data_secret_created: Option<bool>,
404 /// infrastructureProvisioned is true when the infrastructure provider reports that Machine's infrastructure is fully provisioned.
405 /// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate provisioning.
406 /// The value of this field is never updated after provisioning is completed.
407 #[serde(
408 default,
409 skip_serializing_if = "Option::is_none",
410 rename = "infrastructureProvisioned"
411 )]
412 pub infrastructure_provisioned: Option<bool>,
413}
414
415/// nodeInfo is a set of ids/uuids to uniquely identify the node.
416/// More info: <https://kubernetes.io/docs/concepts/nodes/node/#info>
417#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
418pub struct MachineStatusNodeInfo {
419 /// The Architecture reported by the node
420 pub architecture: String,
421 /// Boot ID reported by the node.
422 #[serde(rename = "bootID")]
423 pub boot_id: String,
424 /// ContainerRuntime Version reported by the node through runtime remote API (e.g. containerd://1.4.2).
425 #[serde(rename = "containerRuntimeVersion")]
426 pub container_runtime_version: String,
427 /// Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).
428 #[serde(rename = "kernelVersion")]
429 pub kernel_version: String,
430 /// Deprecated: KubeProxy Version reported by the node.
431 #[serde(rename = "kubeProxyVersion")]
432 pub kube_proxy_version: String,
433 /// Kubelet Version reported by the node.
434 #[serde(rename = "kubeletVersion")]
435 pub kubelet_version: String,
436 /// MachineID reported by the node. For unique machine identification
437 /// in the cluster this field is preferred. Learn more from man(5)
438 /// machine-id: <http://man7.org/linux/man-pages/man5/machine-id.5.html>
439 #[serde(rename = "machineID")]
440 pub machine_id: String,
441 /// The Operating System reported by the node
442 #[serde(rename = "operatingSystem")]
443 pub operating_system: String,
444 /// OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).
445 #[serde(rename = "osImage")]
446 pub os_image: String,
447 /// Swap Info reported by the node.
448 #[serde(default, skip_serializing_if = "Option::is_none")]
449 pub swap: Option<MachineStatusNodeInfoSwap>,
450 /// SystemUUID reported by the node. For unique machine identification
451 /// MachineID is preferred. This field is specific to Red Hat hosts
452 /// <https://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html/rhsm/uuid>
453 #[serde(rename = "systemUUID")]
454 pub system_uuid: String,
455}
456
457/// Swap Info reported by the node.
458#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
459pub struct MachineStatusNodeInfoSwap {
460 /// Total amount of swap memory in bytes.
461 #[serde(default, skip_serializing_if = "Option::is_none")]
462 pub capacity: Option<i64>,
463}
464
465/// nodeRef will point to the corresponding Node if it exists.
466#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
467pub struct MachineStatusNodeRef {
468 /// name of the node.
469 /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
470 pub name: String,
471}
472
473/// status is the observed state of Machine.
474#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
475pub enum MachineStatusPhase {
476 Pending,
477 Provisioning,
478 Provisioned,
479 Running,
480 Deleting,
481 Deleted,
482 Failed,
483 Unknown,
484}