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.
-
A virtual machine disk image, in RAW, ISO, or QCOW2 format, optionally compressed by using
xz
orgz
. -
An
HTTP
ors3
endpoint where the image is hosted, along with any authentication credentials needed to access the data source -
At least one available block PV.
-
If your data source requires authentication credentials, edit the
endpoint-secret.yaml
file, and apply the updated configuration to the cluster.-
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)
-
Optional: your key or user name, base64 encoded
-
Optional: your secret or password, base64 encoded
-
-
Update the secret:
$ oc apply -f endpoint-secret.yaml
-
-
Create a
DataVolume
configuration that specifies the data source for the image you want to import andvolumeMode: 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>
-
The name of the DataVolume.
-
Optional: Set the storage class or omit it to accept the cluster default.
-
The
HTTP
source of the image to import. -
Only required if the data source requires authentication.
-
Required for importing to a block PV.
-
-
Create the DataVolume to import the virtual machine image.
$ oc create -f <import-pv-datavolume.yaml>(1)
-
The filename DataVolume created in the previous step.
-