cluster_api_rs/api/
capi_machinehealthcheck.rs

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