k8s-crds-cluster-api 1.12.5

Kubernetes CRDs for cluster-api
Documentation
// WARNING: generated by kopium - manual changes will be overwritten
// kopium command: kopium -f machinehealthchecks.yml --schema=derived --docs -b --derive=Default --derive=PartialEq --smart-derive-elision
// kopium version: 0.23.0

#[allow(unused_imports)]
mod prelude {
    pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
    pub use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString;
    pub use kube_derive::CustomResource;
    #[cfg(feature = "schemars")]
    pub use schemars::JsonSchema;
    pub use serde::{Deserialize, Serialize};
    pub use std::collections::BTreeMap;
    #[cfg(feature = "builder")]
    pub use typed_builder::TypedBuilder;
}

use self::prelude::*;

/// spec is the specification of machine health check policy
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[cfg_attr(not(feature = "schemars"), kube(schema = "disabled"))]
#[kube(
    group = "cluster.x-k8s.io",
    version = "v1beta2",
    kind = "MachineHealthCheck",
    plural = "machinehealthchecks"
)]
#[kube(namespaced)]
#[kube(status = "MachineHealthCheckStatus")]
#[kube(derive = "Default")]
#[kube(derive = "PartialEq")]
pub struct MachineHealthCheckSpec {
    /// checks are the checks that are used to evaluate if a Machine is healthy.
    ///
    /// Independent of this configuration the MachineHealthCheck controller will always
    /// flag Machines with `cluster.x-k8s.io/remediate-machine` annotation and
    /// Machines with deleted Nodes as unhealthy.
    ///
    /// Furthermore, if checks.nodeStartupTimeoutSeconds is not set it
    /// is defaulted to 10 minutes and evaluated accordingly.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub checks: Option<MachineHealthCheckChecks>,
    /// clusterName is the name of the Cluster this object belongs to.
    #[serde(rename = "clusterName")]
    pub cluster_name: String,
    /// remediation configures if and how remediations are triggered if a Machine is unhealthy.
    ///
    /// If remediation or remediation.triggerIf is not set,
    /// remediation will always be triggered for unhealthy Machines.
    ///
    /// If remediation or remediation.templateRef is not set,
    /// the OwnerRemediated condition will be set on unhealthy Machines to trigger remediation via
    /// the owner of the Machines, for example a MachineSet or a KubeadmControlPlane.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub remediation: Option<MachineHealthCheckRemediation>,
    /// selector is a label selector to match machines whose health will be exercised
    pub selector: MachineHealthCheckSelector,
}

/// checks are the checks that are used to evaluate if a Machine is healthy.
///
/// Independent of this configuration the MachineHealthCheck controller will always
/// flag Machines with `cluster.x-k8s.io/remediate-machine` annotation and
/// Machines with deleted Nodes as unhealthy.
///
/// Furthermore, if checks.nodeStartupTimeoutSeconds is not set it
/// is defaulted to 10 minutes and evaluated accordingly.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckChecks {
    /// nodeStartupTimeoutSeconds allows to set the maximum time for MachineHealthCheck
    /// to consider a Machine unhealthy if a corresponding Node isn't associated
    /// through a `Spec.ProviderID` field.
    ///
    /// The duration set in this field is compared to the greatest of:
    /// - Cluster's infrastructure ready condition timestamp (if and when available)
    /// - Control Plane's initialized condition timestamp (if and when available)
    /// - Machine's infrastructure ready condition timestamp (if and when available)
    /// - Machine's metadata creation timestamp
    ///
    /// Defaults to 10 minutes.
    /// If you wish to disable this feature, set the value explicitly to 0.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "nodeStartupTimeoutSeconds"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub node_startup_timeout_seconds: Option<i32>,
    /// unhealthyMachineConditions contains a list of the machine conditions that determine
    /// whether a machine is considered unhealthy.  The conditions are combined in a
    /// logical OR, i.e. if any of the conditions is met, the machine is unhealthy.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "unhealthyMachineConditions"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub unhealthy_machine_conditions:
        Option<Vec<MachineHealthCheckChecksUnhealthyMachineConditions>>,
    /// unhealthyNodeConditions contains a list of conditions that determine
    /// whether a node is considered unhealthy. The conditions are combined in a
    /// logical OR, i.e. if any of the conditions is met, the node is unhealthy.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "unhealthyNodeConditions"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub unhealthy_node_conditions: Option<Vec<MachineHealthCheckChecksUnhealthyNodeConditions>>,
}

/// UnhealthyMachineCondition represents a Machine condition type and value with a timeout
/// specified as a duration.  When the named condition has been in the given
/// status for at least the timeout value, a machine is considered unhealthy.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckChecksUnhealthyMachineConditions {
    /// status of the condition, one of True, False, Unknown.
    pub status: MachineHealthCheckChecksUnhealthyMachineConditionsStatus,
    /// timeoutSeconds is the duration that a machine must be in a given status for,
    /// after which the machine is considered unhealthy.
    /// For example, with a value of "3600", the machine must match the status
    /// for at least 1 hour before being considered unhealthy.
    #[serde(rename = "timeoutSeconds")]
    pub timeout_seconds: i32,
    /// type of Machine condition
    #[serde(rename = "type")]
    pub r#type: String,
}

