Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch Multiple VMs from a datavolume [Windows] #2

Open
Neoclassic opened this issue Mar 14, 2024 · 3 comments
Open

Launch Multiple VMs from a datavolume [Windows] #2

Neoclassic opened this issue Mar 14, 2024 · 3 comments

Comments

@Neoclassic
Copy link

Neoclassic commented Mar 14, 2024

Hi,
I create a datavolume and created a VM

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  name: mywindowsvm
spec:
  running: true
  template:
    metadata:
      labels:
        kubevirt.io/domain: mywindowsvm
    spec:
      domain:
        cpu:
          cores: 4
        features:
          acpi: {}
          apic: {}
          hyperv:
            relaxed: {}
            vapic: {}
            spinlocks:
              spinlocks: 8191
        clock:
          utc: {}
          timer:
            hpet:
              present: false
            pit:
              tickPolicy: delay
            rtc:
              tickPolicy: catchup
            hyperv: {}
        devices:
          blockMultiQueue: true
          disks:
            - bootOrder: 1
              disk:
                bus: sata
              name: cdromiso
            - bootOrder: 2
              disk:
                bus: virtio
              name: virtiocontainerdisk
        firmware:
          bootloader:
            efi:
              secureBoot: false
        machine:
          type: q35
        resources:
          requests:
            memory: 16G
      nodeSelector:
        beta.kubernetes.io/instance-type: m5.metal
      volumes:
      - name: cdromiso
        dataVolume:
          name: windowsvm
      - containerDisk:
          image: quay.io/kubevirt/virtio-container-disk
        name: virtiocontainerdisk

Now when i created another VM windowsvm2 using the same datavolume, i could see the files created by the windowsvm in windowsvm.

My question is how to create multiple isolated VMs using the same data volume.

My another question is even if i add another disk it is not visible in the Windows VM.

@cwilkers
Copy link
Owner

First, this repo is a bit out of date, it was originally designed for using gitops to create VMs on a cluster.

Second, DataVolumes are also (while still supported) being deprecated in favor of PVCs with populators.

You can read more at the KubeVirt docs at https://kubevirt.io/user-guide/virtual_machines/disks_and_volumes/

Now to answer the questions you had:

You can create multiple isolated VMs using the same data volume through two ways:

First, you can create a new data volume for the new vm that uses the existing data volume as its source. This will, when created, set up a clone operation and copy the original PVC to a new one in the VM's namespace.

Second, you can create your VM with a dataVolumeTemplate entry. Basically this embeds a DataVolume into your VM's definition, and if the PVC the VM needs does not exist, it will be created by CDI before starting the VM.

As for the other question, multiple disks work fine in VMs, double-check the PVC exists, is bound to a PV, and is being bound by the virt-launcher Pod when the VM starts. Look for any errors in those three locations.

@baromm14
Copy link

Here's another helpful link on import populators:

https://github.com/kubevirt/containerized-data-importer/blob/main/doc/cdi-populators.md

@Neoclassic
Copy link
Author

Thanks @cwilkers and @baromm14

I think creating a MasterCopy of Image and Launching individual VMs by cloning MasterCopy make sense.
Since I am using http data source for populating DataVolume, VM Templates solution might be bad in terms of bootTime.
Also the each copy needs to be in the lifecycle of the VM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants