Configuring virtual machine eviction strategy

The LiveMigrate eviction strategy ensures that a virtual machine instance is not interrupted if the node is placed into maintenance or drained. Virtual machines instances with this eviction strategy will be live migrated to another node.

Configuring custom virtual machines with the LiveMigration eviction strategy

You only need to configure the LiveMigration eviction strategy on custom virtual machines. Common templates have this eviction strategy configured by default.

Procedure

  1. Add the evictionStrategy: LiveMigrate option to the spec.template.spec section in the virtual machine configuration file. This example uses oc edit to update the relevant snippet of the VirtualMachine configuration file:

    1. $ oc edit vm <custom-vm> -n <my-namespace>
    1. apiVersion: kubevirt.io/v1
    2. kind: VirtualMachine
    3. metadata:
    4. name: custom-vm
    5. spec:
    6. template:
    7. spec:
    8. evictionStrategy: LiveMigrate
    9. # ...
  2. Restart the virtual machine for the update to take effect:

    1. $ virtctl restart <custom-vm> -n <my-namespace>