Créer une VM Windows à partir d'une image ISO dans Google Distributed Cloud
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Ce document explique comment créer une machine virtuelle (VM) Windows qui démarre à partir d'une image ISO à l'aide de l'environnement d'exécution de VM sur GDC. Lorsque la VM démarre, vous devez effectuer manuellement la routine de configuration de Windows.
Pour créer une VM Windows, suivez les étapes et les sections de ce document dans l'ordre.
Pour démarrer à partir d'une image ISO Windows, créez d'abord un VirtualMachineDisk avec un diskType de cdrom. Utilisez votre ISO Windows comme source pour ce disque.
Créez un fichier manifeste VirtualMachineDisk, tel que windows-iso.yaml, dans l'éditeur de votre choix :
nanowindows-iso.yaml
Copiez et collez le fichier manifeste YAML suivant :
Enregistrez et fermez le fichier manifeste dans votre éditeur.
Créez VirtualMachineDisk en utilisant kubectl :
kubectlapply-fwindows-iso.yaml
Créer un disque de pilotes de VM
Pour démarrer à partir d'une image ISO Windows et terminer le processus d'installation, la VM doit avoir accès aux pilotes virtio. Pour fournir les pilotes virtio à la VM, procédez comme suit:
Créez un fichier manifeste VirtualMachineDisk, tel que virtio-driver.yaml, dans l'éditeur de votre choix :
nanovirtio-driver.yaml
Copiez et collez le fichier manifeste YAML suivant :
Ce fichier manifeste extrait les derniers pilotes virtio à partir d'un dépôt Docker public et définit diskType sur cdrom. Votre VM utilise ce disque pendant le processus d'installation.
Enregistrez et fermez le fichier manifeste dans votre éditeur.
Créez VirtualMachineDisk en utilisant kubectl :
kubectlapply-fvirtio-driver.yaml
Créer une VM Windows
Créez une VM qui démarre à partir du fichier ISO Windows VirtualMachineDisk et associe le disque de pilotes virtio:
Dans l'éditeur de votre choix, créez un fichier manifeste qui définit un VirtualMachineDisk pour le volume de démarrage et un VirtualMachine, tel que windows-vm.yaml:
nanowindows-vm.yaml
Copiez et collez le fichier manifeste YAML suivant :
Remplacez VM_NAME par le nom que vous souhaitez donner à votre VM.
Ce fichier manifeste crée un volume de démarrage de 100 Gio. Comme ce volume de démarrage est vide au premier démarrage de la VM, la VM démarre à partir de l'ISO en tant qu'appareil CD-ROM pour démarrer la routine de configuration. Les pilotes virtio sont également joints pour finaliser le processus d'installation.
Enregistrez et fermez le fichier manifeste dans votre éditeur.
Créez VirtualMachineDisk et VirtualMachine à l'aide de kubectl:
kubectlapply-fwindows-vm.yaml
Se connecter à la VM Windows et terminer l'installation de l'OS
La VM démarre et s'exécute à partir de l'ISO Windows de la section précédente. Connectez-vous à votre VM, terminez le processus d'installation de Windows et configurez votre VM:
Pour en savoir plus sur l'utilisation de kubectl virt vnc pour vous connecter à votre VM, consultez la section Se connecter directement via VNC.
Dans la configuration de Windows, choisissez d'effectuer une installation personnalisée.
Sélectionnez Load driver (Charger le pilote), accédez au répertoire viostor sur le disque virtio, puis sélectionnez le répertoire correspondant à la version de Windows que vous souhaitez installer.
Les pilotes de stockage et de réseau de virtio étant désormais disponibles, terminez le reste du processus d'installation de Windows.
Nous vous recommandons d'activer le protocole RDP afin de pouvoir vous connecter directement à la VM après l'installation.
Dissocier l'image ISO et le disque de pilotes
Une fois l'installation de Windows terminée, supprimez le disque de pilotes virtio et l'image ISO Windows de la VM:
Arrêtez votre VM Windows:
kubectlvirtstopVM_NAME
Remplacez VM_NAME par le nom de votre VM Windows.
Utilisez kubectl pour modifier la VM :
kubectleditgvmVM_NAME
Remplacez VM_NAME par le nom de votre VM Windows.
Dans votre éditeur, mettez à jour la section spec.disks pour supprimer les disques ISO et virtio Windows, comme indiqué dans l'exemple suivant. Le seul disque restant associé à la VM doit être VM_NAME-boot-dv:
Enregistrez et fermez le fichier manifeste de la VM.
Démarrez votre VM Windows:
kubectlvirtstartVM_NAME
Remplacez VM_NAME par le nom de votre VM Windows.
Vérifiez le STATUS de votre VM :
kubectl get gvm VM_NAME
Remplacez VM_NAME par le nom de votre VM Windows.
Vérifiez que votre VM est à l'état Running. Si la VM n'est pas à l'état Running, vérifiez votre fichier manifeste de ressources VirtualMachine pour vous assurer que vous n'avez supprimé que l'ISO Windows et le disque virtio. Vérifiez que l'hôte dispose de suffisamment de ressources de calcul pour démarrer votre VM.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/01 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)"]]