Windows-VM aus ISO-Image in Google Distributed Cloud erstellen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
In diesem Dokument erfahren Sie, wie Sie eine Windows-VM erstellen, die mit VM Laufzeit in GDC von einem ISO-Image bootet. Wenn die VM gestartet wird, führen Sie die Windows-Einrichtung manuell durch.
Folgen Sie der Anleitung in diesem Dokument der Reihe nach, um eine Windows-VM zu erstellen.
Wenn Sie von einem Windows-ISO-Image booten möchten, erstellen Sie zuerst eine VirtualMachineDisk mit einer diskType von cdrom. Verwenden Sie Ihre Windows-ISO-Datei als Quelle für dieses Laufwerk.
Erstellen Sie in einem Editor Ihrer Wahl ein VirtualMachineDisk-Manifest wie windows-iso.yaml.
nanowindows-iso.yaml
Kopieren Sie das folgende YAML-Manifest und fügen Sie es ein:
Speichern und schließen Sie das Manifest in Ihrem Editor.
Erstellen Sie VirtualMachineDisk mit kubectl:
kubectlapply-fwindows-iso.yaml
VM-Treiberlaufwerk erstellen
Damit die VM von einem Windows-ISO-Image booten und die Installation abschließen kann, benötigt sie Zugriff auf die virtio-Treiber. Führen Sie die folgenden Schritte aus, um der VM die virtio-Treiber zur Verfügung zu stellen:
Erstellen Sie in einem Editor Ihrer Wahl ein VirtualMachineDisk-Manifest wie virtio-driver.yaml.
nanovirtio-driver.yaml
Kopieren Sie das folgende YAML-Manifest und fügen Sie es ein:
Dieses Manifest ruft die neuesten virtio-Treiber aus einem öffentlichen Docker-Repository ab und legt diskType als cdrom fest. Dieses Laufwerk wird von Ihrer VM während der Installation verwendet.
Speichern und schließen Sie das Manifest in Ihrem Editor.
Erstellen Sie VirtualMachineDisk mit kubectl:
kubectlapply-fvirtio-driver.yaml
Erstellen Sie eine Windows-VM:
Erstellen Sie eine VM, die von der Windows-ISO VirtualMachineDisk aus startet und das Treiberlaufwerk virtio anhängt:
Erstellen Sie in einem Editor Ihrer Wahl ein Manifest, das eine VirtualMachineDisk für das Bootvolume und eine VirtualMachine wie windows-vm.yaml definiert:
nanowindows-vm.yaml
Kopieren Sie das folgende YAML-Manifest und fügen Sie es ein:
Ersetzen Sie VM_NAME durch den gewünschten Namen für die VM.
Dieses Manifest erstellt ein Bootvolume mit einer Größe von 100 Gibibyte (GiB). Da dieses Boot-Volume beim ersten Starten der VM leer ist, wird die VM vom ISO als CD-ROM-Gerät gestartet, um die Einrichtungsroutine zu starten. Die virtio-Treiber sind ebenfalls angehängt, um die Installation abzuschließen.
Speichern und schließen Sie das Manifest in Ihrem Editor.
Erstellen Sie VirtualMachineDisk und VirtualMachine mit kubectl:
kubectlapply-fwindows-vm.yaml
Verbindung zur Windows-VM herstellen und Betriebssysteminstallation abschließen
Die VM wird gestartet und von der Windows-ISO aus dem vorherigen Abschnitt gestartet. Stellen Sie eine Verbindung zu Ihrer VM her, führen Sie die Windows-Installation durch und konfigurieren Sie die VM:
Stellen Sie eine Verbindung zu Ihrer Windows-VM her.
kubectlvirtvncVM_NAME
Ersetzen Sie VM_NAME durch den Namen Ihrer Windows-VM.
Weitere Informationen zum Herstellen einer Verbindung zu Ihrer VM über kubectl virt vnc finden Sie unter Direkte Verbindung über VNC.
Wählen Sie in der Windows-Einrichtung die Option Benutzerdefinierte Installation aus.
Wählen Sie Treiber laden aus, rufen Sie das Verzeichnis viostor auf dem Laufwerk virtio auf und wählen Sie dann das Verzeichnis aus, das der Version von Windows entspricht, die Sie installieren möchten.
Da die Speicher- und Netzwerktreiber von virtio jetzt verfügbar sind, können Sie mit der restlichen Installation von Windows fortfahren.
Wir empfehlen, das Remote Desktop Protocol zu aktivieren, damit Sie nach der Installation direkt eine Verbindung zur VM herstellen können.
ISO-Image und Treiberlaufwerk trennen
Entfernen Sie nach Abschluss der Windows-Installation das virtio-Laufwerk mit den Treibern und das Windows-ISO-Image aus der VM:
Beenden Sie die Windows-VM:
kubectlvirtstopVM_NAME
Ersetzen Sie VM_NAME durch den Namen Ihrer Windows-VM.
Verwenden Sie kubectl zum Bearbeiten der VM:
kubectleditgvmVM_NAME
Ersetzen Sie VM_NAME durch den Namen Ihrer Windows-VM.
Aktualisieren Sie in Ihrem Editor den Abschnitt spec.disks, um die Windows-ISO und die virtio-Laufwerke zu entfernen, wie im folgenden Beispiel gezeigt. Das einzige Laufwerk, das noch an die VM angehängt ist, sollte VM_NAME-boot-dv sein:
Ersetzen Sie VM_NAME durch den Namen Ihrer Windows-VM.
Prüfen Sie den STATUS Ihrer VM:
kubectl get gvm VM_NAME
Ersetzen Sie VM_NAME durch den Namen Ihrer Windows-VM.
Achten Sie darauf, dass die VM den Status Running hat. Wenn die VM nicht den Status Running hat, prüfen Sie das Ressourcenmanifest VirtualMachine, um sicherzustellen, dass Sie nur das Windows-ISO und das virtio-Laufwerk entfernt haben. Prüfen Sie, ob der Host genügend Rechenressourcen zum Starten Ihrer VM hat.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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)"]]