Skip to content

Latest commit

 

History

History
86 lines (74 loc) · 2.52 KB

cnv-importing-vm-to-block-pv.adoc

File metadata and controls

86 lines (74 loc) · 2.52 KB

Importing a virtual machine image to a block PersistentVolume using DataVolumes

You can import an existing virtual machine image into your {product-title} cluster. {CNVProductNameStart} uses DataVolumes to automate the importing data and the creation of an underlying PersistentVolumeClaim (PVC). You can then reference the DataVolume in a virtual machine configuration.

Prerequisites
  • A virtual machine disk image, in RAW, ISO, or QCOW2 format, optionally compressed by using xz or gz.

  • An HTTP or s3 endpoint where the image is hosted, along with any authentication credentials needed to access the data source

  • At least one available block PV.

Procedure
  1. If your data source requires authentication credentials, edit the endpoint-secret.yaml file, and apply the updated configuration to the cluster.

    1. Edit the endpoint-secret.yaml file with your preferred text editor:

      apiVersion: v1
      kind: Secret
      metadata:
        name: <endpoint-secret>
        labels:
          app: containerized-data-importer
      type: Opaque
      data:
        accessKeyId: "" (1)
        secretKey:   "" (2)
      1. Optional: your key or user name, base64 encoded

      2. Optional: your secret or password, base64 encoded

    2. Update the secret:

      $ oc apply -f endpoint-secret.yaml
  2. Create a DataVolume configuration that specifies the data source for the image you want to import and volumeMode: Block so that an available block PV is used.

    apiVersion: cdi.kubevirt.io/v1alpha1
    kind: DataVolume
    metadata:
      name: <import-pv-datavolume> (1)
    spec:
      storageClassName: local (2)
      source:
          http:
             url: <http://download.fedoraproject.org/pub/fedora/linux/releases/28/Cloud/x86_64/images/Fedora-Cloud-Base-28-1.1.x86_64.qcow2> (3)
             secretRef: <endpoint-secret> (4)
      pvc:
        volumeMode: Block (5)
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: <2Gi>
    1. The name of the DataVolume.

    2. Optional: Set the storage class or omit it to accept the cluster default.

    3. The HTTP source of the image to import.

    4. Only required if the data source requires authentication.

    5. Required for importing to a block PV.

  3. Create the DataVolume to import the virtual machine image.

    $ oc create -f <import-pv-datavolume.yaml>(1)
    1. The filename DataVolume created in the previous step.