Creare una VM Windows da un'immagine ISO in Google Distributed Cloud
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questo documento illustra come creare una macchina virtuale (VM) Windows che si avvia da un'immagine ISO utilizzando il runtime VM su GDC. Quando la VM si avvia, completa manualmente la routine di configurazione di Windows.
Per creare correttamente una VM Windows, segui nell'ordine i passaggi e le sezioni di questo
documento.
Per avviare da un'immagine ISO di Windows, crea prima un VirtualMachineDisk condiskType di cdrom. Utilizza l'ISO di Windows come origine per questo disco.
Crea un file manifest VirtualMachineDisk, ad esempio windows-iso.yaml, nell'editor che preferisci:
Per avviarsi correttamente da un'immagine ISO di Windows e completare la procedura di installazione, la VM deve avere accesso ai driver virtio. Per fornire i driver virtio alla VM,
completa i seguenti passaggi:
Crea un file manifest VirtualMachineDisk, ad esempio virtio-driver.yaml, nell'editor che preferisci:
Questo manifest estrae i driver virtio più recenti da un repository Docker pubblico e imposta diskType come cdrom. La VM utilizza questo disco durante il processo di installazione.
Salva e chiudi il manifest nell'editor.
Crea il VirtualMachineDisk utilizzando kubectl:
kubectlapply-fvirtio-driver.yaml
Crea una VM Windows
Crea una VM che si avvia dall'immagine ISO di Windows VirtualMachineDisk e collega il disco dei driver virtio:
Crea un manifest che definisce un VirtualMachineDisk per il volume di avvio e un VirtualMachine, ad esempio windows-vm.yaml, nell'editor che preferisci:
Sostituisci VM_NAME con il nome che vuoi assegnare alla VM.
Questo manifest crea un volume di avvio di 100 Gibibyte (GiB). Poiché questo volume di avvio è vuoto
al primo avvio della VM, la VM si avvia dall'ISO come dispositivo CD-ROM per avviare
la routine di configurazione. I driver virtio sono collegati anche per completare la procedura di installazione.
Salva e chiudi il manifest nell'editor.
Crea VirtualMachineDisk e VirtualMachine utilizzando kubectl:
kubectlapply-fwindows-vm.yaml
Connettiti alla VM Windows e completa l'installazione del sistema operativo
La VM si avvia e si avvia dall'immagine ISO di Windows nella sezione precedente. Connettiti alla VM e completa la procedura di installazione di Windows e configura la VM:
Nella configurazione di Windows, scegli di eseguire un'installazione personalizzata.
Seleziona Carica driver, vai alla directory viostor sul disco virtio e poi seleziona la directory corrispondente alla versione di Windows che vuoi installare.
Ora che i driver di archiviazione e di rete di virtio sono disponibili, completa il resto della procedura di installazione di Windows.
Ti consigliamo di attivare il protocollo Remote Desktop per poterti connettere direttamente alla VM dopo l'installazione.
Scollega l'immagine ISO e il disco dei driver
Al termine dell'installazione di Windows, rimuovi il disco dei driver virtio e
l'immagine ISO di Windows dalla VM:
Arresta la VM Windows:
kubectlvirtstopVM_NAME
Sostituisci VM_NAME con il nome della VM Windows.
Usa kubectl per modificare la VM:
kubectleditgvmVM_NAME
Sostituisci VM_NAME con il nome della VM Windows.
Nell'editor, aggiorna la sezione spec.disks per rimuovere i dischi ISO e virtio di Windows, come mostrato nell'esempio seguente. L'unico disco rimasto collegato
alla VM dovrebbe essere VM_NAME-boot-dv:
Assicurati che la VM sia in uno stato Running. Se la VM non è in uno stato Running, controlla il file manifest della risorsa VirtualMachine per assicurarti di aver rimosso solo il file ISO di Windows e il disco virtio. Verifica che l'host disponga di risorse di calcolo sufficienti per avviare la VM.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-01 UTC."],[],[],null,["This document shows you how to create a Windows virtual machine (VM) that boots\nfrom an ISO using VM Runtime on GDC. When the VM boots, you manually\ncomplete the Windows setup routine.\n\nYou can also create a Windows VM from a prepared disk image\n[using an HTTP source](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/create-manage-disks#from_image)\nor\n[from Cloud Storage](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/create-storage-credentials#use_a_secret_to_import_an_image).\n\nBefore you begin\n\nTo complete this document, you need access to the following resources:\n\n- Access to Google Distributed Cloud version 1.12.0 (`anthosBareMetalVersion: 1.12.0`) or higher cluster. You can use any cluster type capable of running workloads. If needed, [try Google Distributed Cloud on Compute Engine](/kubernetes-engine/distributed-cloud/bare-metal/docs/try/gce-vms) or see the [cluster creation overview](/kubernetes-engine/distributed-cloud/bare-metal/docs/installing/creating-clusters/create-clusters-overview).\n- The `virtctl` client tool installed as a plugin for `kubectl`. If needed, [install the virtctl client tool](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/quickstart#install_the_virtctl_client_tool).\n\nCreate a virtual disk for the ISO image\n\nTo successfully create a Windows VM, follow the steps and sections in this\ndocument in order.\n\nTo boot from a Windows ISO image, first create a `VirtualMachineDisk` with\n`diskType` of `cdrom`. Use your Windows ISO as the source for this disk.\n\n1. Create a `VirtualMachineDisk` manifest, such as `windows-iso.yaml`, in the\n editor of your choice:\n\n nano windows-iso.yaml\n\n2. Copy and paste the following YAML manifest:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachineDisk\n metadata:\n name: windows-iso\n spec:\n source:\n http:\n url: \u003cvar label=\"img_url\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eIMG_URL\u003c/span\u003e\u003c/var\u003e\n size: 10Gi\n diskType: cdrom\n\n Replace \u003cvar translate=\"no\"\u003eIMG_URL\u003c/var\u003e with the HTTP path to your Windows ISO.\n You can also\n [create and use credentials to import an ISO from Cloud Storage](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/create-storage-credentials).\n3. Save and close the manifest in your editor.\n\n4. Create the `VirtualMachineDisk` using `kubectl`:\n\n kubectl apply -f windows-iso.yaml\n\nCreate a VM drivers disk\n\nTo successfully boot from a Windows ISO and complete the install process, the\nVM needs access to the\n[`virtio` drivers](https://wiki.libvirt.org/page/Virtio). To provide the `virtio` drivers to the VM,\ncomplete the following steps:\n\n1. Create a `VirtualMachineDisk` manifest, such as `virtio-driver.yaml`, in the\n editor of your choice:\n\n nano virtio-driver.yaml\n\n2. Copy and paste the following YAML manifest:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachineDisk\n metadata:\n name: virtio-driver\n spec:\n size: 1Gi\n source:\n registry:\n url: docker://quay.io/kubevirt/virtio-container-disk:latest\n diskType: cdrom\n\n This manifest pulls the latest `virtio` drivers from a public Docker repo and\n sets the `diskType` as `cdrom`. Your VM uses this disk during the install\n process.\n3. Save and close the manifest in your editor.\n\n4. Create the `VirtualMachineDisk` using `kubectl`:\n\n kubectl apply -f virtio-driver.yaml\n\nCreate a Windows VM\n\nCreate a VM that boots from the Windows ISO `VirtualMachineDisk`, and attaches\nthe `virtio` drivers disk:\n\n1. Create a manifest that defines a `VirtualMachineDisk` for the boot volume and\n a `VirtualMachine`, such as `windows-vm.yaml`, in the editor of your choice:\n\n nano windows-vm.yaml\n\n2. Copy and paste the following YAML manifest:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachineDisk\n metadata:\n name: \u003cvar label=\"vm_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVM_NAME\u003c/span\u003e\u003c/var\u003e-boot-dv\n spec:\n size: 100Gi\n ---\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachine\n metadata:\n name: \u003cvar label=\"vm_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVM_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n osType: Windows\n disks:\n - virtualMachineDiskName: \u003cvar label=\"vm_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVM_NAME\u003c/span\u003e\u003c/var\u003e-boot-dv\n boot: true\n - virtualMachineDiskName: windows-iso\n - virtualMachineDiskName: virtio-driver\n compute:\n cpu:\n vcpus: 2\n memory:\n capacity: 4Gi\n interfaces:\n - name: eth0\n networkName: pod-network\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name that you want for your VM.\n\n This manifest creates a *100 Gibibyte (GiB)* boot volume. As this boot volume is empty\n when the VM first starts, the VM boots from ISO as a CD-ROM device to start\n the setup routine. The `virtio` drivers are also attached to complete the\n install process.\n3. Save and close the manifest in your editor.\n\n4. Create the `VirtualMachineDisk` and `VirtualMachine` using `kubectl`:\n\n kubectl apply -f windows-vm.yaml\n\nConnect to Windows VM and complete OS install\n\nThe VM starts and boots from the Windows ISO in the previous section. Connect to\nyour VM and complete the Windows install process and configure your VM:\n\n1. Connect to your Windows VM:\n\n kubectl virt vnc \u003cvar label=\"vm_name\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of your Windows VM.\n\n When prompted, enter your\n [Windows guest OS user credentials](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/connect-vms#create_initial_user_credentials) for your VM.\n\n For more information about using `kubectl virt vnc` to connect to your VM, see\n [Connect directly using VNC](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/connect-vms#connect_directly_using_vnc).\n2. In the Windows setup, choose to perform a **Custom install**.\n\n3. Select **Load driver** , browse to the **viostor** directory on the `virtio`\n disk, then select the directory that matches the version of Windows you want\n to install.\n\n For more information, see\n [KubeVirt Windows `virtio` drivers](https://kubevirt.io/user-guide/virtual_machines/windows_virtio_drivers/).\n4. With the storage and network drivers from `virtio` now available, complete\n the rest of the Windows install process.\n\n We recommend that you enable Remote Desktop Protocol so you can connect\n directly to the VM after install.\n\nDetach the ISO image and drivers disk\n\nAfter the Windows install is complete, remove the `virtio` drivers disk and\nWindows ISO image from the VM:\n\n1. Stop your Windows VM:\n\n kubectl virt stop \u003cvar label=\"vm_name\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of your Windows VM.\n2. Use `kubectl` to edit the VM:\n\n kubectl edit gvm \u003cvar label=\"vm_name\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of your Windows VM.\n3. In your editor, update the `spec.disks` section to remove the Windows ISO and\n `virtio` disks, as shown in the following example. The only disk left attached\n to the VM should be the \u003cvar scope=\"vm_name\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e`-boot-dv`:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachine\n metadata:\n name: windows-vm\n spec:\n osType: Windows\n disks:\n - virtualMachineDiskName: windows-vm-boot-dv\n boot: true\n interfaces:\n ...\n\n4. Save and close the VM manifest.\n\n5. Start your Windows VM:\n\n kubectl virt start \u003cvar label=\"vm_name\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of your Windows VM.\n6. Check the `STATUS` of your VM:\n\n kubectl get gvm \u003cvar label=\"vm_name\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of your Windows VM.\n\n Make sure that your VM is in a `Running` state. If the VM isn't in a `Running`\n state, check your `VirtualMachine` resource manifest to make sure you only\n removed the Windows ISO and `virtio` disk. Check that the host has enough\n compute resources to start your VM.\n\nWhat's next\n\n- [Connect to VMs](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/connect-vms)\n- [Manage the power state of a VM](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/manage-power-state)"]]