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.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 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 = "v1beta1",
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 /// clusterName is the name of the Cluster this object belongs to.
31 #[serde(rename = "clusterName")]
32 pub cluster_name: String,
33 /// maxUnhealthy specifies the maximum number of unhealthy machines allowed.
34 /// Any further remediation is only allowed if at most "maxUnhealthy" machines selected by
35 /// "selector" are not healthy.
36 ///
37 /// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/issues/10722 for more details.
38 #[serde(
39 default,
40 skip_serializing_if = "Option::is_none",
41 rename = "maxUnhealthy"
42 )]
43 pub max_unhealthy: Option<IntOrString>,
44 /// nodeStartupTimeout allows to set the maximum time for MachineHealthCheck
45 /// to consider a Machine unhealthy if a corresponding Node isn't associated
46 /// through a `Spec.ProviderID` field.
47 ///
48 /// The duration set in this field is compared to the greatest of:
49 /// - Cluster's infrastructure ready condition timestamp (if and when available)
50 /// - Control Plane's initialized condition timestamp (if and when available)
51 /// - Machine's infrastructure ready condition timestamp (if and when available)
52 /// - Machine's metadata creation timestamp
53 ///
54 /// Defaults to 10 minutes.
55 /// If you wish to disable this feature, set the value explicitly to 0.
56 #[serde(
57 default,
58 skip_serializing_if = "Option::is_none",
59 rename = "nodeStartupTimeout"
60 )]
61 pub node_startup_timeout: Option<String>,
62 /// remediationTemplate is a reference to a remediation template
63 /// provided by an infrastructure provider.
64 ///
65 /// This field is completely optional, when filled, the MachineHealthCheck controller
66 /// creates a new object from the template referenced and hands off remediation of the machine to
67 /// a controller that lives outside of Cluster API.
68 #[serde(
69 default,
70 skip_serializing_if = "Option::is_none",
71 rename = "remediationTemplate"
72 )]
73 pub remediation_template: Option<ObjectReference>,
74 /// selector is a label selector to match machines whose health will be exercised
75 pub selector: MachineHealthCheckSelector,
76 /// unhealthyConditions contains a list of the conditions that determine
77 /// whether a node is considered unhealthy. The conditions are combined in a
78 /// logical OR, i.e. if any of the conditions is met, the node is unhealthy.
79 #[serde(
80 default,
81 skip_serializing_if = "Option::is_none",
82 rename = "unhealthyConditions"
83 )]
84 pub unhealthy_conditions: Option<Vec<MachineHealthCheckUnhealthyConditions>>,
85 /// unhealthyRange specifies the range of unhealthy machines allowed.
86 /// Any further remediation is only allowed if the number of machines selected by "selector" as not healthy
87 /// is within the range of "unhealthyRange". Takes precedence over maxUnhealthy.
88 /// Eg. "[3-5]" - This means that remediation will be allowed only when:
89 /// (a) there are at least 3 unhealthy machines (and)
90 /// (b) there are at most 5 unhealthy machines
91 ///
92 /// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/issues/10722 for more details.
93 #[serde(
94 default,
95 skip_serializing_if = "Option::is_none",
96 rename = "unhealthyRange"
97 )]
98 pub unhealthy_range: Option<String>,
99}
100
101/// remediationTemplate is a reference to a remediation template
102/// provided by an infrastructure provider.
103///
104/// This field is completely optional, when filled, the MachineHealthCheck controller
105/// creates a new object from the template referenced and hands off remediation of the machine to
106/// a controller that lives outside of Cluster API.
107#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
108pub struct MachineHealthCheckRemediationTemplate {
109 /// API version of the referent.
110 #[serde(
111 default,
112 skip_serializing_if = "Option::is_none",
113 rename = "apiVersion"
114 )]
115 pub api_version: Option<String>,
116 /// If referring to a piece of an object instead of an entire object, this string
117 /// should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
118 /// For example, if the object reference is to a container within a pod, this would take on a value like:
119 /// "spec.containers{name}" (where "name" refers to the name of the container that triggered
120 /// the event) or if no container name is specified "spec.containers[2]" (container with
121 /// index 2 in this pod). This syntax is chosen only to have some well-defined way of
122 /// referencing a part of an object.
123 #[serde(default, skip_serializing_if = "Option::is_none", rename = "fieldPath")]
124 pub field_path: Option<String>,
125 /// Kind of the referent.
126 /// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
127 #[serde(default, skip_serializing_if = "Option::is_none")]
128 pub kind: Option<String>,
129 /// Name of the referent.
130 /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
131 #[serde(default, skip_serializing_if = "Option::is_none")]
132 pub name: Option<String>,
133 /// Namespace of the referent.
134 /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
135 #[serde(default, skip_serializing_if = "Option::is_none")]
136 pub namespace: Option<String>,
137 /// Specific resourceVersion to which this reference is made, if any.
138 /// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
139 #[serde(
140 default,
141 skip_serializing_if = "Option::is_none",
142 rename = "resourceVersion"
143 )]
144 pub resource_version: Option<String>,
145 /// UID of the referent.
146 /// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
147 #[serde(default, skip_serializing_if = "Option::is_none")]
148 pub uid: Option<String>,
149}
150
151/// selector is a label selector to match machines whose health will be exercised
152#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
153pub struct MachineHealthCheckSelector {
154 /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
155 #[serde(
156 default,
157 skip_serializing_if = "Option::is_none",
158 rename = "matchExpressions"
159 )]
160 pub match_expressions: Option<Vec<MachineHealthCheckSelectorMatchExpressions>>,
161 /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
162 /// map is equivalent to an element of matchExpressions, whose key field is "key", the
163 /// operator is "In", and the values array contains only "value". The requirements are ANDed.
164 #[serde(
165 default,
166 skip_serializing_if = "Option::is_none",
167 rename = "matchLabels"
168 )]
169 pub match_labels: Option<BTreeMap<String, String>>,
170}
171
172/// A label selector requirement is a selector that contains values, a key, and an operator that
173/// relates the key and values.
174#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
175pub struct MachineHealthCheckSelectorMatchExpressions {
176 /// key is the label key that the selector applies to.
177 pub key: String,
178 /// operator represents a key's relationship to a set of values.
179 /// Valid operators are In, NotIn, Exists and DoesNotExist.
180 pub operator: String,
181 /// values is an array of string values. If the operator is In or NotIn,
182 /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
183 /// the values array must be empty. This array is replaced during a strategic
184 /// merge patch.
185 #[serde(default, skip_serializing_if = "Option::is_none")]
186 pub values: Option<Vec<String>>,
187}
188
189/// UnhealthyCondition represents a Node condition type and value with a timeout
190/// specified as a duration. When the named condition has been in the given
191/// status for at least the timeout value, a node is considered unhealthy.
192#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
193pub struct MachineHealthCheckUnhealthyConditions {
194 /// status of the condition, one of True, False, Unknown.
195 pub status: String,
196 /// timeout is the duration that a node must be in a given status for,
197 /// after which the node is considered unhealthy.
198 /// For example, with a value of "1h", the node must match the status
199 /// for at least 1 hour before being considered unhealthy.
200 pub timeout: String,
201 /// type of Node condition
202 #[serde(rename = "type")]
203 pub r#type: String,
204}
205
206/// status is the most recently observed status of MachineHealthCheck resource
207#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
208pub struct MachineHealthCheckStatus {
209 /// conditions defines current service state of the MachineHealthCheck.
210 #[serde(default, skip_serializing_if = "Option::is_none")]
211 pub conditions: Option<Vec<Condition>>,
212 /// currentHealthy is the total number of healthy machines counted by this machine health check
213 #[serde(
214 default,
215 skip_serializing_if = "Option::is_none",
216 rename = "currentHealthy"
217 )]
218 pub current_healthy: Option<i32>,
219 /// expectedMachines is the total number of machines counted by this machine health check
220 #[serde(
221 default,
222 skip_serializing_if = "Option::is_none",
223 rename = "expectedMachines"
224 )]
225 pub expected_machines: Option<i32>,
226 /// observedGeneration is the latest generation observed by the controller.
227 #[serde(
228 default,
229 skip_serializing_if = "Option::is_none",
230 rename = "observedGeneration"
231 )]
232 pub observed_generation: Option<i64>,
233 /// remediationsAllowed is the number of further remediations allowed by this machine health check before
234 /// maxUnhealthy short circuiting will be applied
235 #[serde(
236 default,
237 skip_serializing_if = "Option::is_none",
238 rename = "remediationsAllowed"
239 )]
240 pub remediations_allowed: Option<i32>,
241 /// targets shows the current list of machines the machine health check is watching
242 #[serde(default, skip_serializing_if = "Option::is_none")]
243 pub targets: Option<Vec<String>>,
244 /// v1beta2 groups all the fields that will be added or modified in MachineHealthCheck's status with the V1Beta2 version.
245 #[serde(default, skip_serializing_if = "Option::is_none")]
246 pub v1beta2: Option<MachineHealthCheckStatusV1beta2>,
247}
248
249/// v1beta2 groups all the fields that will be added or modified in MachineHealthCheck's status with the V1Beta2 version.
250#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, JsonSchema)]
251pub struct MachineHealthCheckStatusV1beta2 {
252 /// conditions represents the observations of a MachineHealthCheck's current state.
253 /// Known condition types are RemediationAllowed, Paused.
254 #[serde(default, skip_serializing_if = "Option::is_none")]
255 pub conditions: Option<Vec<Condition>>,
256}