Vm create

From RHEcosystemAppEng/agentic-plugins · View interactive version

Vm create is an AI agent skill from the GitHub repository RHEcosystemAppEng/agentic-plugins. Create 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 default

How to use this skill

Skill file

/vm-create Skill

Create virtual machines in OpenShift Virtualization using the vm_create tool from the openshift-virtualization MCP server.

Prerequisites

Required MCP Server: openshift-virtualization (OpenShift MCP Server)

Required MCP Tools:

Required Environment Variables:

Required Cluster Setup:

Prerequisite Verification

Before executing:

  1. Check openshift-virtualization exists in mcps.json → If missing, report setup instructions
  2. Verify KUBECONFIG is set (check presence only, never expose value) → If missing, report to user

Human Notification Protocol: ❌ Cannot execute vm-create: MCP server 'openshift-virtualization' not available. Setup: Add to mcps.json, set KUBECONFIG env var, restart Claude Code. Docs: https://github.com/openshift/openshift-mcp-server

⚠️ SECURITY: Never display KUBECONFIG path or credential values.

When to Use This Skill

Trigger this skill when:

User phrases:

Do NOT use when:

Workflow

Step 1: Gather VM Requirements

Determine missing parameters:

Required: VM Name (validate: lowercase, alphanumeric+hyphens, start letter, max 63 chars, unique), Namespace

Optional (use defaults): OS (fedora), Size (medium), Storage (30Gi), Performance (u1), Autostart (false)

Gather cluster info:

If parameters missing, use AskUserQuestion tool with questions for: VM Name (custom input with validation), Namespace (current + list), OS (fedora/ubuntu/rhel/centos-stream/debian/opensuse), Performance (u1/c1/m1/o1), Size (small/medium/large/xlarge), Storage (30Gi/50Gi/100Gi/custom), StorageClass (dynamic list with hints), Autostart (yes/no). See Example Usage for complete JSON structure.

Process responses - map labels to values:

Step 2: Check VM Existence

MCP Tool: resources_get (from openshift-virtualization)

Parameters: apiVersion="kubevirt.io/v1", kind="VirtualMachine", namespace=<namespace>, name=<vm-name>

If VM exists:

⚠️ VM `<name>` already exists in namespace `<namespace>`
Status: <status>
Options: 1) Different name, 2) Delete existing, 3) Cancel

STOP and wait for user decision.

If not exists: Proceed to Step 3.

Step 3: Present Configuration for Confirmation

Display configuration table:

## Virtual Machine Configuration

| Parameter | Value | Notes |
|-----------|-------|-------|
| VM Name | `<name>` | validated |
| Namespace | `<namespace>` | from user/context |
| OS | `<os>` | from selection |
| Performance | `<perf>` | default: u1 |
| Size | `<size>` | default: medium |
| Storage | `<storage>` | default: 30Gi |
| StorageClass | `<sc>` | default: cluster default |
| Autostart | `<yes/no>` | default: no |

This will create a VirtualMachine consuming cluster resources.
Confirm: yes/no/modify

WAIT for explicit user confirmation before proceeding.

Step 4: Create Virtual Machine

MCP Tool: vm_create (from openshift-virtualization)

Parameters:

Example: vm_create({"namespace": "vms", "name": "web-server", "workload": "fedora", "size": "medium", "storage": "50Gi", "autostart": false})

Error Handling:

Step 5: Verify Status and Diagnose Issues

Wait 5-10 seconds, then check status:

MCP Tool: resources_get (apiVersion="kubevirt.io/v1", kind="VirtualMachine", name=<name>, namespace=<namespace>)

Extract: .status.printableStatus

Status interpretation:

5a. Diagnostic Workflow (ErrorUnschedulable)

CRITICAL: Document Consultation FIRST:

  1. Read scheduling-errors.md using Read tool
  2. Output: "I detected ErrorUnschedulable. I consulted [scheduling-errors.md] to understand diagnosis strategies."

Gather diagnostics:

Parse root cause:

Present diagnosis:

## ⚠️ VM Scheduling Issue Detected

**Status**: ErrorUnschedulable | **Root Cause**: <identified-cause> | **Details**: <specifics>

