Live VM Switching
Autonomous instant migration of a virtual machine from one Kubernetes node to another without stopping applications.
Problem #
Virtual machines in a Kubernetes cluster often run on nodes with varying characteristics: some nodes are being upgraded, others fail, and some sit idle because of scheduled maintenance. Developers are forced to manually move VMs, shut down services, and restart containers, leading to downtime, SLA violations, and added risk.
Why now #
As the number of native container workloads grows, the use of hypervisors compatible with KubeVirt for running legacy systems is becoming more common. KVM live‑migration tools on Linux have stabilized, and the Kubernetes API for managing VMs has gained broader support. What is needed is a simple, fully automated chain that lets you change hosts without rebooting the VM.
Why it’s cool #
The benefit is that the VM switches over without stopping, without restarting user applications, while preserving the exact state of disks, network interfaces, and system configurations. This removes one of the key bottlenecks in flexible VM‑cloud operations and opens up dynamic load balancing, planned node upgrades, and rapid disaster recovery.
How to build it #
- Identify the candidate – create a
LiveSwitchCRD with fieldsvmName,targetNode,mode: full|delta. - Collect state – use the KubeVirt API to get the current VM spec and the list of attached PVs and network resources.
- Create a temporary snapshot – run
kubevirt.io/restoreindeltamode on the target node to sync only changed blocks. - Switch networks – use CNI to move virtual interfaces to the new node and update DNS IP addresses.
- Launch the new VM – start a copy of the VM on the target node, then gracefully shut down the old instance.
- Cleanup – delete temporary volumes and the old VM process, ensuring all logs and metrics are transferred.
- Monitor – add a Prometheus exporter that checks migration status and alerts on rollback.
Initial working slice:
LiveSwitchCRDswitch_vm.shscript that performs steps 2–5 viakubectlandvirtctl.
Who has tried #
KubeVirt has its own live‑migration mechanism, but it is limited to migrations within a single cluster without network integration and does not allow manual node selection. Other projects such as virt-migrate require manual intervention and do not expose an automation API. Thus, I am not aware of any full‑scale analogues.
First customers #
Those running legacy applications in a virtual environment and already using KubeVirt:
- IT departments of large services where downtime is unacceptable.
- Monitoring and logging systems that must operate continuously. Approach can be through Kubernetes conferences, KubeVirt forums, and internal DevOps channels.
What kills it #
If the hypervisor does not support delta synchronization (only full snapshots), migration will become a full VM stop and SLA loss.