Created
January 13, 2026 11:30
-
-
Save jwhb/989ca0055f67d8239f45e4e65ae6b43c to your computer and use it in GitHub Desktop.
KubeVirt / OpenShift Virtualization: Migrate all VMs on Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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