// Module included in the following assemblies:
//
// * virt/node_maintenance/virt-setting-node-maintenance.adoc

[id="virt-setting-node-maintenance-cli_{context}"]
= Setting a node to maintenance mode in the CLI

Set a node to maintenance mode by creating a `NodeMaintenance` Custom Resource
(CR) object that references the node name and the reason for setting it to
maintenance mode.

.Procedure

. Create the node maintenance CR configuration. This example uses a CR that is
called `node02-maintenance.yaml`:
+
[source,yaml]
----
apiVersion: nodemaintenance.kubevirt.io/v1beta1
kind: NodeMaintenance
metadata:
  name: node02-maintenance
spec:
  nodeName: node02
  reason: "Replacing node02"
----

. Create the `NodeMaintenance` object in the cluster:
+
[source,terminal]
----
$ oc apply -f <node02-maintenance.yaml>
----

The node live migrates virtual machine instances that have the
`LiveMigration` eviction strategy, and taint the node so that it is no longer
schedulable. All other pods and virtual machines on the node are deleted and
recreated on another node.
