/rh-virt:vm-rebalancefrom rh-virt
Orchestrate VM migrations across cluster nodes for load balancing, maintenance, and resource optimization. Use when: - "Move VM database-01 to worker-03" - "Rebalance VMs to optimize CPU load" - "Drain worker-02 for maintenance" - "Automatically rebalance the cluster" Supports Manual (user-driven) and Automatic (AI-driven) modes. NOT for creating VMs (use vm-create) or lifecycle only (use vm-lifecycle-manager).
Ships in rh-virt. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Orchestrate VM migrations across OpenShift cluster nodes for load balancing, maintenance, and resource optimization. Supports manual and automatic rebalancing with live migration (zero downtime) and cold migration (brief downtime) strategies.
Implementation: Uses KubeVirt's VirtualMachineInstanceMigration API for live migrations and node affinity for cold migrations.
Required MCP Server: openshift-virtualization (OpenShift MCP Server)
Required MCP Tools:
resources_list - List VMs and nodesresources_get - Get VM and node detailsresources_create_or_update - Create migrations and update VM specsvm_lifecycle - Start/stop VMs for cold migrationnodes_top - Monitor node resource usagepods_top - Monitor VM resource consumptionRequired Environment Variables:
KUBECONFIG - Path to Kubernetes configuration fileRequired Cluster Setup:
Before executing:
openshift-virtualization exists in mcps.json → If missing, report setupKUBECONFIG is set (presence only, never expose value) → If missing, reportresources_getHuman Notification Protocol: ❌ Cannot execute vm-rebalance: MCP server not available. Setup: Add to mcps.json, set KUBECONFIG, restart Claude Code. Docs: https://github.com/openshift/openshift-mcp-server
⚠️ SECURITY: Never display KUBECONFIG path or credential values.
Trigger when:
/vm-rebalanceUser phrases:
Do NOT use when:
/vm-create/vm-lifecycle-manager/vm-clone/vm-deleteManual Mode: User specifies VM name(s) and target node(s). Example: "Move VM database-01 to worker-03"
Automatic Mode: User requests AI-driven rebalancing. Example: "Rebalance VMs based on CPU"
For Manual Mode:
Document Consultation (REQUIRED - Execute FIRST):
For Automatic Mode:
Document Consultation (REQUIRED - Execute FIRST):
Shared by ALL migration strategies. Execute before any VM migration:
MCP Tool: resources_get (apiVersion="kubevirt.io/v1", kind="VirtualMachine", name=<vm>, namespace=<ns>)
Extract: spec.template.spec.volumes[].persistentVolumeClaim.claimName, status.ready
Errors: VM not found → Use vm-inventory | Namespace not found → Verify name | Permission denied → Check RBAC
MCP Tool (if VM running): resources_get (apiVersion="kubevirt.io/v1", kind="VirtualMachineInstance", name=<vm>, namespace=<ns>)
Extract: status.nodeName, status.phase
Validation: If already on target → "VM already on target node. No migration needed."
MCP Tool: resources_get (apiVersion="v1", kind="PersistentVolumeClaim", name=<pvc>, namespace=<ns>)
Extract: spec.accessModes
Error for live migration: If RWO → "Cannot live migrate. Use cold migration (brief downtime ~30-60s)."
Reference: references/live-migration-best-practices.md
MCP Tool: resources_list (apiVersion="v1", kind="Node")
Validation: Verify target exists, status.conditions[] shows Ready=True, not cordoned
Errors: Not found → "Node doesn't exist" | Not Ready → "Choose different target" | Cordoned → "Uncordon or choose different target"
Reference: scheduling-errors.md
Applies to Automatic Mode only.
Use resources_list (apiVersion="v1", kind="Node")
Filter where ALL true:
metadata.labels["kubevirt.io/schedulable"] == "true"status.capacity["devices.kubevirt.io/kvm"] > "0"node-role.kubernetes.io/control-plane or node-role.kubernetes.io/master labelIf no nodes: "No suitable nodes. Check OpenShift Virtualization operator and hardware virtualization support."
Note: Ignore custom taints. Use official KubeVirt labels.
Live Migration: Zero downtime, <1s pause during cutover. Requires RWX storage. Memory transferred while VM runs.
Cold Migration: Brief downtime (~30-60s). Works with any storage. Stop VM → Update placement → Start on target.
Reference: references/live-migration-best-practices.md
ALL strategies MUST use this standardized format for consistency.
Show only what matters:
Table 1: VM Rebalance Plan
## 📋 VM Rebalance Plan
| VM | Instance Type | Current Node | → | New Node | Type | Downtime | Notes |
|----|---------------|--------------|---|----------|------|----------|-------|
| vm-1 | u1.xlarge | worker-01 | → | worker-03 | Live | <1s pause | ContainerDisk |
| vm-2 | u1.2xmedium | worker-01 | → | worker-02 | Cold | ~40s | RWO storage |
| vm-3 | u1.medium | worker-02 | - | *stays* | - | - | Already balanced |
Column Definitions: VM name | Instance type | Current node | Movement indicator | Target node (or stays) | Migration type (Live/Cold/-) | Downtime (<1s/~30-60s/-) | Brief explanation
Table 2: Node State Before → After
## 📊 Node State: Before → After
| Node | VMs Now | CPU Now | Memory Now | → | VMs After | CPU After | Memory After | Change |
|------|---------|---------|------------|---|-----------|-----------|--------------|--------|
| worker-01 | 5 | 85% | 72% | → | 3 | 68% | 59% | ✓ Reduced load |
| worker-02 | 2 | 42% | 48% | → | 3 | 58% | 61% | ← Receiving VMs |
| worker-03 | 3 | 38% | 51% | → | 4 | 55% | 63% | ← Receiving VMs |
CRITICAL - Capacity Calculation Method:
CPU/Memory percentages MUST be calculated based on allocated capacity, not actual runtime usage:
CPU Percentage Calculation:
resources_get Node → status.capacity.cpu (e.g., "32" = 32 vCPUs)spec.domain.cpu.sockets × spec.domain.cpu.cores × spec.domain.cpu.threadsMemory Percentage Calculation:
resources_get Node → status.capacity.memory (e.g., "128Gi")spec.domain.memory.guestExample: Node with 32 vCPUs hosting VMs with 2+4+8+4+2 = 20 vCPUs → CPU = 62.5% (20/32), NOT the actual runtime usage which might be 0% if VMs are idle.
Rationale: Shows capacity planning (how much is reserved) rather than runtime utilization, which is more useful for rebalancing decisions.
Overcommit Detection and Warning:
If any node's CPU or Memory percentage exceeds 100% after rebalancing:
⚠️ **OVERCOMMIT WARNING**
**Node(s) will be overcommitted after this rebalance:**
- **worker-02**: CPU 125% (40 vCPUs allocated / 32 vCPUs capacity) - **25% overcommit**
- **worker-03**: Memory 110% (88Gi allocated / 80Gi capacity) - **10% overcommit**
**Impact:**
- **CPU overcommit**: VMs may experience CPU throttling and reduced performance when all VMs are active simultaneously
- **Memory overcommit**: Risk of VM eviction or OOM (Out of Memory) if total memory demand exceeds node capacity
**Recommendations:**
- Consider distributing VMs across more nodes to avoid overcommit
- Review VM instance types to ensure they match actual workload requirements
- Monitor node resource usage closely after rebalancing
**Proceed with overcommit?** (yes/cancel)
When NOT to warn: If percentages ≤ 100%, overcommit is not present. Omit this warning section.
After tables, include:
Key Improvement: "Distribution from 1 node to 4 nodes hosting VMs" or "CPU variance reduced from 22% to 4% (81% improvement)"
Rebalance Summary (batch operations):
- Total VMs: 5 | Live: 4 | Cold: 1 | Staying: 2
- Total Downtime: ~40s | Duration: 1-2min (parallel)
Execution Mode: **Parallel** (default) - all VMs rebalance simultaneously OR **Sequential** (user requested)
Terminology Standards:
Symptom: "Cannot live migrate: PVC access mode is ReadWriteOnce" Solution: Use cold migration OR convert PVC to RWX Reference: storage-errors.md
Symptom: "VM cannot be scheduled: ErrorUnschedulable"
Solution: Check node capacity (nodes_top), verify no blocking taints (resources_get Node), add tolerations, choose different target, remove nodeSelector
Reference: scheduling-errors.md
Symptom: "Migration exceeded timeout: 150s per GiB" Solution: Retry migration, reduce VM workload, use cold migration, increase timeout in HyperConverged CR Reference: references/performance-tuning.md
Symptom: "Migration rejected: cluster limit reached (5 concurrent)"
Solution: Wait for migrations to complete (resources_list VirtualMachineInstanceMigration), retry, migrate sequentially, increase limit
Reference: references/performance-tuning.md
Symptom: "Forbidden: User cannot create VirtualMachineInstanceMigration"
Solution: Verify RBAC permissions (create on VirtualMachineInstanceMigration, update on VirtualMachine), contact admin
Symptom: Multiple migrations slow/fail, high network utilization Solution: Reduce concurrent migrations, set bandwidth limit, use dedicated migration network Reference: references/performance-tuning.md
Symptom: "Apply failed: conflict with 'kubernetes-mcp-server' using .spec.runStrategy"
Solution: After vm_lifecycle stop, re-read VM using resources_get before updating nodeAffinity (gets fresh resourceVersion)
Workflow: Stop → Wait → Re-read → Update nodeAffinity → Start
Reference: REBALANCE_MANUAL.md - Sub-step 4b.2.5
openshift-virtualization - OpenShift MCP server (https://github.com/openshift/openshift-mcp-server)resources_list, resources_get, resources_create_or_update, vm_lifecycle, nodes_top, pods_top, nodes_stats_summaryvm-inventory - List VMs and check placementvm-lifecycle-manager - Simple start/stopvm-create - Create VMs with placementvm-snapshot-create - Backup before risky migrationsSkill Strategy Files:
Performance and Best Practices:
Troubleshooting:
Official Documentation:
IMPORTANT: This skill performs VM migrations affecting placement and availability. You MUST:
Before Initiating Migration
Never Auto-Execute
For Batch Operations
Why: Live migration (brief pause, bandwidth, performance impact), Cold migration (downtime, dropped connections), Wrong node (performance degradation), Batch (network saturation)
Rationale: Prevents unintended disruption; maintains user control.
Strategy Implementation: ✅ REBALANCE_MANUAL.md | ✅ REBALANCE_AUTOMATIC.md
Reference Documentation: ✅ live-migration-best-practices.md | ✅ performance-tuning.md | ✅ anti-patterns.md | ✅ production-considerations.md
Last Updated: 2026-02-24 | OpenShift Virtualization: 4.17, 4.18, 4.19, 4.20
REBALANCE_AUTOMATIC.md (opens in a new tab)REBALANCE_MANUAL.md (opens in a new tab)references/README.md (opens in a new tab)references/SOURCES.md (opens in a new tab)references/anti-patterns.md (opens in a new tab)references/live-migration-best-practices.md (opens in a new tab)references/performance-tuning.md (opens in a new tab)references/production-considerations.md (opens in a new tab)references/troubleshooting/INDEX.md (opens in a new tab)references/troubleshooting/lifecycle-errors.md (opens in a new tab)references/troubleshooting/network-errors.md (opens in a new tab)references/troubleshooting/runtime-errors.md (opens in a new tab)references/troubleshooting/scheduling-errors.md (opens in a new tab)references/troubleshooting/storage-errors.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
inheritOther plugins' skills for the same job
npx claudepluginhub rhecosystemappeng/agentic-catalog --plugin rh-virt10 skills in this plugin
/vm-cloneClone existing virtual machines for testing, scaling, or creating templates.
Use when:
- "Clone VM [source] to [target]"
- "Create a copy of VM [name]"
- "Duplicate VM [name] for testing"
- "Create 3 copies of template-vm"
This skill clones VM configuration and optionally creates new storage or references existing storage.
NOT for snapshots (use vm-snapshot for point-in-time backups).
/vm-createCreate new virtual machines in OpenShift Virtualization with automatic instance type resolution and OS selection.
Use when:
- "Create a new VM"
- "Deploy a virtual machine with [OS]"
- "Set up a VM in namespace [name]"
- "Provision a [size] VM"
This skill handles VM creation with intelligent defaults for OpenShift Virtualization.
NOT for managing existing VMs (use vm-lifecycle-manager or vm-delete instead).
/vm-deletePermanently delete virtual machines and their associated resources from OpenShift Virtualization.
Use when:
- "Delete VM [name]"
- "Remove virtual machine [name]"
- "Destroy VM [name]"
- "Clean up VM [name]"
This skill handles permanent VM deletion with strict safety confirmations and typed verification.
NOT for power management (use vm-lifecycle-manager to stop VMs).
/vm-inventoryList and view virtual machines across namespaces with status, resource usage, and health information.
Use when:
- "List all VMs"
- "Show VMs in namespace [name]"
- "What VMs are running?"
- "Get details of VM [name]"
This skill provides comprehensive VM inventory and status reporting.
NOT for creating or modifying VMs (use vm-create or vm-lifecycle-manager instead).
/vm-lifecycle-managerManage virtual machine lifecycle operations including start, stop, and restart.
Use when:
- "Start VM [name]"
- "Stop the virtual machine [name]"
- "Restart VM [name]"
- "Power on/off VM [name]"
This skill handles VM state transitions safely with user confirmation for each action.
NOT for creating VMs (use vm-create) or deleting VMs (use vm-delete).
/vm-snapshot-createCreate virtual machine snapshots for backup and recovery.
Use when:
- "Create a snapshot of VM [name]"
- "Backup VM [name] before upgrade"
- "Take a snapshot of [vm]"
Validates storage class snapshot support, CSI driver capabilities, and guest agent status before snapshot creation.
NOT for VM cloning (use vm-clone to create independent copies).