This document discusses a virtual machine solution based on the open-source component KubeVirt, using KubeVirt virtualization technology to create a Windows operating system image through an ISO image file.
All components in the cluster are functioning correctly.
Please prepare the Windows image and the latest virtio-win-tools in advance.
Please prepare the repository for storing the image. This document takes the build-harbor.example.cn repository as an example, and please replace it according to your actual environment.
When starting KubeVirt, the size of the custom image's filesystem will affect the speed of writing the image to the disk in PVC. If the filesystem is too large, it may result in extended creation times.
It is recommended to keep the Linux root partition or Windows C drive below 100G to minimize the initial size. Subsequent expansion can be done through cloud-init (for Windows systems, it must be expanded manually after creation).
Create a Docker image from the prepared Windows and virtio-win ISO images, and push it to the repository. This document uses Windows Server 2019 as an example.
Create a Docker Image from the Windows ISO
Navigate to the directory where the ISO image is stored, and execute the following command in the terminal to rename the ISO image to win.iso.
Execute the following command to create a Dockerfile.
Edit the Dockerfile, add the following content, and save it.
Execute the following command to build the Docker image.
Execute the following command to push the image to the repository.
Create a Docker Image from the virtio-win ISO
Navigate to the directory where the ISO image is stored, and execute the following command in the terminal to create a Dockerfile.
Edit the Dockerfile, add the following content, and save it.
Execute the following command to build the Docker image.
Execute the following command to push the image to the repository.
Access the Container Platform.
In the left navigation bar, click on Virtualization > Virtual Machines.
Click on Create Virtual Machine.
Fill in the necessary parameters such as Name, Image, etc., in the form page. For detailed parameters and configuration, please refer to Create Virtual Machine.
Switch to YAML.
Replace the configuration under the spec.template.spec.domain.devices.disks field with the following content.
Add the following content under the spec.template.spec.volumes field.
Check the YAML file. The complete YAML after finishing the configuration is as follows.
Click Create.
Click Actions > VNC Login.
When the prompt press any key boot from CD or DVD appears, press any key to enter the Windows installation program; if you do not see the prompt, click on Send Remote Command in the top left of the page, then select Ctrl-Alt-Delete from the dropdown menu to restart the server.
Note: If a message appears at the top of the virtual machine details page stating The current virtual machine has configuration changes that require a restart to take effect, please restart, this message can be ignored; no restart is necessary.
Follow the installation instructions to install the system after entering the installation page.
Note: During the partition selection step, the bus must be sata for the disk to be correctly recognized. Therefore, you need to select each partition in turn and click Delete to remove all partitions, allowing the system to handle it automatically.
After configuring the administrator account password, click Send Remote Command in the top left of the page, then select Ctrl-Alt-Delete from the dropdown menu.
When prompted The Ctrl+Alt+Delete combination will restart the server, confirm to restart, click OK.
Enter the password to access the Windows system desktop; at this point, the Windows operating system installation is complete.
This tool primarily contains the necessary drivers.
Open File Explorer.
Double-click CD Drive(E:) virtio-win-<version>, run the virtio-win-guest-tools directory to enter the installation page, and follow the installation instructions. The <version> part should be based on the actual situation.
After the installation is complete, power off the Windows system.
Please refer to Export Virtual Machine Image for the specific operation.
Access the Container Platform.
In the left navigation bar, click on Virtualization > Virtual Machines.
Click on Create Virtual Machine.
Fill in the necessary parameters on the form page. For the image, select the exported Windows image. For detailed parameters and configuration, please refer to Create Virtual Machine.
(Optional) If using a newer operating system, such as Windows 11, enable features like clock, UEFI, TPM, etc. Switch to YAML and replace the original YAML file with the following YAML file.
Click Create.
By configuring a NodePort type internal route, expose the port for remote desktop connections.
Access the Container Platform.
In the left navigation bar, click on Virtualization > Virtual Machines.
Click on the virtual machine name created with the Windows image in the list to enter the details page.
Click on the Add icon next to Internal Route in the Login Information area.
Configure parameters according to the following instructions.
Parameter | Description |
---|---|
Type | Select NodePort. |
Port |
|
Click OK to return to the details page.
Click on the Internal Route link in the Login Information area.
Save the Virtual IP information in the basic information area and the Host Port information in the port area.
This document discusses using the Windows operating system for remote connection as an example. Other operating systems can use software that supports the RDP protocol for connection.
Open Remote Desktop Connection.
Enter the saved Virtual IP and Host Port from the Add Internal Route step, formatted as Virtual IP:Host Port, for example: 192.1.1.1:3389 .
Click Connect.