|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * virt/virtual_machines/virt-export-vms.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="virt-creating-virtualmachineexport_{context}"] |
| 7 | += Creating a VirtualMachineExport custom resource |
| 8 | + |
| 9 | +You can create a `VirtualMachineExport` custom resource (CR) to export the following objects: |
| 10 | + |
| 11 | +* Virtual machine (VM): Exports the persistent volume claims (PVCs) of a specified VM. |
| 12 | +* VM snapshot: Exports PVCs contained in a `VirtualMachineSnapshot` CR. |
| 13 | +* PVC: Exports a PVC. If the PVC is used by another pod, such as the `virt-launcher` pod, the export remains in a `Pending` state until the PVC is no longer in use. |
| 14 | +
|
| 15 | +The `VirtualMachineExport` CR creates internal and external links for the exported volumes. Internal links are valid within the cluster. External links can be accessed by using an `Ingress` or `Route`. |
| 16 | + |
| 17 | +The export server supports the following file formats: |
| 18 | + |
| 19 | +* `raw`: Raw disk image file. |
| 20 | +* `gzip`: Compressed disk image file. |
| 21 | +* `dir`: PVC directory and files. |
| 22 | +* `tar.gz`: Compressed PVC file. |
| 23 | +
|
| 24 | +.Prerequisites |
| 25 | + |
| 26 | +* The VM must be shut down for a VM export. |
| 27 | +
|
| 28 | +.Procedure |
| 29 | + |
| 30 | +. Create a `VirtualMachineExport` manifest to export a volume from a `VirtualMachine`, `VirtualMachineSnapshot`, or `PersistentVolumeClaim` CR according to the following example and save it as `example-export.yaml`: |
| 31 | ++ |
| 32 | +.`VirtualMachineExport` example |
| 33 | +[source,yaml] |
| 34 | +---- |
| 35 | +apiVersion: export.kubevirt.io/v1alpha1 |
| 36 | +kind: VirtualMachineExport |
| 37 | +metadata: |
| 38 | + name: example-export |
| 39 | +spec: |
| 40 | + source: |
| 41 | + apiGroup: "kubevirt.io" <1> |
| 42 | + kind: VirtualMachine <2> |
| 43 | + name: example-vm |
| 44 | + ttlDuration: 1h <3> |
| 45 | +---- |
| 46 | +<1> Specify the appropriate API group: |
| 47 | ++ |
| 48 | +* `"kubevirt.io"` for `VirtualMachine`. |
| 49 | +* `"snapshot.kubevirt.io"` for `VirtualMachineSnapshot`. |
| 50 | +* `""` for `PersistentVolumeClaim`. |
| 51 | +<2> Specify `VirtualMachine`, `VirtualMachineSnapshot`, or `PersistentVolumeClaim`. |
| 52 | +<3> Optional. The default duration is 2 hours. |
| 53 | + |
| 54 | +. Create the `VirtualMachineExport` CR: |
| 55 | ++ |
| 56 | +[source,terminal] |
| 57 | +---- |
| 58 | +$ oc create -f example-export.yaml |
| 59 | +---- |
| 60 | + |
| 61 | +. Get the `VirtualMachineExport` CR: |
| 62 | ++ |
| 63 | +[source,terminal] |
| 64 | +---- |
| 65 | +$ oc get vmexport example-export -o yaml |
| 66 | +---- |
| 67 | ++ |
| 68 | +The internal and external links for the exported volumes are displayed in the `status` stanza: |
| 69 | ++ |
| 70 | +.Output example |
| 71 | +[source,yaml] |
| 72 | +---- |
| 73 | +apiVersion: export.kubevirt.io/v1alpha1 |
| 74 | +kind: VirtualMachineExport |
| 75 | +metadata: |
| 76 | + name: example-export |
| 77 | + namespace: example |
| 78 | +spec: |
| 79 | + source: |
| 80 | + apiGroup: "" |
| 81 | + kind: PersistentVolumeClaim |
| 82 | + name: example-pvc |
| 83 | + tokenSecretRef: example-token |
| 84 | +status: |
| 85 | + conditions: |
| 86 | + - lastProbeTime: null |
| 87 | + lastTransitionTime: "2022-06-21T14:10:09Z" |
| 88 | + reason: podReady |
| 89 | + status: "True" |
| 90 | + type: Ready |
| 91 | + - lastProbeTime: null |
| 92 | + lastTransitionTime: "2022-06-21T14:09:02Z" |
| 93 | + reason: pvcBound |
| 94 | + status: "True" |
| 95 | + type: PVCReady |
| 96 | + links: |
| 97 | + external: <1> |
| 98 | + cert: |- |
| 99 | + -----BEGIN CERTIFICATE----- |
| 100 | + ... |
| 101 | + -----END CERTIFICATE----- |
| 102 | + volumes: |
| 103 | + - formats: |
| 104 | + - format: raw |
| 105 | + url: https://vmexport-proxy.test.net/api/export.kubevirt.io/v1alpha1/namespaces/example/virtualmachineexports/example-export/volumes/example-disk/disk.img |
| 106 | + - format: gzip |
| 107 | + url: https://vmexport-proxy.test.net/api/export.kubevirt.io/v1alpha1/namespaces/example/virtualmachineexports/example-export/volumes/example-disk/disk.img.gz |
| 108 | + name: example-disk |
| 109 | + internal: <2> |
| 110 | + cert: |- |
| 111 | + -----BEGIN CERTIFICATE----- |
| 112 | + ... |
| 113 | + -----END CERTIFICATE----- |
| 114 | + volumes: |
| 115 | + - formats: |
| 116 | + - format: raw |
| 117 | + url: https://virt-export-example-export.example.svc/volumes/example-disk/disk.img |
| 118 | + - format: gzip |
| 119 | + url: https://virt-export-example-export.example.svc/volumes/example-disk/disk.img.gz |
| 120 | + name: example-disk |
| 121 | + phase: Ready |
| 122 | + serviceName: virt-export-example-export |
| 123 | +---- |
| 124 | +<1> External links are accessible from outside the cluster by using an `Ingress` or `Route`. |
| 125 | +<2> Internal links are only valid inside the cluster. |
0 commit comments