Create a Windows VM

About this task

This section provides an example of deploying a WindowsServer-based VM with KubeVirt.

The example uses:

  • A Windows Server 2019 image pre-installed in a qcow2 type image

    • In order to make things easier, as part of making this image be sure to:

      • configure a well-known Administrator password,

      • enable Remote Desktop, and

      • enable Cloud-Init.

  • The CDI Upload Proxy service to upload the Windows Server 2019 pre-installed qcow2 image into a DataVolume/PVC, for the root disk,

    Note that this image will be larger than previous ubuntu image so will take longer to load.

  • Explicit resource request for 4x CPUs and 8G of Memory

  • Multus and SR-IOV CNIs in order to add an additional SR-IOV-based interface.

    These allow the VM to be assigned a unique IP Address from the IP Subnet attached to the SR-IOV-based interface.

  • Connect with the graphical console interface via Virtctl in order to extend the root disk and configure the IP Interface on the SRIOV-based interface.

  • Remote Desktop (RDP) from a remote workstation to the Windows VM’s unique IP Address on the IP Subnet attached to the SR-IOV-based interface.

This example assumes the same infrastructure changes as in the previous Ubuntu VM example have been done here. i.e., SR-IOV interfaces connecting to a 10.10.186.0/24 network on vlan-id=20 have been configured on all hosts, and a NetworkAttachmentDefinition, 186-subnet, has been created to this network.

From a remote workstation that you have configured kubectl, virtctl and virt-viewer, follow the procedure below to create the Windows VM, login to the graphical console and configure the VM’s interface on the 10.10.186.0/24 network. Finally, RDP to the VM from a remote workstation.

Procedure

  1. Use virtctl and the CDI Upload Proxy service to load the Windows Server 2019 qcow2 image into a new DataVolume of size 500G, in the stx-lab namespace.

    $ virtctl image-upload dv stx-lab-winserv-test-disk --namespace stx-lab --insecure \
       --access-mode ReadWriteOnce --size 100Gi --image-path \
       /home/sysadmin/admin/kubevirt/images/winserv2019.qcow2 \
       --uploadproxy-url https://admin.starlingx.abc.com:32111
    
  2. Create the yaml file defining the VirtualMachine CRD instance

    $ cat <<EOF > stx-lab-winserv-test-vm.yaml
    apiVersion: kubevirt.io/v1alpha3
    kind: VirtualMachine
    metadata
      labels:
        kubevirt.io/vm: stx-lab-winserv-test
      name: stx-lab-winserv-test
      namespace: stx-lab
    spec:
      running: true
        template:
          metadata:
            labels:
              kubevirt.io/vm: stx-lab-winserv-test
          spec:
            domain:
              devices:
                disks:
                - disk:
                    bus: virtio
                  name: myrootdisk
                interfaces:
                - masquerade: {}
                  name: default
                - name: 186-subnet
                  sriov: {}
              machine:
                type: q35
              resources:
                requests:
                  cpu: 4
                  memory: 8G
            terminationGracePeriodSeconds: 0
            networks:
            - name: default
              pod: {}
            - multus:
                networkName: stx-lab/186-subnet
              name: 186-subnet
            volumes:
           - name: myrootdisk
             dataVolume:
               name: stx-lab-winserv-test-disk
    EOF
    
  3. Apply the configuration.

    $ kubectl apply -f stx-lab-winserv-test-vm.yaml
    
  4. Connect to the graphical console, extend the root disk, and configure the VM’s interface on the 10.10.186.0/24 network.

    $ virtctl -n stx-lab vnc --kubeconfig="/home/jdoe/.kube/config" stx-lab-winserv
    

    This command launches Windows graphical console.

    1. Login with well-known Administrator password set when the Windows Server 2019 qcow2 image was created.

    2. Extend the root disk to fully use the space on the root disk.

      Computer Management > Storage > Disk Management > Extend Volume (on the C: drive)

    3. Configure the second ethernet adapter (SRIOV-based Interface).

      For example:

      • with static ip address in 10.10.186.0/24 subnet

      • with the gateway ip address and

      • with DNS address (10.10.186.130)

    4. Logout of graphical console.

Results

You can now RDP to the Windows VM using the 10.10.186.<nnn> IP Address.