-
Default eviction strategy for multi-node clusters.
-
If a VM blocks an upgrade, you must shut down the VM manually.
-
Default eviction strategy for single-node OpenShift.
You can configure eviction strategies for virtual machines (VMs) or for the cluster.
The default eviction strategy is LiveMigrate. The VM LiveMigrate eviction strategy ensures that a virtual machine instance (VMI) is not interrupted if the node is placed into maintenance or drained. VMIs with this eviction strategy are live migrated to another node.
| Eviction strategy | Description | Interrupts workflow | Blocks upgrades |
|---|---|---|---|
|
Prioritizes workload continuity over upgrades. |
No |
Yes 2 |
|
Prioritizes upgrades over workload continuity to ensure that the environment is updated. |
Yes |
No |
|
Shuts down VMs with no eviction strategy. |
Yes |
No |
Default eviction strategy for multi-node clusters.
If a VM blocks an upgrade, you must shut down the VM manually.
Default eviction strategy for single-node OpenShift.
You can configure an eviction strategy for a virtual machine (VM) by using the command line.
|
The default eviction strategy is You must set the eviction strategy of non-migratable VMs to |
You have installed the OpenShift CLI (oc).
Edit the VirtualMachine resource by running the following command:
$ oc edit vm <vm_name> -n <namespace>
Example eviction strategy:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: <vm_name>
spec:
template:
spec:
evictionStrategy: LiveMigrateIfPossible
# ...
spec.template.spec.evictionStrategy defines the eviction strategy. The default value is LiveMigrate.
Restart the VM to apply the changes:
$ virtctl restart <vm_name> -n <namespace>
You can configure an eviction strategy for a cluster by using the command line.
You have installed the OpenShift CLI (oc).
Edit the hyperconverged resource by running the following command:
$ oc edit hyperconverged kubevirt-hyperconverged -n kubevirt-hyperconverged
Set the cluster eviction strategy as shown in the following example:
Example cluster eviction strategy:
apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
spec:
evictionStrategy: LiveMigrate
# ...
The spec.runStrategy key determines how a VM behaves under certain conditions.
This key has four possible values: Always, RerunOnFailure, Manual, and Halted.
AlwaysThe virtual machine instance (VMI) is always present when a virtual machine (VM) is created on another node. A new VMI is created if the original stops for any reason.
RerunOnFailureThe VMI is re-created on another node if the previous instance fails. The instance is not re-created if the VM stops successfully, such as when it is shut down.
ManualYou control the VMI state manually with the start, stop, and restart virtctl client commands. The VM is not automatically restarted.
HaltedNo VMI is present when a VM is created.
Different combinations of the virtctl start, stop and restart commands affect the run strategy.
The following table describes a VM’s transition between states. The first column shows the VM’s initial run strategy. The remaining columns show a virtctl command and the new run strategy after that command is run.
| Initial run strategy | Start | Stop | Restart |
|---|---|---|---|
Always |
- |
Halted |
Always |
RerunOnFailure |
RerunOnFailure |
RerunOnFailure |
RerunOnFailure |
Manual |
Manual |
Manual |
Manual |
Halted |
Always |
- |
- |
|
If a node in a cluster installed by using installer-provisioned infrastructure fails the machine health check and is unavailable, VMs with |
You can configure a run strategy for a virtual machine (VM) by using the command line.
You have installed the OpenShift CLI (oc).
Edit the VirtualMachine resource by running the following command:
$ oc edit vm <vm_name> -n <namespace>
Example run strategy:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
spec:
runStrategy: Always
# ...
If a node fails and machine health checks are not deployed on your cluster, virtual machines (VMs) with runStrategy: Always configured are not automatically relocated to healthy nodes. To trigger VM failover, you must manually delete the Node object. The following procedure deletes a node from an OKD cluster running on bare metal.
A node where a virtual machine was running has the NotReady condition.
The virtual machine that was running on the failed node has runStrategy set to Always.
You have installed the OpenShift CLI (oc).
Mark the node as unschedulable:
$ oc adm cordon <node_name>
Drain all pods on the node:
$ oc adm drain <node_name> --force=true
This step might fail if the node is offline or unresponsive. Even if the node does not respond, the node might still be running a workload that writes to shared storage. To avoid data corruption, power down the physical hardware before you proceed.
Delete the node from the cluster:
$ oc delete node <node_name>
Although the node object is now deleted from the cluster, it can still rejoin the cluster after reboot or if the kubelet service is restarted. To permanently delete the node and all its data, you must decommission the node.
If you powered down the physical hardware, turn it back on so that the node can rejoin the cluster.
After all resources are terminated on the unhealthy node, a new virtual machine instance (VMI) is automatically created on a healthy node for each relocated VM. To confirm that the VMI was created, view all VMIs by using the OpenShift CLI (oc).