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