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.