Skip to content

Commit 76d921e

Browse files
authored
Merge pull request #53976 from apinnick/CNV16073-export-vm
CNV-16073: Export VM disk
2 parents 56ac56c + a4365c5 commit 76d921e

File tree

4 files changed

+159
-27
lines changed

4 files changed

+159
-27
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3358,6 +3358,8 @@ Topics:
33583358
File: virt-edit-boot-order
33593359
- Name: Deleting virtual machines
33603360
File: virt-delete-vms
3361+
- Name: Exporting virtual machines
3362+
File: virt-exporting-vms
33613363
- Name: Managing virtual machine instances
33623364
File: virt-manage-vmis
33633365
- Name: Controlling virtual machine states
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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.

modules/virt-virtctl-commands.adoc

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,35 @@
88

99
The `virtctl` client is a command-line utility for managing {VirtProductName} resources.
1010

11-
To view a list of `virtctl` commands, run the following command:
12-
13-
[source,terminal]
14-
----
15-
$ virtctl help
16-
----
11+
.`virtctl` general commands
12+
[width="100%",cols="1a,2a",options="header"]
13+
|===
14+
|Command |Description
15+
|`virtctl version`
16+
|View the `virtctl` client and server versions.
1717

18-
To view a list of options that you can use with a specific command, run it with the `-h` or `--help` flag. For example:
18+
|`virtctl help`
19+
|View a list of `virtctl` commands.
1920

20-
[source,terminal]
21-
----
22-
$ virtctl image-upload -h
23-
----
21+
|`virtctl <command> -h\|--help`
22+
|View a list of options for a specific command.
2423

25-
To view a list of global command options that you can use with any `virtctl` command, run the following command:
26-
27-
[source,terminal]
28-
----
29-
$ virtctl options
30-
----
24+
|`virtctl options`
25+
|View a list of global command options for any `virtctl` command.
26+
|===
3127

32-
// apinnick: I recommend not breaking these commands into separate modules because of maintenance issues.
33-
// These sections would never be used independently.
28+
// apinnick: I recommend not breaking these sections into separate modules because of maintenance issues.
29+
// These sections will never be used independently.
3430

3531
[id='vm-management-commands_{context}']
36-
== Virtual machine management commands
32+
== VM and VMI management commands
3733

3834
You can use `virtctl` to manage virtual machine (VM) or virtual machine instance (VMI) states and to migrate a VM.
3935

40-
.VM management commands
36+
.`virtctl` VM management commands
4137
[width="100%",cols="1a,2a",options="header"]
4238
|===
4339
|Command |Description
44-
4540
|`virtctl start <vm_name>`
4641
|Start a VM.
4742

@@ -77,7 +72,6 @@ You can use `virtctl` to connect to the serial console, expose a port, set a pro
7772
[width="100%",cols="1a,2a",options="header"]
7873
|===
7974
|Command |Description
80-
8175
|`virtctl console <vmi_name>`
8276
|Connect to the serial console of a VMI.
8377

@@ -107,7 +101,6 @@ You can use `virtctl vmexport` commands to create, download, or delete a volume
107101
[width="100%",cols="1a,2a",options="header"]
108102
|===
109103
|Command |Description
110-
111104
|`virtctl vmexport create <vmexport_name> --vm\|snapshot\|pvc=<object_name>`
112105
|Create a `VirtualMachineExport` custom resource (CR) to export a volume from a VM, VM snapshot, or PVC.
113106

@@ -217,9 +210,6 @@ You can use `virtctl` to view information about versions, file systems, guest op
217210
[width="100%",cols="1a,2a",options="header"]
218211
|===
219212
|Command |Description
220-
|`virtctl version`
221-
|View the `virtctl` client and server versions.
222-
223213
|`virtctl fslist <vmi_name>`
224214
|View the file systems available on a guest machine.
225215

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
:_content-type: ASSEMBLY
2+
[id="virt-exporting-vms"]
3+
= Exporting virtual machines
4+
include::_attributes/common-attributes.adoc[]
5+
:context: virt-exporting-vms
6+
7+
toc::[]
8+
9+
You can export a virtual machine (VM) and its associated disks in order to import a VM into another cluster or to analyze the volume for forensic purposes.
10+
11+
You create a `VirtualMachineExport` custom resource (CR) by using the command line interface.
12+
13+
Alternatively, you can use the xref:../../virt/virt-using-the-cli-tools.adoc#vm-volume-export-commands_virt-using-the-cli-tools[`virtctl vmexport` command] to create a `VirtualMachineExport` CR and to download exported volumes.
14+
15+
include::modules/virt-creating-virtualmachineexport.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)