cluster_api_rs/api/
capi_machinepool.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::api::core::v1::ObjectReference;
8    pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
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 MachinePool.
18#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
19#[kube(
20    group = "cluster.x-k8s.io",
21    version = "v1beta2",
22    kind = "MachinePool",
23    plural = "machinepools"
24)]
25#[kube(namespaced)]
26#[kube(status = "MachinePoolStatus")]
27#[kube(derive = "Default")]
28#[kube(derive = "PartialEq")]
29pub struct MachinePoolSpec {
30    /// clusterName is the name of the Cluster this object belongs to.
31    #[serde(rename = "clusterName")]
32    pub cluster_name: String,
33    /// failureDomains is the list of failure domains this MachinePool should be attached to.
34    #[serde(
35        default,
36        skip_serializing_if = "Option::is_none",
37        rename = "failureDomains"
38    )]
39    pub failure_domains: Option<Vec<String>>,
40    /// providerIDList are the identification IDs of machine instances provided by the provider.
41    /// This field must match the provider IDs as seen on the node objects corresponding to a machine pool's machine instances.
42    #[serde(
43        default,
44        skip_serializing_if = "Option::is_none",
45        rename = "providerIDList"
46    )]
47    pub provider_id_list: Option<Vec<String>>,
48    /// replicas is the number of desired machines. Defaults to 1.
49    /// This is a pointer to distinguish between explicit zero and not specified.
50    #[serde(default, skip_serializing_if = "Option::is_none")]
51    pub replicas: Option<i32>,
52    /// template describes the machines that will be created.
53    pub template: MachinePoolTemplate,
54}
55
56/// template describes the machines that will be created.
57#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
58pub struct MachinePoolTemplate {
59    /// metadata is the standard object's metadata.
60    /// More info: <https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata>
61    #[serde(default, skip_serializing_if = "Option::is_none")]
62    pub metadata: Option<MachinePoolTemplateMetadata>,
63    /// spec is the specification of the desired behavior of the machine.
64    /// More info: <https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status>
65    pub spec: MachinePoolTemplateSpec,
66}
67
68/// metadata is the standard object's metadata.
69/// More info: <https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata>
70#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
71pub struct MachinePoolTemplateMetadata {
72    /// annotations is an unstructured key value map stored with a resource that may be
73    /// set by external tools to store and retrieve arbitrary metadata. They are not
74    /// queryable and should be preserved when modifying objects.
75    /// More info: <http://kubernetes.io/docs/user-guide/annotations>
76    #[serde(default, skip_serializing_if = "Option::is_none")]
77    pub annotations: Option<BTreeMap<String, String>>,
78    /// labels is a map of string keys and values that can be used to organize and categorize
79    /// (scope and select) objects. May match selectors of replication controllers
80    /// and services.
81    /// More info: <http://kubernetes.io/docs/user-guide/labels>
82    #[serde(default, skip_serializing_if = "Option::is_none")]
83    pub labels: Option<BTreeMap<String, String>>,
84}
85
86/// spec is the specification of the desired behavior of the machine.
87/// More info: <https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status>
88#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
89pub struct MachinePoolTemplateSpec {
90    /// bootstrap is a reference to a local struct which encapsulates
91    /// fields to configure the Machine’s bootstrapping mechanism.
92    pub bootstrap: MachinePoolTemplateSpecBootstrap,
93    /// clusterName is the name of the Cluster this object belongs to.
94    #[serde(rename = "clusterName")]
95    pub cluster_name: String,
96    /// deletion contains configuration options for Machine deletion.
97    #[serde(default, skip_serializing_if = "Option::is_none")]
98    pub deletion: Option<MachinePoolTemplateSpecDeletion>,
99    /// failureDomain is the failure domain the machine will be created in.
100    /// Must match the name of a FailureDomain from the Cluster status.
101    #[serde(
102        default,
103        skip_serializing_if = "Option::is_none",
104        rename = "failureDomain"
105    )]
106    pub failure_domain: Option<String>,
107    /// infrastructureRef is a required reference to a custom resource
108    /// offered by an infrastructure provider.
109    #[serde(rename = "infrastructureRef")]
110    pub infrastructure_ref: MachinePoolTemplateSpecInfrastructureRef,
111    /// minReadySeconds is the minimum number of seconds for which a Machine should be ready before considering it available.
112    /// Defaults to 0 (Machine will be considered available as soon as the Machine is ready)
113    #[serde(
114        default,
115        skip_serializing_if = "Option::is_none",
116        rename = "minReadySeconds"
117    )]
118    pub min_ready_seconds: Option<i32>,
119    /// providerID is the identification ID of the machine provided by the provider.
120    /// This field must match the provider ID as seen on the node object corresponding to this machine.
121    /// This field is required by higher level consumers of cluster-api. Example use case is cluster autoscaler
122    /// with cluster-api as provider. Clean-up logic in the autoscaler compares machines to nodes to find out
123    /// machines at provider which could not get registered as Kubernetes nodes. With cluster-api as a
124    /// generic out-of-tree provider for autoscaler, this field is required by autoscaler to be
125    /// able to have a provider view of the list of machines. Another list of nodes is queried from the k8s apiserver
126    /// and then a comparison is done to find out unregistered machines and are marked for delete.
127    /// This field will be set by the actuators and consumed by higher level entities like autoscaler that will
128    /// be interfacing with cluster-api as generic provider.
129    #[serde(
130        default,
131        skip_serializing_if = "Option::is_none",
132        rename = "providerID"
133    )]
134    pub provider_id: Option<String>,
135    /// readinessGates specifies additional conditions to include when evaluating Machine Ready condition.
136    ///
137    /// This field can be used e.g. by Cluster API control plane providers to extend the semantic of the
138    /// Ready condition for the Machine they control, like the kubeadm control provider adding ReadinessGates
139    /// for the APIServerPodHealthy, SchedulerPodHealthy conditions, etc.
140    ///
141    /// Another example are external controllers, e.g. responsible to install special software/hardware on the Machines;
142    /// they can include the status of those components with a new condition and add this condition to ReadinessGates.
143    ///
144    /// NOTE: In case readinessGates conditions start with the APIServer, ControllerManager, Scheduler prefix, and all those
145    /// readiness gates condition are reporting the same message, when computing the Machine's Ready condition those
146    /// readinessGates will be replaced by a single entry reporting "Control plane components: " + message.
147    /// This helps to improve readability of conditions bubbling up to the Machine's owner resource / to the Cluster).
148    #[serde(
149        default,
150        skip_serializing_if = "Option::is_none",
151        rename = "readinessGates"
152    )]
153    pub readiness_gates: Option<Vec<MachinePoolTemplateSpecReadinessGates>>,
154    /// version defines the desired Kubernetes version.
155    /// This field is meant to be optionally used by bootstrap providers.
156    #[serde(default, skip_serializing_if = "Option::is_none")]
157    pub version: Option<String>,
158}
159
160/// bootstrap is a reference to a local struct which encapsulates
161/// fields to configure the Machine’s bootstrapping mechanism.
162#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
163pub struct MachinePoolTemplateSpecBootstrap {
164    /// configRef is a reference to a bootstrap provider-specific resource
165    /// that holds configuration details. The reference is optional to
166    /// allow users/operators to specify Bootstrap.DataSecretName without
167    /// the need of a controller.
168    #[serde(default, skip_serializing_if = "Option::is_none", rename = "configRef")]
169    pub config_ref: Option<MachinePoolTemplateSpecBootstrapConfigRef>,
170    /// dataSecretName is the name of the secret that stores the bootstrap data script.
171    /// If nil, the Machine should remain in the Pending state.
172    #[serde(
173        default,
174        skip_serializing_if = "Option::is_none",
175        rename = "dataSecretName"
176    )]
177    pub data_secret_name: Option<String>,
178}
179
180/// configRef is a reference to a bootstrap provider-specific resource
181/// that holds configuration details. The reference is optional to
182/// allow users/operators to specify Bootstrap.DataSecretName without
183/// the need of a controller.
184#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
185pub struct MachinePoolTemplateSpecBootstrapConfigRef {
186    /// apiGroup is the group of the resource being referenced.
187    /// apiGroup must be fully qualified domain name.
188    /// The corresponding version for this reference will be looked up from the contract
189    /// labels of the corresponding CRD of the resource being referenced.
190    #[serde(rename = "apiGroup")]
191    pub api_group: String,
192    /// kind of the resource being referenced.
193    /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
194    pub kind: String,
195    /// name of the resource being referenced.
196    /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
197    pub name: String,
198}
199
200/// deletion contains configuration options for Machine deletion.
201#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
202pub struct MachinePoolTemplateSpecDeletion {
203    /// nodeDeletionTimeoutSeconds defines how long the controller will attempt to delete the Node that the Machine
204    /// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
205    /// Defaults to 10 seconds.
206    #[serde(
207        default,
208        skip_serializing_if = "Option::is_none",
209        rename = "nodeDeletionTimeoutSeconds"
210    )]
211    pub node_deletion_timeout_seconds: Option<i32>,
212    /// nodeDrainTimeoutSeconds is the total amount of time that the controller will spend on draining a node.
213    /// The default value is 0, meaning that the node can be drained without any time limitations.
214    /// NOTE: nodeDrainTimeoutSeconds is different from `kubectl drain --timeout`
215    #[serde(
216        default,
217        skip_serializing_if = "Option::is_none",
218        rename = "nodeDrainTimeoutSeconds"
219    )]
220    pub node_drain_timeout_seconds: Option<i32>,
221    /// nodeVolumeDetachTimeoutSeconds is the total amount of time that the controller will spend on waiting for all volumes
222    /// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
223    #[serde(
224        default,
225        skip_serializing_if = "Option::is_none",
226        rename = "nodeVolumeDetachTimeoutSeconds"
227    )]
228    pub node_volume_detach_timeout_seconds: Option<i32>,
229}
230
231/// infrastructureRef is a required reference to a custom resource
232/// offered by an infrastructure provider.
233#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
234pub struct MachinePoolTemplateSpecInfrastructureRef {
235    /// apiGroup is the group of the resource being referenced.
236    /// apiGroup must be fully qualified domain name.
237    /// The corresponding version for this reference will be looked up from the contract
238    /// labels of the corresponding CRD of the resource being referenced.
239    #[serde(rename = "apiGroup")]
240    pub api_group: String,
241    /// kind of the resource being referenced.
242    /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
243    pub kind: String,
244    /// name of the resource being referenced.
245    /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
246    pub name: String,
247}
248
249/// MachineReadinessGate contains the type of a Machine condition to be used as a readiness gate.
250#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
251pub struct MachinePoolTemplateSpecReadinessGates {
252    /// conditionType refers to a condition with matching type in the Machine's condition list.
253    /// If the conditions doesn't exist, it will be treated as unknown.
254    /// Note: Both Cluster API conditions or conditions added by 3rd party controllers can be used as readiness gates.
255    #[serde(rename = "conditionType")]
256    pub condition_type: String,
257    /// polarity of the conditionType specified in this readinessGate.
258    /// Valid values are Positive, Negative and omitted.
259    /// When omitted, the default behaviour will be Positive.
260    /// A positive polarity means that the condition should report a true status under normal conditions.
261    /// A negative polarity means that the condition should report a false status under normal conditions.
262    #[serde(default, skip_serializing_if = "Option::is_none")]
263    pub polarity: Option<MachinePoolTemplateSpecReadinessGatesPolarity>,
264}
265
266/// MachineReadinessGate contains the type of a Machine condition to be used as a readiness gate.
267#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
268pub enum MachinePoolTemplateSpecReadinessGatesPolarity {
269    Positive,
270    Negative,
271}
272
273/// status is the observed state of MachinePool.
274#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
275pub struct MachinePoolStatus {
276    /// availableReplicas is the number of available replicas for this MachinePool. A machine is considered available when Machine's Available condition is true.
277    #[serde(
278        default,
279        skip_serializing_if = "Option::is_none",
280        rename = "availableReplicas"
281    )]
282    pub available_replicas: Option<i32>,
283    /// conditions represents the observations of a MachinePool's current state.
284    /// Known condition types are Available, BootstrapConfigReady, InfrastructureReady, MachinesReady, MachinesUpToDate,
285    /// ScalingUp, ScalingDown, Remediating, Deleting, Paused.
286    #[serde(default, skip_serializing_if = "Option::is_none")]
287    pub conditions: Option<Vec<Condition>>,
288    /// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
289    #[serde(default, skip_serializing_if = "Option::is_none")]
290    pub deprecated: Option<MachinePoolStatusDeprecated>,
291    /// initialization provides observations of the MachinePool initialization process.
292    /// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial MachinePool provisioning.
293    #[serde(default, skip_serializing_if = "Option::is_none")]
294    pub initialization: Option<MachinePoolStatusInitialization>,
295    /// nodeRefs will point to the corresponding Nodes if it they exist.
296    #[serde(default, skip_serializing_if = "Option::is_none", rename = "nodeRefs")]
297    pub node_refs: Option<Vec<ObjectReference>>,
298    /// observedGeneration is the latest generation observed by the controller.
299    #[serde(
300        default,
301        skip_serializing_if = "Option::is_none",
302        rename = "observedGeneration"
303    )]
304    pub observed_generation: Option<i64>,
305    /// phase represents the current phase of cluster actuation.
306    #[serde(default, skip_serializing_if = "Option::is_none")]
307    pub phase: Option<MachinePoolStatusPhase>,
308    /// readyReplicas is the number of ready replicas for this MachinePool. A machine is considered ready when Machine's Ready condition is true.
309    #[serde(
310        default,
311        skip_serializing_if = "Option::is_none",
312        rename = "readyReplicas"
313    )]
314    pub ready_replicas: Option<i32>,
315    /// replicas is the most recently observed number of replicas.
316    #[serde(default, skip_serializing_if = "Option::is_none")]
317    pub replicas: Option<i32>,
318    /// upToDateReplicas is the number of up-to-date replicas targeted by this MachinePool. A machine is considered up-to-date when Machine's UpToDate condition is true.
319    #[serde(
320        default,
321        skip_serializing_if = "Option::is_none",
322        rename = "upToDateReplicas"
323    )]
324    pub up_to_date_replicas: Option<i32>,
325}
326
327/// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
328#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
329pub struct MachinePoolStatusDeprecated {
330    /// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
331    #[serde(default, skip_serializing_if = "Option::is_none")]
332    pub v1beta1: Option<MachinePoolStatusDeprecatedV1beta1>,
333}
334
335/// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
336#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
337pub struct MachinePoolStatusDeprecatedV1beta1 {
338    /// availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachinePool.
339    ///
340    /// 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.
341    #[serde(
342        default,
343        skip_serializing_if = "Option::is_none",
344        rename = "availableReplicas"
345    )]
346    pub available_replicas: Option<i32>,
347    /// conditions define the current service state of the MachinePool.
348    ///
349    /// 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.
350    #[serde(default, skip_serializing_if = "Option::is_none")]
351    pub conditions: Option<Vec<Condition>>,
352    /// failureMessage indicates that there is a problem reconciling the state,
353    /// and will be set to a descriptive error message.
354    ///
355    /// 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.
356    #[serde(
357        default,
358        skip_serializing_if = "Option::is_none",
359        rename = "failureMessage"
360    )]
361    pub failure_message: Option<String>,
362    /// failureReason indicates that there is a problem reconciling the state, and
363    /// will be set to a token value suitable for programmatic interpretation.
364    ///
365    /// 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.
366    #[serde(
367        default,
368        skip_serializing_if = "Option::is_none",
369        rename = "failureReason"
370    )]
371    pub failure_reason: Option<String>,
372    /// readyReplicas is the number of ready replicas for this MachinePool. A machine is considered ready when the node has been created and is "Ready".
373    ///
374    /// 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.
375    #[serde(
376        default,
377        skip_serializing_if = "Option::is_none",
378        rename = "readyReplicas"
379    )]
380    pub ready_replicas: Option<i32>,
381    /// unavailableReplicas is the total number of unavailable machine instances targeted by this machine pool.
382    /// This is the total number of machine instances that are still required for
383    /// the machine pool to have 100% available capacity. They may either
384    /// be machine instances that are running but not yet available or machine instances
385    /// that still have not been created.
386    ///
387    /// 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.
388    #[serde(
389        default,
390        skip_serializing_if = "Option::is_none",
391        rename = "unavailableReplicas"
392    )]
393    pub unavailable_replicas: Option<i32>,
394}
395
396/// initialization provides observations of the MachinePool initialization process.
397/// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial MachinePool provisioning.
398#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
399pub struct MachinePoolStatusInitialization {
400    /// bootstrapDataSecretCreated is true when the bootstrap provider reports that the MachinePool's boostrap secret is created.
401    /// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate provisioning.
402    /// The value of this field is never updated after provisioning is completed.
403    #[serde(
404        default,
405        skip_serializing_if = "Option::is_none",
406        rename = "bootstrapDataSecretCreated"
407    )]
408    pub bootstrap_data_secret_created: Option<bool>,
409    /// infrastructureProvisioned is true when the infrastructure provider reports that MachinePool's infrastructure is fully provisioned.
410    /// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate provisioning.
411    /// The value of this field is never updated after provisioning is completed.
412    #[serde(
413        default,
414        skip_serializing_if = "Option::is_none",
415        rename = "infrastructureProvisioned"
416    )]
417    pub infrastructure_provisioned: Option<bool>,
418}
419
420/// status is the observed state of MachinePool.
421#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
422pub enum MachinePoolStatusPhase {
423    Pending,
424    Provisioning,
425    Provisioned,
426    Running,
427    ScalingUp,
428    ScalingDown,
429    Scaling,
430    Deleting,
431    Failed,
432    Unknown,
433}