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