Skip to main content
EARLY ACCESS

This feature is available as Early Access (EA) and should not be used in production.

Create a KubeVirt VM Using a Precreated PVC

You can create a KubeVirt virtual machine (VM) that references an existing PersistentVolumeClaim (PVC). This workflow lets you provision and verify storage before creating the VM, reuse a PVC across VM definitions, or manage the PVC lifecycle independently of the VM.

When you reference a Fusion-backed PVC in a VM, the Portworx Fusion Controller detects the reference, creates a corresponding FusionWorkload custom resource (CR) to track the VM storage, and provisions the volume on the appropriate FlashArray based on the associated Fusion preset.

note

This workflow supplements the DataVolumeTemplate workflow described in Create a KubeVirt VM Using a Fusion Preset. Existing VMs that use DataVolumeTemplate continue to work without changes.

Prerequisites​

Before you begin, ensure that the following requirements are met:

PVC compatibility requirements​

Before referencing a PVC in a VM, ensure that the PVC meets the following requirements:

RequirementDescription
StorageClassThe PVC must use the same StorageClass as the VM's existing PVCs.
Access modeThe access mode matches the disk usage. Use ReadWriteOnce (RWO) for a single-node disk or ReadWriteMany (RWX) for disks on VMs that use live migration.
Volume modeThe volume mode matches the VM disk requirements. Use Block for raw block disks or Filesystem for file system-backed disks.
StatusThe PVC is in the Pending state before the VM references it.
NamespaceThe PVC and VM are in the same namespace.
important

A KubeVirt VM must use a single RWX volume type for all its disks. Do not mix volume types on the same VM. Mixing volume types can cause node drains to stall during OpenShift Container Platform or Portworx upgrades.

Create a VM using a precreated PVC​

To create a VM that uses an existing PVC as a disk:

  1. Create a PVC that references a Fusion-backed StorageClass:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    name: fusion-vm-disk
    namespace: portworx
    spec:
    storageClassName: fleet-testing-gold-tier
    accessModes:
    - ReadWriteOnce
    resources:
    requests:
    storage: 50Gi

    Replace fleet-testing-gold-tier with the StorageClass generated from your Fusion preset.

  2. Apply the PVC:

    kubectl apply -f fusion-vm-disk.yaml
  3. Create the VM and reference the PVC as a disk by using a persistentVolumeClaim volume source:

    apiVersion: kubevirt.io/v1
    kind: VirtualMachine
    metadata:
    name: fusion-vm
    namespace: portworx
    spec:
    running: true
    template:
    spec:
    domain:
    devices:
    disks:
    - name: os-disk
    disk:
    bus: virtio
    volumes:
    - name: os-disk
    persistentVolumeClaim:
    claimName: fusion-vm-disk
  4. Apply the VM:

    kubectl apply -f fusion-vm.yaml
  5. Verify that the PVC is in the Bound state:

    kubectl get pvc fusion-vm-disk -n portworx

    Verify that the STATUS column shows Bound:

    NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
    fusion-vm-disk Bound pvc-a1b2c3d4 50Gi RWO fleet-testing-gold-tier 30s
  6. Verify that the VM is running:

    kubectl get vm fusion-vm -n portworx

    Verify that the STATUS column shows Running.

Verify the Fusion workload​

When the Fusion Controller detects the PVC reference, it creates a FusionWorkload CR to represent and track the VM storage.

To list the Fusion workloads, run:

kubectl get fusionworkload -n <namespace>

To view provisioning details and events for the workload, run:

kubectl describe fusionworkload <workload-name> -n <namespace>

Replace <namespace> with the namespace where the VM and PVC reside and <workload-name> with the name of the FusionWorkload CR associated with the VM.

If provisioning fails, the VM remains in the Provisioning state. Check the events for the corresponding FusionWorkload CR to determine the cause.

note

The PVC has an independent lifecycle from the VM. Deleting the VM does not delete a precreated PVC. Delete the PVC separately when you no longer need the storage.

In this topic: