Criar uma VM do Windows usando uma imagem ISO no Google Distributed Cloud
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Neste documento, mostramos como criar uma máquina virtual (VM) do Windows que é inicializada
de uma ISO usando o ambiente de execução de VMs no GDC. Quando a VM é inicializada, você conclui manualmente a rotina de configuração do Windows.
Para criar uma VM do Windows, siga as etapas e seções deste
documento em ordem.
Para inicializar com uma imagem ISO do Windows, primeiro crie um VirtualMachineDisk com diskType de cdrom. Use o ISO do Windows como fonte desse disco.
Crie um manifesto de VirtualMachineDisk, como windows-iso.yaml, no editor de sua escolha:
Para inicializar com base em um ISO do Windows e concluir o processo de instalação, a
VM precisa ter acesso aos
drivers virtio. Para fornecer os drivers virtio à VM, siga estas etapas:
Crie um manifesto de VirtualMachineDisk, como virtio-driver.yaml, no editor de sua escolha:
Esse manifesto extrai os drivers virtio mais recentes de um repositório público do Docker e define o diskType como cdrom. A VM usa esse disco durante o processo
de instalação.
Salve e feche o manifesto no editor.
Crie VirtualMachineDisk usando kubectl:
kubectlapply-fvirtio-driver.yaml
Criar uma VM do Windows
Crie uma VM com a inicialização do VirtualMachineDisk do ISO do Windows e anexe
o disco dos drivers virtio:
Crie um manifesto que defina um VirtualMachineDisk para o volume de inicialização e uma VirtualMachine, como windows-vm.yaml, no editor de sua escolha:
Esse manifesto cria um volume de inicialização de 100 Gibibyte (GiB). Como esse volume de inicialização está vazio
quando a VM é iniciada pela primeira vez, a VM é inicializada do ISO como um dispositivo de CD-ROM para iniciar
a rotina de configuração. Os drivers virtio também são anexados para concluir o
processo de instalação.
Salve e feche o manifesto no editor.
Crie VirtualMachineDisk e VirtualMachine usando kubectl:
kubectlapply-fwindows-vm.yaml
Conectar-se à VM do Windows e concluir a instalação do SO
A VM é iniciada e inicializada pelo ISO do Windows na seção anterior. Conecte-se à
VM, conclua o processo de instalação do Windows e configure a VM:
Na configuração do Windows, escolha executar uma Instalação personalizada.
Selecione Carregar driver, navegue até o diretório viostor no disco virtio e selecione o diretório que corresponde à versão do Windows que você quer instalar.
Com os drivers de armazenamento e de rede de virtio agora disponíveis, conclua
o restante do processo de instalação do Windows.
Recomendamos ativar o protocolo Remote Desktop para se conectar
diretamente à VM após a instalação.
Remover a imagem ISO e o disco dos drivers
Após a conclusão da instalação do Windows, remova o disco de drivers virtio e
a imagem ISO do Windows da VM:
Interrompa a VM do Windows:
kubectlvirtstopVM_NAME
Substitua VM_NAME pelo nome da sua VM do Windows.
Use kubectl para editar a VM:
kubectleditgvmVM_NAME
Substitua VM_NAME pelo nome da sua VM do Windows.
No seu editor, atualize a seção spec.disks para remover os discos ISO e
virtio do Windows, como mostrado no exemplo a seguir. O único disco restante anexado à VM precisa ser o VM_NAME-boot-dv:
Verifique se a VM está no estado Running. Se a VM não estiver no estado Running, verifique o manifesto do recurso VirtualMachine para garantir que você tenha
só removido o disco ISO e virtio do Windows. Verifique se o host tem recursos de computação suficientes
para iniciar sua VM.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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)"]]