cluster_api_rs/api/
capi_machinehealthcheck.rs

1// WARNING: generated by kopium - manual changes will be overwritten
2// kopium command: kopium --smart-derive-elision -D Default -D PartialEq -A -d -f -
3// kopium version: 0.22.5
4
5#[allow(unused_imports)]
6mod prelude {
7    pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
8    pub use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString;
9    pub use kube::CustomResource;
10    pub use schemars::JsonSchema;
11    pub use serde::{Deserialize, Serialize};
12    pub use std::collections::BTreeMap;
13}
14
15use self::prelude::*;
16
17/// spec is the specification of machine health check policy
18#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
19#[kube(
20    group = "cluster.x-k8s.io",
21    version = "v1beta2",
22    kind = "MachineHealthCheck",
23    plural = "machinehealthchecks"
24)]
25#[kube(namespaced)]
26#[kube(status = "MachineHealthCheckStatus")]
27#[kube(derive = "Default")]
28#[kube(derive = "PartialEq")]
29pub struct MachineHealthCheckSpec {
30    /// checks are the checks that are used to evaluate if a Machine is healthy.
31    ///
32    /// Independent of this configuration the MachineHealthCheck controller will always
33    /// flag Machines with `cluster.x-k8s.io/remediate-machine` annotation and
34    /// Machines with deleted Nodes as unhealthy.
35    ///
36    /// Furthermore, if checks.nodeStartupTimeoutSeconds is not set it
37    /// is defaulted to 10 minutes and evaluated accordingly.
38    #[serde(default, skip_serializing_if = "Option::is_none")]
39    pub checks: Option<MachineHealthCheckChecks>,
40    /// clusterName is the name of the Cluster this object belongs to.
41    #[serde(rename = "clusterName")]
42    pub cluster_name: String,
43    /// remediation configures if and how remediations are triggered if a Machine is unhealthy.
44    ///
45    /// If remediation or remediation.triggerIf is not set,
46    /// remediation will always be triggered for unhealthy Machines.
47    ///
48    /// If remediation or remediation.templateRef is not set,
49    /// the OwnerRemediated condition will be set on unhealthy Machines to trigger remediation via
50    /// the owner of the Machines, for example a MachineSet or a KubeadmControlPlane.
51    #[serde(default, skip_serializing_if = "Option::is_none")]
52    pub remediation: Option<MachineHealthCheckRemediation>,
53    /// selector is a label selector to match machines whose health will be exercised
54    pub selector: MachineHealthCheckSelector,
55}
56
57/// checks are the checks that are used to evaluate if a Machine is healthy.
58///
59/// Independent of this configuration the MachineHealthCheck controller will always
60/// flag Machines with `cluster.x-k8s.io/remediate-machine` annotation and
61/// Machines with deleted Nodes as unhealthy.
62///
63/// Furthermore, if checks.nodeStartupTimeoutSeconds is not set it
64/// is defaulted to 10 minutes and evaluated accordingly.
65#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
66pub struct MachineHealthCheckChecks {
67    /// nodeStartupTimeoutSeconds allows to set the maximum time for MachineHealthCheck
68    /// to consider a Machine unhealthy if a corresponding Node isn't associated
69    /// through a `Spec.ProviderID` field.
70    ///
71    /// The duration set in this field is compared to the greatest of:
72    /// - Cluster's infrastructure ready condition timestamp (if and when available)
73    /// - Control Plane's initialized condition timestamp (if and when available)
74    /// - Machine's infrastructure ready condition timestamp (if and when available)
75    /// - Machine's metadata creation timestamp
76    ///
77    /// Defaults to 10 minutes.
78    /// If you wish to disable this feature, set the value explicitly to 0.
79    #[serde(
80        default,
81        skip_serializing_if = "Option::is_none",
82        rename = "nodeStartupTimeoutSeconds"
83    )]
84    pub node_startup_timeout_seconds: Option<i32>,
85    /// unhealthyNodeConditions contains a list of conditions that determine
86    /// whether a node is considered unhealthy. The conditions are combined in a
87    /// logical OR, i.e. if any of the conditions is met, the node is unhealthy.
88    #[serde(
89        default,
90        skip_serializing_if = "Option::is_none",
91        rename = "unhealthyNodeConditions"
92    )]
93    pub unhealthy_node_conditions: Option<Vec<MachineHealthCheckChecksUnhealthyNodeConditions>>,
94}
95
96/// UnhealthyNodeCondition represents a Node condition type and value with a timeout
97/// specified as a duration.  When the named condition has been in the given
98/// status for at least the timeout value, a node is considered unhealthy.
99#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
100pub struct MachineHealthCheckChecksUnhealthyNodeConditions {
101    /// status of the condition, one of True, False, Unknown.
102    pub status: String,
103    /// timeoutSeconds is the duration that a node must be in a given status for,
104    /// after which the node is considered unhealthy.
105    /// For example, with a value of "1h", the node must match the status
106    /// for at least 1 hour before being considered unhealthy.
107    #[serde(rename = "timeoutSeconds")]
108    pub timeout_seconds: i32,
109    /// type of Node condition
110    #[serde(rename = "type")]
111    pub r#type: String,
112}
113
114/// remediation configures if and how remediations are triggered if a Machine is unhealthy.
115///
116/// If remediation or remediation.triggerIf is not set,
117/// remediation will always be triggered for unhealthy Machines.
118///
119/// If remediation or remediation.templateRef is not set,
120/// the OwnerRemediated condition will be set on unhealthy Machines to trigger remediation via
121/// the owner of the Machines, for example a MachineSet or a KubeadmControlPlane.
122#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
123pub struct MachineHealthCheckRemediation {
124    /// templateRef is a reference to a remediation template
125    /// provided by an infrastructure provider.
126    ///
127    /// This field is completely optional, when filled, the MachineHealthCheck controller
128    /// creates a new object from the template referenced and hands off remediation of the machine to
129    /// a controller that lives outside of Cluster API.
130    #[serde(
131        default,
132        skip_serializing_if = "Option::is_none",
133        rename = "templateRef"
134    )]
135    pub template_ref: Option<MachineHealthCheckRemediationTemplateRef>,
136    /// triggerIf configures if remediations are triggered.
137    /// If this field is not set, remediations are always triggered.
138    #[serde(default, skip_serializing_if = "Option::is_none", rename = "triggerIf")]
139    pub trigger_if: Option<MachineHealthCheckRemediationTriggerIf>,
140}
141
142/// templateRef is a reference to a remediation template
143/// provided by an infrastructure provider.
144///
145/// This field is completely optional, when filled, the MachineHealthCheck controller
146/// creates a new object from the template referenced and hands off remediation of the machine to
147/// a controller that lives outside of Cluster API.
148#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
149pub struct MachineHealthCheckRemediationTemplateRef {
150    /// apiVersion of the remediation template.
151    /// apiVersion must be fully qualified domain name followed by / and a version.
152    /// NOTE: This field must be kept in sync with the APIVersion of the remediation template.
153    #[serde(rename = "apiVersion")]
154    pub api_version: String,
155    /// kind of the remediation template.
156    /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
157    pub kind: String,
158    /// name of the remediation template.
159    /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
160    pub name: String,
161}
162
163/// triggerIf configures if remediations are triggered.
164/// If this field is not set, remediations are always triggered.
165#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
166pub struct MachineHealthCheckRemediationTriggerIf {
167    /// unhealthyInRange specifies that remediations are only triggered if the number of
168    /// unhealthy Machines is in the configured range.
169    /// Takes precedence over unhealthyLessThanOrEqualTo.
170    /// Eg. "[3-5]" - This means that remediation will be allowed only when:
171    /// (a) there are at least 3 unhealthy Machines (and)
172    /// (b) there are at most 5 unhealthy Machines
173    #[serde(
174        default,
175        skip_serializing_if = "Option::is_none",
176        rename = "unhealthyInRange"
177    )]
178    pub unhealthy_in_range: Option<String>,
179    /// unhealthyLessThanOrEqualTo specifies that remediations are only triggered if the number of
180    /// unhealthy Machines is less than or equal to the configured value.
181    /// unhealthyInRange takes precedence if set.
182    #[serde(
183        default,
184        skip_serializing_if = "Option::is_none",
185        rename = "unhealthyLessThanOrEqualTo"
186    )]
187    pub unhealthy_less_than_or_equal_to: Option<IntOrString>,
188}
189
190/// selector is a label selector to match machines whose health will be exercised
191#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
192pub struct MachineHealthCheckSelector {
193    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
194    #[serde(
195        default,
196        skip_serializing_if = "Option::is_none",
197        rename = "matchExpressions"
198    )]
199    pub match_expressions: Option<Vec<MachineHealthCheckSelectorMatchExpressions>>,
200    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
201    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
202    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
203    #[serde(
204        default,
205        skip_serializing_if = "Option::is_none",
206        rename = "matchLabels"
207    )]
208    pub match_labels: Option<BTreeMap<String, String>>,
209}
210
211/// A label selector requirement is a selector that contains values, a key, and an operator that
212/// relates the key and values.
213#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
214pub struct MachineHealthCheckSelectorMatchExpressions {
215    /// key is the label key that the selector applies to.
216    pub key: String,
217    /// operator represents a key's relationship to a set of values.
218    /// Valid operators are In, NotIn, Exists and DoesNotExist.
219    pub operator: String,
220    /// values is an array of string values. If the operator is In or NotIn,
221    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
222    /// the values array must be empty. This array is replaced during a strategic
223    /// merge patch.
224    #[serde(default, skip_serializing_if = "Option::is_none")]
225    pub values: Option<Vec<String>>,
226}
227
228/// status is the most recently observed status of MachineHealthCheck resource
229#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
230pub struct MachineHealthCheckStatus {
231    /// conditions represents the observations of a MachineHealthCheck's current state.
232    /// Known condition types are RemediationAllowed, Paused.
233    #[serde(default, skip_serializing_if = "Option::is_none")]
234    pub conditions: Option<Vec<Condition>>,
235    /// currentHealthy is the total number of healthy machines counted by this machine health check
236    #[serde(
237        default,
238        skip_serializing_if = "Option::is_none",
239        rename = "currentHealthy"
240    )]
241    pub current_healthy: Option<i32>,
242    /// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
243    #[serde(default, skip_serializing_if = "Option::is_none")]
244    pub deprecated: Option<MachineHealthCheckStatusDeprecated>,
245    /// expectedMachines is the total number of machines counted by this machine health check
246    #[serde(
247        default,
248        skip_serializing_if = "Option::is_none",
249        rename = "expectedMachines"
250    )]
251    pub expected_machines: Option<i32>,
252    /// observedGeneration is the latest generation observed by the controller.
253    #[serde(
254        default,
255        skip_serializing_if = "Option::is_none",
256        rename = "observedGeneration"
257    )]
258    pub observed_generation: Option<i64>,
259    /// remediationsAllowed is the number of further remediations allowed by this machine health check before
260    /// maxUnhealthy short circuiting will be applied
261    #[serde(
262        default,
263        skip_serializing_if = "Option::is_none",
264        rename = "remediationsAllowed"
265    )]
266    pub remediations_allowed: Option<i32>,
267    /// targets shows the current list of machines the machine health check is watching
268    #[serde(default, skip_serializing_if = "Option::is_none")]
269    pub targets: Option<Vec<String>>,
270}
271
272/// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
273#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
274pub struct MachineHealthCheckStatusDeprecated {
275    /// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
276    #[serde(default, skip_serializing_if = "Option::is_none")]
277    pub v1beta1: Option<MachineHealthCheckStatusDeprecatedV1beta1>,
278}
279
280/// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
281#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
282pub struct MachineHealthCheckStatusDeprecatedV1beta1 {
283    /// conditions defines current service state of the MachineHealthCheck.
284    ///
285    /// Deprecated: This field is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see <https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md> for more details.
286    #[serde(default, skip_serializing_if = "Option::is_none")]
287    pub conditions: Option<Vec<Condition>>,
288}