/// UnhealthyMachineCondition represents a Machine condition type and value with a timeout
/// specified as a duration.  When the named condition has been in the given
/// status for at least the timeout value, a machine is considered unhealthy.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub enum MachineHealthCheckChecksUnhealthyMachineConditionsStatus {
    True,
    False,
    Unknown,
}

/// UnhealthyNodeCondition represents a Node condition type and value with a timeout
/// specified as a duration.  When the named condition has been in the given
/// status for at least the timeout value, a node is considered unhealthy.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckChecksUnhealthyNodeConditions {
    /// status of the condition, one of True, False, Unknown.
    pub status: String,
    /// timeoutSeconds is the duration that a node must be in a given status for,
    /// after which the node is considered unhealthy.
    /// For example, with a value of "3600", the node must match the status
    /// for at least 1 hour before being considered unhealthy.
    #[serde(rename = "timeoutSeconds")]
    pub timeout_seconds: i32,
    /// type of Node condition
    #[serde(rename = "type")]
    pub r#type: String,
}

/// remediation configures if and how remediations are triggered if a Machine is unhealthy.
///
/// If remediation or remediation.triggerIf is not set,
/// remediation will always be triggered for unhealthy Machines.
///
/// If remediation or remediation.templateRef is not set,
/// the OwnerRemediated condition will be set on unhealthy Machines to trigger remediation via
/// the owner of the Machines, for example a MachineSet or a KubeadmControlPlane.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckRemediation {
    /// templateRef is a reference to a remediation template
    /// provided by an infrastructure provider.
    ///
    /// This field is completely optional, when filled, the MachineHealthCheck controller
    /// creates a new object from the template referenced and hands off remediation of the machine to
    /// a controller that lives outside of Cluster API.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "templateRef"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub template_ref: Option<MachineHealthCheckRemediationTemplateRef>,
    /// triggerIf configures if remediations are triggered.
    /// If this field is not set, remediations are always triggered.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "triggerIf")]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub trigger_if: Option<MachineHealthCheckRemediationTriggerIf>,
}

/// templateRef is a reference to a remediation template
/// provided by an infrastructure provider.
///
/// This field is completely optional, when filled, the MachineHealthCheck controller
/// creates a new object from the template referenced and hands off remediation of the machine to
/// a controller that lives outside of Cluster API.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckRemediationTemplateRef {
    /// apiVersion of the remediation template.
    /// apiVersion must be fully qualified domain name followed by / and a version.
    /// NOTE: This field must be kept in sync with the APIVersion of the remediation template.
    #[serde(rename = "apiVersion")]
    pub api_version: String,
    /// kind of the remediation template.
    /// kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character.
    pub kind: String,
    /// name of the remediation template.
    /// name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
    pub name: String,
}

/// triggerIf configures if remediations are triggered.
/// If this field is not set, remediations are always triggered.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckRemediationTriggerIf {
    /// unhealthyInRange specifies that remediations are only triggered if the number of
    /// unhealthy Machines is in the configured range.
    /// Takes precedence over unhealthyLessThanOrEqualTo.
    /// Eg. "[3-5]" - This means that remediation will be allowed only when:
    /// (a) there are at least 3 unhealthy Machines (and)
    /// (b) there are at most 5 unhealthy Machines
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "unhealthyInRange"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub unhealthy_in_range: Option<String>,
    /// unhealthyLessThanOrEqualTo specifies that remediations are only triggered if the number of
    /// unhealthy Machines is less than or equal to the configured value.
    /// unhealthyInRange takes precedence if set.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "unhealthyLessThanOrEqualTo"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub unhealthy_less_than_or_equal_to: Option<IntOrString>,
}

/// selector is a label selector to match machines whose health will be exercised
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "matchExpressions"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub match_expressions: Option<Vec<MachineHealthCheckSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "matchLabels"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub values: Option<Vec<String>>,
}

/// status is the most recently observed status of MachineHealthCheck resource
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckStatus {
    /// conditions represents the observations of a MachineHealthCheck's current state.
    /// Known condition types are RemediationAllowed, Paused.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub conditions: Option<Vec<Condition>>,
    /// currentHealthy is the total number of healthy machines counted by this machine health check
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "currentHealthy"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub current_healthy: Option<i32>,
    /// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub deprecated: Option<MachineHealthCheckStatusDeprecated>,
    /// expectedMachines is the total number of machines counted by this machine health check
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "expectedMachines"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub expected_machines: Option<i32>,
    /// observedGeneration is the latest generation observed by the controller.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "observedGeneration"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub observed_generation: Option<i64>,
    /// remediationsAllowed is the number of further remediations allowed by this machine health check before
    /// maxUnhealthy short circuiting will be applied
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "remediationsAllowed"
    )]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub remediations_allowed: Option<i32>,
    /// targets shows the current list of machines the machine health check is watching
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub targets: Option<Vec<String>>,
}

/// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckStatusDeprecated {
    /// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub v1beta1: Option<MachineHealthCheckStatusDeprecatedV1beta1>,
}

/// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(TypedBuilder))]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct MachineHealthCheckStatusDeprecatedV1beta1 {
    /// conditions defines current service state of the MachineHealthCheck.
    ///
    /// 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.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[cfg_attr(feature = "builder", builder(default, setter(strip_option)))]
    pub conditions: Option<Vec<Condition>>,
}