// Module included in the following assemblies:
//
// *nodes/nodes/eco-poison-pill-operator.adoc

:_mod-docs-content-type: PROCEDURE
[id="configuring-machine-health-check-with-self-node-remediation-operator_{context}"]
= Configuring machine health checks to use the Self Node Remediation Operator

Use the following procedure to configure the worker or control-plane machine health checks to use the Self Node Remediation Operator as a remediation provider.

.Prerequisites

* Install the OpenShift CLI (`oc`).
* Log in as a user with `cluster-admin` privileges.

.Procedure

. Create a `SelfNodeRemediationTemplate` CR:

.. Define the `SelfNodeRemediationTemplate` CR:
+
[source,yaml]
----
apiVersion: self-node-remediation.medik8s.io/v1alpha1
kind: SelfNodeRemediationTemplate
metadata:
  namespace: openshift-machine-api
  name: selfnoderemediationtemplate-sample
spec:
  template:
    spec:
      remediationStrategy: ResourceDeletion <1>
----
<1> Specifies the remediation strategy. The default strategy is `ResourceDeletion`.

.. To create the `SelfNodeRemediationTemplate` CR, run the following command:
+
[source,terminal]
----
$ oc create -f <snrt-name>.yaml
----

. Create or update the `MachineHealthCheck` CR to point to the `SelfNodeRemediationTemplate` CR:

.. Define or update the `MachineHealthCheck` CR:
+
[source,yaml]
----
apiVersion: machine.openshift.io/v1beta1
kind: MachineHealthCheck
metadata:
  name: machine-health-check
  namespace: openshift-machine-api
spec:
  selector:
    matchLabels: <1>
      machine.openshift.io/cluster-api-machine-role: "worker"
      machine.openshift.io/cluster-api-machine-type: "worker"
  unhealthyConditions:
  - type:    "Ready"
    timeout: "300s"
    status: "False"
  - type:    "Ready"
    timeout: "300s"
    status: "Unknown"
  maxUnhealthy: "40%"
  nodeStartupTimeout: "10m"
  remediationTemplate: <2>
    kind: SelfNodeRemediationTemplate
    apiVersion: self-node-remediation.medik8s.io/v1alpha1
    name: selfnoderemediationtemplate-sample
----
<1> Selects whether the machine health check is for `worker` or `control-plane` nodes. The label can also be user-defined.
<2> Specifies the details for the remediation template.

+
.. To create a `MachineHealthCheck` CR, run the following command:
+
[source,terminal]
----
$ oc create -f <mhc-name>.yaml
----

.. To update a `MachineHealthCheck` CR, run the following command:
+
[source,terminal]
----
$ oc apply -f <mhc-name>.yaml
----
