|
5 | 5 | [id="virt-setting-node-maintenance-cli_{context}"] |
6 | 6 | = Setting a node to maintenance mode in the CLI |
7 | 7 |
|
8 | | -Set a node to maintenance mode by creating a `NodeMaintenance` custom resource |
9 | | -(CR) object that references the node name and the reason for setting it to |
10 | | -maintenance mode. |
| 8 | +Set a node to maintenance mode by marking it as unschedulable and using the `oc adm drain` command to evict or delete pods from the node. |
11 | 9 |
|
12 | 10 | .Procedure |
13 | 11 |
|
14 | | -. Create the node maintenance CR configuration. This example uses a CR that is |
15 | | -called `node02-maintenance.yaml`: |
| 12 | +. Mark the node as unschedulable. The node status changes to `NotReady,SchedulingDisabled`. |
16 | 13 | + |
17 | | -[source,yaml] |
| 14 | +[source,terminal] |
18 | 15 | ---- |
19 | | -apiVersion: nodemaintenance.kubevirt.io/v1beta1 |
20 | | -kind: NodeMaintenance |
21 | | -metadata: |
22 | | - name: node02-maintenance |
23 | | -spec: |
24 | | - nodeName: node02 |
25 | | - reason: "Replacing node02" |
| 16 | +$ oc adm cordon <node1> |
26 | 17 | ---- |
27 | 18 |
|
28 | | -. Create the `NodeMaintenance` object in the cluster: |
| 19 | +. Drain the node in preparation for maintenance. The node live migrates virtual machine instances that have the `LiveMigratable` condition set to `True` and the `spec:evictionStrategy` field set to `LiveMigrate`. All other pods and virtual machines on the node are deleted and recreated on another node. |
29 | 20 | + |
30 | 21 | [source,terminal] |
31 | 22 | ---- |
32 | | -$ oc apply -f <node02-maintenance.yaml> |
| 23 | +$ oc adm drain <node1> --delete-local-data --ignore-daemonsets=true --force |
33 | 24 | ---- |
34 | 25 |
|
35 | | -The node live migrates virtual machine instances that have the |
36 | | -`LiveMigration` eviction strategy, and taint the node so that it is no longer |
37 | | -schedulable. All other pods and virtual machines on the node are deleted and |
38 | | -recreated on another node. |
| 26 | +* The `--delete-local-data` flag removes any virtual machine instances on the node that use `emptyDir` volumes. Data in these volumes is ephemeral and is safe to be deleted after termination. |
| 27 | + |
| 28 | +* The `--ignore-daemonsets=true` flag ensures that daemon sets are ignored and pod eviction can continue successfully. |
| 29 | + |
| 30 | +* The `--force` flag is required to delete pods that are not managed by a replica set or daemon set controller. |
0 commit comments