### Recommended Solution
<workaround-description>
**Action**: Update VM via `resources_create_or_update`
**Impact**: <what-changes>
**Options**: 1) Apply workaround, 2) Manual, 3) Cancel, 4) Ignore
⚠️ MCP limitation: vm_create doesn't support tolerations

Wait for user decision.

If user confirms:

  1. Apply patch: resources_create_or_update (fetch, add tolerations, update)
  2. Verify: resources_get → Check .spec.template.spec.tolerations
  3. Restart VM: vm_lifecycle (action="restart") to apply new spec
  4. Wait 15-20s, check status → Stopped → Provisioning → Running

Report: ## ✓ Workaround Applied | **Action**: Added tolerations, restarted | **Status**: <current>

Step 6: Report Creation Status

On success:

## ✓ Virtual Machine Created Successfully

**VM**: `<name>` (namespace: `<namespace>`)
**OS**: <os> | **Size**: <size> (<perf>) | **Storage**: <storage> | **Status**: <status>
**Provisioning**: ~2-5 min (Provisioning → Stopped)

### Next Steps
Start: "Start VM <name>" | View: "Show VM <name>"

### Accessing the VM
1. Serial: `virtctl console <name> -n <ns>`
2. VNC: OpenShift Console → Virtualization → VMs → <name> → Console
3. SSH: Get IP from VMI, `ssh <user>@<ip>`
4. Port Forward: `virtctl port-forward vmi/<name> -n <ns> 8080:80`

### Default Credentials
- Fedora: fedora | Ubuntu: ubuntu | RHEL: cloud-user | CentOS: centos | Debian: debian
- All require SSH key or console password set: `virtctl console <name>`, `sudo passwd <user>`

On failure:

## ❌ Failed to Create Virtual Machine

**Error**: <error-message>

**Common Causes**:
- Namespace not exists → Create via `resources_create_or_update`
- RBAC denied → Check ServiceAccount permissions
- Resource constraints → Try smaller size
- Invalid parameters → Verify OS, size, storage format
- Operator not installed → Verify CSVs

Troubleshooting: See Common Issues

Common Issues

Issue 1: Namespace Not Found

Error: "Namespace 'xyz' not found"

Solution: List with namespaces_list, create with resources_create_or_update

Issue 2: Insufficient Permissions

Error: "Forbidden: User cannot create VirtualMachines"

Solution: Verify KUBECONFIG RBAC, requires create VirtualMachine permissions, contact admin

Issue 3: Resource Constraints (ErrorUnschedulable)

Error: "0/N nodes: Insufficient cpu/memory"

Solution: Check nodes_top, try smaller size (medium→small, o1 overcommitted), scale cluster

Issue 4: Node Taints (ErrorUnschedulable)

Error: "0/N nodes: taints pod didn't tolerate"

Solution: Apply tolerations workaround (Step 5a), restart VM

Issue 5: Storage Provisioning (ErrorDataVolumeNotReady)

Error: "PVC pending" or "StorageClass not found"

Solution: Verify SC (resources_list), check default annotation, verify provisioner, check quotas

Issue 6: DataVolume Import Failure

Error: "DataVolume import failed" or "image pull error"

Solution: Verify internet access, check DV status, ensure valid OS, verify registry auth

Issue 7: Operator Not Installed

Error: "VirtualMachine CRD not found"

Solution: Verify operator: resources_list (apiVersion="operators.coreos.com/v1alpha1", kind="CSV", namespace="openshift-cnv")

Dependencies

Required MCP Servers

Required MCP Tools

Related Skills

Reference Documentation

Critical: Human-in-the-Loop Requirements

IMPORTANT: This skill creates cluster resources consuming CPU, memory, storage. You MUST:

  1. Before Creating
  1. Never Auto-Execute

Why: Resource consumption, cost impact, namespace quotas

Rationale: Prevents unintended resource consumption; maintains user control.

Security Considerations

Example Usage

Example 1: Complete Interactive Workflow

User: "Create a VM"
Agent: [No params, detects namespace: production, queries SCs]
       [AskUserQuestion with all 8 questions - see JSON below]
