Migrate a VM to a Different Node
Palette supports virtual machine (VM) migration to another physical host in the cluster. This is known as live migration. During live migration, the VM and its memory, storage, and CPU resources are moved from one cluster compute node to another without any noticeable downtime.
Successful live migrations rely on appropriately configured storage and networking, and live migration must be enabled
as a feature gate. Live migration is enabled by default in the feature-gates
section of the KubeVirt configuration
file that is part of the Virtual Machine Orchestrator pack. Refer to
Feature Gates for more information.
Live migration is used with rolling Kubernetes upgrades and workload balancing. To avoid interrupting a VM when a node
is placed into maintenance or upgraded, all VM instances require a LiveMigrate
eviction strategy.
Prerequisites
-
All VM instances must have an eviction strategy set as
evictionStrategy: LiveMigrate
to ensure that a VM is not interrupted if the node is placed into maintenance. This is configured automatically in the KubeVirt configuration file. If needed, you can override the default setting by configuringspec.template.spec.evictionStrategy
. -
VMs that use Persistent Volumes must have shared
ReadWriteMany
(RWX
) access. For more information, refer to the Persistent Volume Access Modes Kubernetes resource. VMs that do not use persistent storage, such as containerDisks, do not require modifications for live migration. -
A VM’s pod network cannot use a Bridge interface. Disable the default Bridge interface on the pod network. However, other interfaces such as those that Multus grants, may use a bridge interface for live migration.
Migrate VM to a Different Node
-
Log in to Palette.
-
From the left Main Menu, choose Clusters and click on your cluster.
-
Click on the Virtual Machines tab.
-
Select the VM to migrate and click either the three-dot Menu or Actions.
-
Click Migrate Node to Node.
Validate
-
Log in to Palette.
-
From the left Main Menu, click Clusters and select the cluster.
-
Navigate to the Virtual Machines tab, and click the VM you migrated.
-
Click the Details tab, and verify that the name and IP address of the new node is changed.
Evacuate a Host
Compute nodes can be placed into maintenance mode using Palette or manually using the cordon
and drain
commands. The
cordon
command marks the node as un-schedulable and the drain
command evacuates all the VMs and pods from it. This
process is useful in case you need to perform hardware maintenance on the node - for example to replace a disk or
network interface card (NIC) card, perform memory maintenance, or if there are any issues with a particular node that
need to be resolved. To learn more, check out the
Safely Drain a Node
Kubernetes resource.
Prerequisites
- Ensure
LiveMigrate
is set as the eviction strategy for all affected VMs. When the host is put in maintenance mode, this feature allows for a smooth and uninterrupted migration process.
Evacuate VMs in Palette
-
Log in to Palette.
-
From the left Main Menu, choose Clusters and click on the Nodes tab.
-
Click the three-dot Menu in the row of the node you want to evacuate and select Turn on maintenance mode. This evacuates all workloads from the node to other nodes in the worker pool.
-
Turn off maintenance mode by clicking the three-dot Menu in the row of the evacuated node and select Turn off maintenance mode.
warningMaintenance mode reduces cluster capacity. Be sure to turn off maintenance mode after maintenance completes.
Validate
You can validate evacuation completed by following the steps below.
-
Log in to Palette.
-
From the left Main Menu, choose Clusters.
-
Verify the Health column displays the Maintenance mode: Completed icon.
Evacuate VMs Manually
-
Obtain the kubeconfig file from Palette, and set the KUBECONFIG environment variable to access it so you can issue kubectl commands to the cluster. To learn how, refer to Set up Kubectl.
-
Issue the following command to mark the node as un-schedulable. This alerts the Kubernetes scheduler not to schedule any new pods on that node but allows existing pods on the node to continue to operate.
Example:
kubectl cordon <node-name>
node-name: The name of the node that should be marked as un-schedulable.
-
Issue the following command to gracefully remove all pods from the node that is undergoing maintenance. When you drain a node, all pods and VMs will be safely evicted from the node.
Example:
kubectl drain <node-name>
node-name: The name of the node that you wish to drain.
infoThe kubectl
drain
command should only be issued to a single node at a time.
Validate
-
Using kubectl, log in to a machine that has access to the kubernetes cluster.
-
Issue the following command to verify the pods are rescheduled on a different node by verifying the name and IP address of the new node changed.
kubectl get pods --output wide