From 111caee761bf692ecee3ea07daedf46d1b109ed1 Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Thu, 15 Jan 2026 12:48:09 +0100 Subject: [PATCH] Update evictionStrategy for imported VMs The versions 1.6 and 1.7 have been updated because they are currently considered relevant. All older versions that support the VM Importer plugin are also affected, but are no longer supported anyway. Related to: https://github.com/harvester/harvester/issues/9849 Signed-off-by: Volker Theile --- .../version-v1.6/advanced/addons/vmimport.md | 27 +++++++++++++++++++ .../version-v1.7/advanced/addons/vmimport.md | 27 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/versioned_docs/version-v1.6/advanced/addons/vmimport.md b/versioned_docs/version-v1.6/advanced/addons/vmimport.md index 60e7d3d8c1..6ca4e0e1a6 100644 --- a/versioned_docs/version-v1.6/advanced/addons/vmimport.md +++ b/versioned_docs/version-v1.6/advanced/addons/vmimport.md @@ -243,3 +243,30 @@ To address the issue, perform one of the following workarounds: - Shut down the virtual machine before migrating it to Harvester - In the `VirtualMachineImport` CRD spec, set the `forcePowerOff` field to `true`. - Install VMware Tools or [open-vm-tools](https://knowledge.broadcom.com/external/article?legacyId=2073803). + +##### Eviction strategy is not set + +When importing virtual machines, the eviction strategy field is not configured, which subsequently prevents live migration of the virtual machine. +To fix this, please run the following command: + +```shell +kubectl patch VirtualMachine -n --type=merge -p '{ + "spec": { + "template": { + "spec": { + "evictionStrategy": "LiveMigrateIfPossible" + } + } + } +}' +``` + +To configure all incorrectly configured virtual machines at once, please use the following command: + +```shell +for vm in $(kubectl get VirtualMachine -A -o json | jq -r '.items[] | select(.spec.template.spec.evictionStrategy == null) | "\(.metadata.namespace):\(.metadata.name)"'); do \ + kubectl patch VirtualMachine ${vm#*:} -n ${vm%:*} --type=merge -p '{"spec":{"template":{"spec":{"evictionStrategy":"LiveMigrateIfPossible"}}}}'; \ +done +``` + +You need to reboot the virtual machine to apply the changes. diff --git a/versioned_docs/version-v1.7/advanced/addons/vmimport.md b/versioned_docs/version-v1.7/advanced/addons/vmimport.md index 7b834b253d..297abe4773 100644 --- a/versioned_docs/version-v1.7/advanced/addons/vmimport.md +++ b/versioned_docs/version-v1.7/advanced/addons/vmimport.md @@ -285,3 +285,30 @@ To address the issue, perform one of the following workarounds: - Shut down the virtual machine before migrating it to Harvester - In the `VirtualMachineImport` CRD spec, set the `forcePowerOff` field to `true`. - Install VMware Tools or [open-vm-tools](https://knowledge.broadcom.com/external/article?legacyId=2073803). + +##### Eviction strategy is not set + +When importing virtual machines, the eviction strategy field is not configured, which subsequently prevents live migration of the virtual machine. +To fix this, please run the following command: + +```shell +kubectl patch VirtualMachine -n --type=merge -p '{ + "spec": { + "template": { + "spec": { + "evictionStrategy": "LiveMigrateIfPossible" + } + } + } +}' +``` + +To configure all incorrectly configured virtual machines at once, please use the following command: + +```shell +for vm in $(kubectl get VirtualMachine -A -o json | jq -r '.items[] | select(.spec.template.spec.evictionStrategy == null) | "\(.metadata.namespace):\(.metadata.name)"'); do \ + kubectl patch VirtualMachine ${vm#*:} -n ${vm%:*} --type=merge -p '{"spec":{"template":{"spec":{"evictionStrategy":"LiveMigrateIfPossible"}}}}'; \ +done +``` + +You need to reboot the virtual machine to apply the changes.