cluster_api_rs/api/capi_machineset.rs
1// WARNING: generated by kopium - manual changes will be overwritten
2// kopium command: kopium -D Default -D PartialEq -A -d -f -
3// kopium version: 0.21.1
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}
14use self::prelude::*;
15
16/// MachineSetSpec defines the desired state of MachineSet.
17#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
18#[kube(
19    group = "cluster.x-k8s.io",
20    version = "v1beta1",
21    kind = "MachineSet",
22    plural = "machinesets"
23)]
24#[kube(namespaced)]
25#[kube(status = "MachineSetStatus")]
26#[kube(derive = "Default")]
27#[kube(derive = "PartialEq")]
28pub struct MachineSetSpec {
29    /// clusterName is the name of the Cluster this object belongs to.
30    #[serde(rename = "clusterName")]
31    pub cluster_name: String,
32    /// deletePolicy defines the policy used to identify nodes to delete when downscaling.
33    /// Defaults to "Random".  Valid values are "Random, "Newest", "Oldest"
34    #[serde(
35        default,
36        skip_serializing_if = "Option::is_none",
37        rename = "deletePolicy"
38    )]
39    pub delete_policy: Option<MachineSetDeletePolicy>,
40    /// minReadySeconds is the minimum number of seconds for which a Node for a newly created machine should be ready before considering the replica available.
41    /// Defaults to 0 (machine will be considered available as soon as the Node is ready)
42    #[serde(
43        default,
44        skip_serializing_if = "Option::is_none",
45        rename = "minReadySeconds"
46    )]
47    pub min_ready_seconds: Option<i32>,
48    /// replicas is the number of desired replicas.
49    /// This is a pointer to distinguish between explicit zero and unspecified.
50    ///
51    /// Defaults to:
52    /// * if the Kubernetes autoscaler min size and max size annotations are set:
53    ///   - if it's a new MachineSet, use min size
54    ///   - if the replicas field of the old MachineSet is < min size, use min size
55    ///   - if the replicas field of the old MachineSet is > max size, use max size
56    ///   - if the replicas field of the old MachineSet is in the (min size, max size) range, keep the value from the oldMS
57    /// * otherwise use 1
58    /// Note: Defaulting will be run whenever the replicas field is not set:
59    /// * A new MachineSet is created with replicas not set.
60    /// * On an existing MachineSet the replicas field was first set and is now unset.
61    /// Those cases are especially relevant for the following Kubernetes autoscaler use cases:
62    /// * A new MachineSet is created and replicas should be managed by the autoscaler
63    /// * An existing MachineSet which initially wasn't controlled by the autoscaler
64    ///   should be later controlled by the autoscaler
65    #[serde(default, skip_serializing_if = "Option::is_none")]
66    pub replicas: Option<i32>,
67    /// selector is a label query over machines that should match the replica count.
68    /// Label keys and values that must match in order to be controlled by this MachineSet.
69    /// It must match the machine template's labels.
70    /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
71    pub selector: MachineSetSelector,
72    /// template is the object that describes the machine that will be created if
73    /// insufficient replicas are detected.
74    /// Object references to custom resources are treated as templates.
75    #[serde(default, skip_serializing_if = "Option::is_none")]
76    pub template: Option<MachineSetTemplate>,
77}
78
79/// MachineSetSpec defines the desired state of MachineSet.
80#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
81pub enum MachineSetDeletePolicy {
82    Random,
83    Newest,
84    Oldest,
85}
86
87/// selector is a label query over machines that should match the replica count.
88/// Label keys and values that must match in order to be controlled by this MachineSet.
89/// It must match the machine template's labels.
90/// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
91#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
92pub struct MachineSetSelector {
93    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
94    #[serde(
95        default,
96        skip_serializing_if = "Option::is_none",
97        rename = "matchExpressions"
98    )]
99    pub match_expressions: Option<Vec<MachineSetSelectorMatchExpressions>>,
100    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
101    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
102    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
103    #[serde(
104        default,
105        skip_serializing_if = "Option::is_none",
106        rename = "matchLabels"
107    )]
108    pub match_labels: Option<BTreeMap<String, String>>,
109}
110
111/// A label selector requirement is a selector that contains values, a key, and an operator that
112/// relates the key and values.
113#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
114pub struct MachineSetSelectorMatchExpressions {
115    /// key is the label key that the selector applies to.
116    pub key: String,
117    /// operator represents a key's relationship to a set of values.
118    /// Valid operators are In, NotIn, Exists and DoesNotExist.
119    pub operator: String,
120    /// values is an array of string values. If the operator is In or NotIn,
121    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
122    /// the values array must be empty. This array is replaced during a strategic
123    /// merge patch.
124    #[serde(default, skip_serializing_if = "Option::is_none")]
125    pub values: Option<Vec<String>>,
126}
127
128/// template is the object that describes the machine that will be created if
129/// insufficient replicas are detected.
130/// Object references to custom resources are treated as templates.
131#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
132pub struct MachineSetTemplate {
133    /// Standard object's metadata.
134    /// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
135    #[serde(default, skip_serializing_if = "Option::is_none")]
136    pub metadata: Option<MachineSetTemplateMetadata>,
137    /// Specification of the desired behavior of the machine.
138    /// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
139    #[serde(default, skip_serializing_if = "Option::is_none")]
140    pub spec: Option<MachineSetTemplateSpec>,
141}
142
143/// Standard object's metadata.
144/// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
145#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
146pub struct MachineSetTemplateMetadata {
147    /// annotations is an unstructured key value map stored with a resource that may be
148    /// set by external tools to store and retrieve arbitrary metadata. They are not
149    /// queryable and should be preserved when modifying objects.
150    /// More info: http://kubernetes.io/docs/user-guide/annotations
151    #[serde(default, skip_serializing_if = "Option::is_none")]
152    pub annotations: Option<BTreeMap<String, String>>,
153    /// Map of string keys and values that can be used to organize and categorize
154    /// (scope and select) objects. May match selectors of replication controllers
155    /// and services.
156    /// More info: http://kubernetes.io/docs/user-guide/labels
157    #[serde(default, skip_serializing_if = "Option::is_none")]
158    pub labels: Option<BTreeMap<String, String>>,
159}
160
161/// Specification of the desired behavior of the machine.
162/// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
163#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
164pub struct MachineSetTemplateSpec {
165    /// bootstrap is a reference to a local struct which encapsulates
166    /// fields to configure the Machine’s bootstrapping mechanism.
167    pub bootstrap: MachineSetTemplateSpecBootstrap,
168    /// clusterName is the name of the Cluster this object belongs to.
169    #[serde(rename = "clusterName")]
170    pub cluster_name: String,
171    /// failureDomain is the failure domain the machine will be created in.
172    /// Must match a key in the FailureDomains map stored on the cluster object.
173    #[serde(
174        default,
175        skip_serializing_if = "Option::is_none",
176        rename = "failureDomain"
177    )]
178    pub failure_domain: Option<String>,
179    /// infrastructureRef is a required reference to a custom resource
180    /// offered by an infrastructure provider.
181    #[serde(rename = "infrastructureRef")]
182    pub infrastructure_ref: ObjectReference,
183    /// nodeDeletionTimeout defines how long the controller will attempt to delete the Node that the Machine
184    /// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
185    /// Defaults to 10 seconds.
186    #[serde(
187        default,
188        skip_serializing_if = "Option::is_none",
189        rename = "nodeDeletionTimeout"
190    )]
191    pub node_deletion_timeout: Option<String>,
192    /// nodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
193    /// The default value is 0, meaning that the node can be drained without any time limitations.
194    /// NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
195    #[serde(
196        default,
197        skip_serializing_if = "Option::is_none",
198        rename = "nodeDrainTimeout"
199    )]
200    pub node_drain_timeout: Option<String>,
201    /// nodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
202    /// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
203    #[serde(
204        default,
205        skip_serializing_if = "Option::is_none",
206        rename = "nodeVolumeDetachTimeout"
207    )]
208    pub node_volume_detach_timeout: Option<String>,
209    /// providerID is the identification ID of the machine provided by the provider.
210    /// This field must match the provider ID as seen on the node object corresponding to this machine.
211    /// This field is required by higher level consumers of cluster-api. Example use case is cluster autoscaler
212    /// with cluster-api as provider. Clean-up logic in the autoscaler compares machines to nodes to find out
213    /// machines at provider which could not get registered as Kubernetes nodes. With cluster-api as a
214    /// generic out-of-tree provider for autoscaler, this field is required by autoscaler to be
215    /// able to have a provider view of the list of machines. Another list of nodes is queried from the k8s apiserver
216    /// and then a comparison is done to find out unregistered machines and are marked for delete.
217    /// This field will be set by the actuators and consumed by higher level entities like autoscaler that will
218    /// be interfacing with cluster-api as generic provider.
219    #[serde(
220        default,
221        skip_serializing_if = "Option::is_none",
222        rename = "providerID"
223    )]
224    pub provider_id: Option<String>,
225    /// readinessGates specifies additional conditions to include when evaluating Machine Ready condition.
226    ///
227    /// This field can be used e.g. by Cluster API control plane providers to extend the semantic of the
228    /// Ready condition for the Machine they control, like the kubeadm control provider adding ReadinessGates
229    /// for the APIServerPodHealthy, SchedulerPodHealthy conditions, etc.
230    ///
231    /// Another example are external controllers, e.g. responsible to install special software/hardware on the Machines;
232    /// they can include the status of those components with a new condition and add this condition to ReadinessGates.
233    ///
234    /// NOTE: This field is considered only for computing v1beta2 conditions.
235    /// NOTE: In case readinessGates conditions start with the APIServer, ControllerManager, Scheduler prefix, and all those
236    /// readiness gates condition are reporting the same message, when computing the Machine's Ready condition those
237    /// readinessGates will be replaced by a single entry reporting "Control plane components: " + message.
238    /// This helps to improve readability of conditions bubbling up to the Machine's owner resource / to the Cluster).
239    #[serde(
240        default,
241        skip_serializing_if = "Option::is_none",
242        rename = "readinessGates"
243    )]
244    pub readiness_gates: Option<Vec<MachineSetTemplateSpecReadinessGates>>,
245    /// version defines the desired Kubernetes version.
246    /// This field is meant to be optionally used by bootstrap providers.
247    #[serde(default, skip_serializing_if = "Option::is_none")]
248    pub version: Option<String>,
249}
250
251/// bootstrap is a reference to a local struct which encapsulates
252/// fields to configure the Machine’s bootstrapping mechanism.
253#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
254pub struct MachineSetTemplateSpecBootstrap {
255    /// configRef is a reference to a bootstrap provider-specific resource
256    /// that holds configuration details. The reference is optional to
257    /// allow users/operators to specify Bootstrap.DataSecretName without
258    /// the need of a controller.
259    #[serde(default, skip_serializing_if = "Option::is_none", rename = "configRef")]
260    pub config_ref: Option<ObjectReference>,
261    /// dataSecretName is the name of the secret that stores the bootstrap data script.
262    /// If nil, the Machine should remain in the Pending state.
263    #[serde(
264        default,
265        skip_serializing_if = "Option::is_none",
266        rename = "dataSecretName"
267    )]
268    pub data_secret_name: Option<String>,
269}
270
271/// configRef is a reference to a bootstrap provider-specific resource
272/// that holds configuration details. The reference is optional to
273/// allow users/operators to specify Bootstrap.DataSecretName without
274/// the need of a controller.
275#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
276pub struct MachineSetTemplateSpecBootstrapConfigRef {
277    /// API version of the referent.
278    #[serde(
279        default,
280        skip_serializing_if = "Option::is_none",
281        rename = "apiVersion"
282    )]
283    pub api_version: Option<String>,
284    /// If referring to a piece of an object instead of an entire object, this string
285    /// should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
286    /// For example, if the object reference is to a container within a pod, this would take on a value like:
287    /// "spec.containers{name}" (where "name" refers to the name of the container that triggered
288    /// the event) or if no container name is specified "spec.containers[2]" (container with
289    /// index 2 in this pod). This syntax is chosen only to have some well-defined way of
290    /// referencing a part of an object.
291    #[serde(default, skip_serializing_if = "Option::is_none", rename = "fieldPath")]
292    pub field_path: Option<String>,
293    /// Kind of the referent.
294    /// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
295    #[serde(default, skip_serializing_if = "Option::is_none")]
296    pub kind: Option<String>,
297    /// Name of the referent.
298    /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
299    #[serde(default, skip_serializing_if = "Option::is_none")]
300    pub name: Option<String>,
301    /// Namespace of the referent.
302    /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
303    #[serde(default, skip_serializing_if = "Option::is_none")]
304    pub namespace: Option<String>,
305    /// Specific resourceVersion to which this reference is made, if any.
306    /// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
307    #[serde(
308        default,
309        skip_serializing_if = "Option::is_none",
310        rename = "resourceVersion"
311    )]
312    pub resource_version: Option<String>,
313    /// UID of the referent.
314    /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
315    #[serde(default, skip_serializing_if = "Option::is_none")]
316    pub uid: Option<String>,
317}
318
319/// infrastructureRef is a required reference to a custom resource
320/// offered by an infrastructure provider.
321#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
322pub struct MachineSetTemplateSpecInfrastructureRef {
323    /// API version of the referent.
324    #[serde(
325        default,
326        skip_serializing_if = "Option::is_none",
327        rename = "apiVersion"
328    )]
329    pub api_version: Option<String>,
330    /// If referring to a piece of an object instead of an entire object, this string
331    /// should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
332    /// For example, if the object reference is to a container within a pod, this would take on a value like:
333    /// "spec.containers{name}" (where "name" refers to the name of the container that triggered
334    /// the event) or if no container name is specified "spec.containers[2]" (container with
335    /// index 2 in this pod). This syntax is chosen only to have some well-defined way of
336    /// referencing a part of an object.
337    #[serde(default, skip_serializing_if = "Option::is_none", rename = "fieldPath")]
338    pub field_path: Option<String>,
339    /// Kind of the referent.
340    /// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
341    #[serde(default, skip_serializing_if = "Option::is_none")]
342    pub kind: Option<String>,
343    /// Name of the referent.
344    /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
345    #[serde(default, skip_serializing_if = "Option::is_none")]
346    pub name: Option<String>,
347    /// Namespace of the referent.
348    /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
349    #[serde(default, skip_serializing_if = "Option::is_none")]
350    pub namespace: Option<String>,
351    /// Specific resourceVersion to which this reference is made, if any.
352    /// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
353    #[serde(
354        default,
355        skip_serializing_if = "Option::is_none",
356        rename = "resourceVersion"
357    )]
358    pub resource_version: Option<String>,
359    /// UID of the referent.
360    /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
361    #[serde(default, skip_serializing_if = "Option::is_none")]
362    pub uid: Option<String>,
363}
364
365/// MachineReadinessGate contains the type of a Machine condition to be used as a readiness gate.
366#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
367pub struct MachineSetTemplateSpecReadinessGates {
368    /// conditionType refers to a positive polarity condition (status true means good) with matching type in the Machine's condition list.
369    /// If the conditions doesn't exist, it will be treated as unknown.
370    /// Note: Both Cluster API conditions or conditions added by 3rd party controllers can be used as readiness gates.
371    #[serde(rename = "conditionType")]
372    pub condition_type: String,
373}
374
375/// MachineSetStatus defines the observed state of MachineSet.
376#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
377pub struct MachineSetStatus {
378    /// The number of available replicas (ready for at least minReadySeconds) for this MachineSet.
379    #[serde(
380        default,
381        skip_serializing_if = "Option::is_none",
382        rename = "availableReplicas"
383    )]
384    pub available_replicas: Option<i32>,
385    /// conditions defines current service state of the MachineSet.
386    #[serde(default, skip_serializing_if = "Option::is_none")]
387    pub conditions: Option<Vec<Condition>>,
388    /// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
389    #[serde(
390        default,
391        skip_serializing_if = "Option::is_none",
392        rename = "failureMessage"
393    )]
394    pub failure_message: Option<String>,
395    /// In the event that there is a terminal problem reconciling the
396    /// replicas, both FailureReason and FailureMessage will be set. FailureReason
397    /// will be populated with a succinct value suitable for machine
398    /// interpretation, while FailureMessage will contain a more verbose
399    /// string suitable for logging and human consumption.
400    ///
401    /// These fields should not be set for transitive errors that a
402    /// controller faces that are expected to be fixed automatically over
403    /// time (like service outages), but instead indicate that something is
404    /// fundamentally wrong with the MachineTemplate's spec or the configuration of
405    /// the machine controller, and that manual intervention is required. Examples
406    /// of terminal errors would be invalid combinations of settings in the
407    /// spec, values that are unsupported by the machine controller, or the
408    /// responsible machine controller itself being critically misconfigured.
409    ///
410    /// Any transient errors that occur during the reconciliation of Machines
411    /// can be added as events to the MachineSet object and/or logged in the
412    /// controller's output.
413    ///
414    /// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
415    #[serde(
416        default,
417        skip_serializing_if = "Option::is_none",
418        rename = "failureReason"
419    )]
420    pub failure_reason: Option<String>,
421    /// The number of replicas that have labels matching the labels of the machine template of the MachineSet.
422    ///
423    /// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
424    #[serde(
425        default,
426        skip_serializing_if = "Option::is_none",
427        rename = "fullyLabeledReplicas"
428    )]
429    pub fully_labeled_replicas: Option<i32>,
430    /// observedGeneration reflects the generation of the most recently observed MachineSet.
431    #[serde(
432        default,
433        skip_serializing_if = "Option::is_none",
434        rename = "observedGeneration"
435    )]
436    pub observed_generation: Option<i64>,
437    /// The number of ready replicas for this MachineSet. A machine is considered ready when the node has been created and is "Ready".
438    #[serde(
439        default,
440        skip_serializing_if = "Option::is_none",
441        rename = "readyReplicas"
442    )]
443    pub ready_replicas: Option<i32>,
444    /// replicas is the most recently observed number of replicas.
445    #[serde(default, skip_serializing_if = "Option::is_none")]
446    pub replicas: Option<i32>,
447    /// selector is the same as the label selector but in the string format to avoid introspection
448    /// by clients. The string will be in the same format as the query-param syntax.
449    /// More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors
450    #[serde(default, skip_serializing_if = "Option::is_none")]
451    pub selector: Option<String>,
452    /// v1beta2 groups all the fields that will be added or modified in MachineSet's status with the V1Beta2 version.
453    #[serde(default, skip_serializing_if = "Option::is_none")]
454    pub v1beta2: Option<MachineSetStatusV1beta2>,
455}
456
457/// v1beta2 groups all the fields that will be added or modified in MachineSet's status with the V1Beta2 version.
458#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
459pub struct MachineSetStatusV1beta2 {
460    /// availableReplicas is the number of available replicas for this MachineSet. A machine is considered available when Machine's Available condition is true.
461    #[serde(
462        default,
463        skip_serializing_if = "Option::is_none",
464        rename = "availableReplicas"
465    )]
466    pub available_replicas: Option<i32>,
467    /// conditions represents the observations of a MachineSet's current state.
468    /// Known condition types are MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused.
469    #[serde(default, skip_serializing_if = "Option::is_none")]
470    pub conditions: Option<Vec<Condition>>,
471    /// readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when Machine's Ready condition is true.
472    #[serde(
473        default,
474        skip_serializing_if = "Option::is_none",
475        rename = "readyReplicas"
476    )]
477    pub ready_replicas: Option<i32>,
478    /// upToDateReplicas is the number of up-to-date replicas for this MachineSet. A machine is considered up-to-date when Machine's UpToDate condition is true.
479    #[serde(
480        default,
481        skip_serializing_if = "Option::is_none",
482        rename = "upToDateReplicas"
483    )]
484    pub up_to_date_replicas: Option<i32>,
485}