This document shows you how to create a Windows virtual machine (VM) that boots from an ISO using VM Runtime on Google Distributed Cloud. When the VM boots, you manually complete the Windows setup routine.
You can also create a Windows VM from a prepared disk image using an HTTP source or from Cloud Storage.
Before you begin
To complete this document, you need access to the following resources:
- 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 or see the cluster creation overview. - The
virtctl
client tool installed as a plugin forkubectl
. If needed, install the virtctl client tool.
Create a virtual disk for the ISO image
To successfully create a Windows VM, follow the steps and sections in this document in order.
To boot from a Windows ISO image, first create a VirtualMachineDisk
with
diskType
of cdrom
. Use your Windows ISO as the source for this disk.
Create a
VirtualMachineDisk
manifest, such aswindows-iso.yaml
, in the editor of your choice:nano windows-iso.yaml
Copy and paste the following YAML manifest:
apiVersion: vm.cluster.gke.io/v1 kind: VirtualMachineDisk metadata: name: windows-iso spec: source: http: url: IMG_URL size: 10Gi diskType: cdrom
Replace
IMG_URL
with the HTTP path to your Windows ISO. You can also create and use credentials to import an ISO from Cloud Storage.Save and close the manifest in your editor.
Create the
VirtualMachineDisk
usingkubectl
:kubectl apply -f windows-iso.yaml
Create a VM drivers disk
To successfully boot from a Windows ISO and complete the install process, the
VM needs access to the
virtio
drivers. To provide the virtio
drivers to the VM,
complete the following steps:
Create a
VirtualMachineDisk
manifest, such asvirtio-driver.yaml
, in the editor of your choice:nano virtio-driver.yaml
Copy and paste the following YAML manifest:
apiVersion: vm.cluster.gke.io/v1 kind: VirtualMachineDisk metadata: name: virtio-driver spec: size: 1Gi source: registry: url: docker://quay.io/kubevirt/virtio-container-disk:latest diskType: cdrom
This manifest pulls the latest
virtio
drivers from a public Docker repo and sets thediskType
ascdrom
. Your VM uses this disk during the install process.Save and close the manifest in your editor.
Create the
VirtualMachineDisk
usingkubectl
:kubectl apply -f virtio-driver.yaml
Create a Windows VM
Create a VM that boots from the Windows ISO VirtualMachineDisk
, and attaches
the virtio
drivers disk:
Create a manifest that defines a
VirtualMachineDisk
for the boot volume and aVirtualMachine
, such aswindows-vm.yaml
, in the editor of your choice:nano windows-vm.yaml
Copy and paste the following YAML manifest:
apiVersion: vm.cluster.gke.io/v1 kind: VirtualMachineDisk metadata: name: VM_NAME-boot-dv spec: size: 100Gi --- apiVersion: vm.cluster.gke.io/v1 kind: VirtualMachine metadata: name: VM_NAME spec: osType: Windows disks: - virtualMachineDiskName: VM_NAME-boot-dv boot: true - virtualMachineDiskName: windows-iso - virtualMachineDiskName: virtio-driver interfaces: - name: eth0 networkName: pod-network
Replace
VM_NAME
with the name that you want for your VM.This manifest creates a 100 Gibibyte (GiB) boot volume. As this boot volume is empty when the VM first starts, the VM boots from ISO as a CD-ROM device to start the setup routine. The
virtio
drivers are also attached to complete the install process.Save and close the manifest in your editor.
Create the
VirtualMachineDisk
andVirtualMachine
usingkubectl
:kubectl apply -f windows-vm.yaml
Connect to Windows VM and complete OS install
The VM starts and boots from the Windows ISO in the previous section. Connect to your VM and complete the Windows install process and configure your VM:
Connect to your Windows VM:
kubectl virt vnc VM_NAME
Replace
VM_NAME
with the name of your Windows VM.When prompted, enter your Windows guest OS user credentials for your VM.
For more information about using
kubectl virt vnc
to connect to your VM, see Connect directly using VNC.In the Windows setup, choose to perform a Custom install.
Select Load driver, browse to the viostor directory on the
virtio
disk, then select the directory that matches the version of Windows you want to install.For more information, see KubeVirt Windows
virtio
drivers.With the storage and network drivers from
virtio
now available, complete the rest of the Windows install process.We recommend that you enable Remote Desktop Protocol so you can connect directly to the VM after install.
Detach the ISO image and drivers disk
After the Windows install is complete, remove the virtio
drivers disk and
Windows ISO image from the VM:
Stop your Windows VM:
kubectl virt stop VM_NAME
Replace
VM_NAME
with the name of your Windows VM.Use
kubectl
to edit the VM:kubectl edit gvm VM_NAME
Replace
VM_NAME
with the name of your Windows VM.In your editor, update the
spec.disks
section to remove the Windows ISO andvirtio
disks, as shown in the following example. The only disk left attached to the VM should be theVM_NAME-boot-dv
:apiVersion: vm.cluster.gke.io/v1 kind: VirtualMachine metadata: name: windows-vm spec: osType: Windows disks: - virtualMachineDiskName: windows-vm-boot-dv boot: true interfaces: ...
Save and close the VM manifest.
Start your Windows VM:
kubectl virt start VM_NAME
Replace
VM_NAME
with the name of your Windows VM.Check the
STATUS
of your VM:kubectl get gvm VM_NAME
Replace
VM_NAME
with the name of your Windows VM.Make sure that your VM is in a
Running
state. If the VM isn't in aRunning
state, check yourVirtualMachine
resource manifest to make sure you only removed the Windows ISO andvirtio
disk. Check that the host has enough compute resources to start your VM.