Skip to content

Instantly share code, notes, and snippets.

@jwhb
Created January 13, 2026 11:30
Show Gist options
  • Select an option

  • Save jwhb/989ca0055f67d8239f45e4e65ae6b43c to your computer and use it in GitHub Desktop.

Select an option

Save jwhb/989ca0055f67d8239f45e4e65ae6b43c to your computer and use it in GitHub Desktop.
KubeVirt / OpenShift Virtualization: Migrate all VMs on Node
#!/bin/bash
# Migrate all KubeVirt VMs of node $1
# Usage: ./migrate-node-vms.sh compute-1
NODENAME=${1:-testcluster-compute-1}
for VMNS in $(oc get vmi -A -l kubevirt.io/nodeName=$NODENAME -ojson | jq -r '.items[] | (.metadata.namespace+"/"+.metadata.name)'); do
virtctl -n $(echo $VMNS |cut -d "/" -f1) migrate $(echo $VMNS |cut -d "/" -f2);
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment