|
| 1 | +# VirtualMachine Creation Plan |
| 2 | + |
| 3 | +Use the `resources_create_or_update` tool with the following YAML: |
| 4 | + |
| 5 | +```yaml |
| 6 | +apiVersion: kubevirt.io/v1 |
| 7 | +kind: VirtualMachine |
| 8 | +metadata: |
| 9 | + name: {{.Name}} |
| 10 | + namespace: {{.Namespace}} |
| 11 | +spec: |
| 12 | + runStrategy: Halted |
| 13 | +{{- if .Instancetype}} |
| 14 | + instancetype: |
| 15 | + name: {{.Instancetype}} |
| 16 | + kind: VirtualMachineClusterInstancetype |
| 17 | +{{- end}} |
| 18 | +{{- if .Preference}} |
| 19 | + preference: |
| 20 | + name: {{.Preference}} |
| 21 | + kind: VirtualMachineClusterPreference |
| 22 | +{{- end}} |
| 23 | +{{- if .UseDataSource}} |
| 24 | + dataVolumeTemplates: |
| 25 | + - metadata: |
| 26 | + name: {{.Name}}-rootdisk |
| 27 | + spec: |
| 28 | + sourceRef: |
| 29 | + kind: DataSource |
| 30 | + name: {{.DataSourceName}} |
| 31 | + namespace: {{.DataSourceNamespace}} |
| 32 | + storage: |
| 33 | + resources: |
| 34 | + requests: |
| 35 | + storage: 30Gi |
| 36 | +{{- end}} |
| 37 | + template: |
| 38 | + spec: |
| 39 | + domain: |
| 40 | + devices: |
| 41 | + disks: |
| 42 | + - name: {{.Name}}-rootdisk |
| 43 | +{{- if not .Instancetype}} |
| 44 | + memory: |
| 45 | + guest: 1Gi |
| 46 | +{{- end}} |
| 47 | + volumes: |
| 48 | + - name: {{.Name}}-rootdisk |
| 49 | +{{- if .UseDataSource}} |
| 50 | + dataVolume: |
| 51 | + name: {{.Name}}-rootdisk |
| 52 | +{{- else}} |
| 53 | + containerDisk: |
| 54 | + image: {{.ContainerDisk}} |
| 55 | +{{- end}} |
| 56 | +``` |
| 57 | + |
| 58 | +## Verification |
| 59 | + |
| 60 | +After creating the VirtualMachine, verify it was created successfully: |
| 61 | + |
| 62 | +Use the `resources_get` tool: |
| 63 | +- **apiVersion**: `kubevirt.io/v1` |
| 64 | +- **kind**: `VirtualMachine` |
| 65 | +- **namespace**: `{{.Namespace}}` |
| 66 | +- **name**: `{{.Name}}` |
| 67 | + |
| 68 | +Check the resource details for any warnings or errors in the status conditions. |
| 69 | + |
| 70 | +## Troubleshooting |
| 71 | + |
| 72 | +If the VirtualMachine fails to create or start: |
| 73 | + |
| 74 | +1. **Check the VM resource details and events**: |
| 75 | + - Use `resources_get` tool with apiVersion `kubevirt.io/v1`, kind `VirtualMachine`, namespace `{{.Namespace}}`, name `{{.Name}}` |
| 76 | + - Look for error messages in the status conditions |
| 77 | + |
| 78 | +2. **Verify instance type exists** (if specified): |
| 79 | + - Use `resources_get` tool with apiVersion `instancetype.kubevirt.io/v1beta1`, kind `VirtualMachineClusterInstancetype`, name `{{.Instancetype}}` |
| 80 | + |
| 81 | +3. **Verify preference exists** (if specified): |
| 82 | + - Use `resources_get` tool with apiVersion `instancetype.kubevirt.io/v1beta1`, kind `VirtualMachineClusterPreference`, name `{{.Preference}}` |
| 83 | + |
| 84 | +4. **Check KubeVirt installation**: |
| 85 | + - Use `pods_list` tool with namespace `kubevirt` |
0 commit comments