Set compute nodes into maintenance mode, drain the workloads from those nodes, and observe the maintenance mode status.
Outcomes
Mark a node as unschedulable.
Drain the workloads from nodes.
Monitor node maintenance status.
Resume a node from maintenance mode.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that the cluster API is reachable and creates the required resources for this exercise.
[student@workstation ~]$ lab start advanced-maintenance
Instructions
As the admin user, confirm that the vm1 VM is running in the advanced-maintenance project.
Log in to the OpenShift cluster as the admin user with redhatocp as the password.
[student@workstation ~]$ oc login -u admin -p redhatocp \
https://api.ocp4.example.com:6443
Login successful.
...output omitted...Change to the advanced-maintenance project.
[student@workstation ~]$ oc project advanced-maintenance
Now using project "advanced-maintenance" on server "https://api.ocp4.example.com:6443".Use the oc get vmi command to verify that the vm1 vm is running.
Note the name of the node that runs the VM.
You use that node name in a later step.
[student@workstation ~]$oc get vmiNAME AGE PHASE IP NODENAME READY vm1 50mRunning10.10.0.29worker02True
The node might be different in your environment.
To prepare for maintenance mode, verify that OpenShift Virtualization can live migrate the vm1 VM.
Use the -o wide option with the oc get vmi command to get additional information about the VMs.
Verify that the vm1 VM is live migrateable.
[student@workstation ~]$oc get vmi -o wideNAME AGE PHASE IP NODENAME READY LIVE-MIGRATABLE PAUSED vm1 53m Running 10.8.2.38 worker02 TrueTrue
Cordon off the node that runs the VM.
Use the oc adm cordon command to mark the node as unschedulable.
In the following command, replace the worker02 node with the node name from the previous step.
[student@workstation ~]$oc adm cordonnode/worker02worker02cordoned
Confirm that the node has the SchedulingDisabled status.
[student@workstation ~]$oc get nodeNAME STATUS ROLES AGE VERSIONworker02worker02Ready,SchedulingDisabledworker 5d20h v1.27.10+28ed2d7
Evacuate the workload from the node.
Run the oc adm drain command to evacuate all workloads from the node.
In the following command, replace the worker02 node with the node name from the previous step.
The command might take a few minutes to complete.
[student@workstation ~]$oc adm drainnode/worker02\ --delete-emptydir-data --ignore-daemonsetsworker02already cordoned ...output omitted... evicting pod advanced-maintenance/virt-launcher-vm1-n75xj error when evicting pods/"virt-launcher-vm1-n75xj" -n "advanced-maintenance" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget. evicting pod advanced-maintenance/virt-launcher-vm1-n75xj pod/virt-launcher-vm1-n75xj evicted node/worker02drained
Ignore the error messages about the failed eviction of the virt-launcher pod.
OpenShift Virtualization can delete the pod only after its migration is complete and a new virt-launcher pod is running on another node.
Confirm that the VM is now running on another node.
[student@workstation ~]$oc get vmiNAME AGE PHASE IP NODENAME READY vm1 63m Running 10.10.0.40master03True
In this example, the vm1 VM is now on the master03 node.
Resume the node from maintenance mode.
Use the oc adm uncordon command to remove the node from maintenance mode.
Replace the worker02 node in the following command with the name of the node that you set in maintenance mode in the previous step.
[student@workstation ~]$oc adm uncordonnode/worker02worker02uncordoned
Confirm that the node is no longer in maintenance mode.
[student@workstation ~]$oc get nodesNAME STATUS ROLES AGE VERSION master01 Ready control-plane,master,worker 15d v1.27.10+28ed2d7 master02 Ready control-plane,master,worker 15d v1.27.10+28ed2d7 master03 Ready control-plane,master,worker 15d v1.27.10+28ed2d7 worker01 Ready worker 5d20h v1.27.10+28ed2d7worker02Readyworker 5d20h v1.27.10+28ed2d7
As an alternative to the oc adm cordon and oc adm drain commands from the preceding steps, use the Node Maintenance operator to set a node in maintenance mode and to drain its workload.
As the admin user, use the OpenShift web console to install the Node Maintenance operator.
Open a web browser and navigate to https://console-openshift-console.apps.ocp4.example.com
Click and log in as the admin user with redhatocp as the password.
Click → and select from the drop-down menu.
In the field, type maintenance to locate the Node Maintenance operator, and then click .
![]() |
The web console displays information about the Node Maintenance operator. Click to proceed to the page.
![]() |
Click to install the operator with the default options in the openshift-workload-availability namespace.
Wait until the installation is complete and the web console displays the ready for use message.
![]() |
Use the OpenShift web console to retrieve the name of the node that runs the vm1 VM.
Navigate to → .
Select the advanced-maintenance project from the list.
Select the vm1 VM, click the tab, and note the name of the node that runs the VM.
You use that node name in the next step.

The node might be different in your environment.
Create a NodeMaintenance resource with the Node Maintenance operator to set the node from the previous step in maintenance mode and to drain its workload.
Navigate to → and open the page.
In the Node Maintenance card, click to create a NodeMaintenance resource.
![]() |
Complete the form by using the following information:
| Field | Value |
|---|---|
| Name | live-migration-test |
| Node Name | Use the node name from the previous step |
| Reason | Testing Live Migration |
Click to create the NodeMaintenance resource.
Observe the live-migration-test status and wait until the node maintenance state is Succeeded.

Verify that the node does not accept new workloads and that the VM is now running on another node.
Navigate to → and confirm that the node has the Scheduling disabled status.

Navigate to → , click the VM, and then click the tab. Observe the node name and confirm that the VM is running on a different node from the previous step.
End the node maintenance.
Navigate to → and open the page. Click the tab.
On the page, click the vertical ellipsis icon next to the live-migration-test node maintenance, and then click .
Click to confirm the operation and resume the node from maintenance mode.
Navigate to → and confirm that the node no longer has the status anymore.