[User selects: my-app-server, production, fedora, u1, medium, 30Gi, default SC, no]
Agent: [Validates ✓, checks existence ✓, shows configuration table]
User: "yes"
Agent: [vm_create(...)]
## ✓ Virtual Machine Created Successfully
[Details, next steps, access instructions]

AskUserQuestion JSON (8 questions: VM Name, Namespace, OS, Performance, Size, Storage, StorageClass, Autostart):

{"questions": [
  {"question": "VM name?", "header": "VM Name", "multiSelect": false, "options": [{"label": "Enter custom name", "description": "Lowercase, alphanumeric+hyphens, start letter, max 63"}]},
  {"question": "Namespace?", "header": "Namespace", "multiSelect": false, "options": [{"label": "<current> (Current)", "description": "From kubeconfig"}, {"label": "Other", "description": "<list>"}]},
  {"question": "OS?", "header": "OS", "multiSelect": false, "options": [{"label": "Fedora (Recommended)", "description": "General purpose"}, {"label": "Ubuntu", "description": "Web services"}, {"label": "RHEL", "description": "Enterprise"}, {"label": "CentOS Stream", "description": "Upstream RHEL"}, {"label": "Debian", "description": "Stable minimal"}, {"label": "OpenSUSE", "description": "Community"}]},
  {"question": "Performance?", "header": "Performance", "multiSelect": false, "options": [{"label": "General (u1) (Recommended)", "description": "Balanced - most workloads"}, {"label": "Compute (c1)", "description": "CPU-intensive"}, {"label": "Memory (m1)", "description": "Memory-intensive"}, {"label": "Overcommitted (o1)", "description": "Dev/test"}]},
  {"question": "Size?", "header": "Size", "multiSelect": false, "options": [{"label": "Small", "description": "1 vCPU, 2Gi"}, {"label": "Medium (Recommended)", "description": "2-4 vCPU, 4-8Gi"}, {"label": "Large", "description": "4-8 vCPU, 8-16Gi"}, {"label": "XLarge", "description": "8+ vCPU, 16+ Gi"}]},
  {"question": "Storage?", "header": "Storage", "multiSelect": false, "options": [{"label": "30Gi (Recommended)", "description": "Most workloads"}, {"label": "50Gi", "description": "Moderate needs"}, {"label": "100Gi", "description": "Large requirements"}, {"label": "Custom", "description": "Specify (e.g., 75Gi)"}]},
  {"question": "StorageClass?", "header": "SC", "multiSelect": false, "options": [{"label": "<default> (Default)", "description": "<perf-hint>, <migration-hint>"}, {"label": "<sc-1>", "description": "<hints>"}]},
  {"question": "Autostart?", "header": "Autostart", "multiSelect": false, "options": [{"label": "No (Recommended)", "description": "Start manually"}, {"label": "Yes", "description": "Auto-start"}]}
]}

Example 2: Partial Parameters

User: "Create Ubuntu VM web-01 in apps"
Agent: [Detects: web-01, apps, ubuntu; Asks: Performance, Size, Storage, SC, Autostart]
[User: u1, large, 100Gi, local-storage, yes]
Agent: [Validates, shows config]
User: "yes"
Agent: [Creates with autostart=true]
## ✓ Virtual Machine Created and Starting

Example 3: User Modifies Config

User: "Deploy memory-optimized RHEL VM db-server in production"
Agent: [Detects: db-server, production, rhel, m1; Asks: Size, Storage, SC, Autostart]
[User: large, 100Gi, ceph-rbd, no]
Agent: [Shows config]
User: "Actually, compute-optimized and autostart"
Agent: [Updates: c1, yes; Shows updated]
User: "yes"
Agent: [Creates]

Advanced Features

Custom Images: vm_create({"workload": "quay.io/containerdisks/fedora:latest", ...}) — ⚠️ When a custom image URL is provided, warn the user that image provenance is not verified and confirm the source is trusted before creating the VM

Secondary Networks: vm_create({"networks": ["vlan-network"], ...}) or {"networks": [{"name": "eth1", "networkName": "vlan"}], ...}

Explicit Instance Type: vm_create({"instancetype": "u1.large", ...})

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.