|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * virt/virtual_machines/virt-exporting-vms.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="virt-accessing-exported-vm-manifests_{context}"] |
| 7 | += Accessing exported virtual machine manifests |
| 8 | + |
| 9 | +After you export a virtual machine (VM) or snapshot, you can get the `VirtualMachine` manifest and related information from the export server. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +* You exported a virtual machine or VM snapshot by creating a `VirtualMachineExport` custom resource (CR). |
| 14 | ++ |
| 15 | +[NOTE] |
| 16 | +==== |
| 17 | +`VirtualMachineExport` objects that have the `spec.source.kind: PersistentVolumeClaim` parameter do not generate virtual machine manifests. |
| 18 | +==== |
| 19 | +
|
| 20 | +.Procedure |
| 21 | + |
| 22 | +. To access the manifests, you must first copy the certificates from the source cluster to the target cluster. |
| 23 | + |
| 24 | +.. Log in to the source cluster. |
| 25 | + |
| 26 | +.. Save the certificates to the `cacert.crt` file by running the following command: |
| 27 | ++ |
| 28 | +[source,terminal] |
| 29 | +---- |
| 30 | +$ oc get vmexport <export_name> -o jsonpath={.status.links.external.cert} > cacert.crt <1> |
| 31 | +---- |
| 32 | +<1> Replace `<export_name>` with the `metadata.name` value from the `VirtualMachineExport` object. |
| 33 | + |
| 34 | +.. Copy the `cacert.crt` file to the target cluster. |
| 35 | + |
| 36 | +. Decode the token in the source cluster and save it to the `token_decode` file by running the following command: |
| 37 | ++ |
| 38 | +[source,terminal] |
| 39 | +---- |
| 40 | +$ oc get secret export-token-<export_name> -o jsonpath={.data.token} | base64 --decode > token_decode <1> |
| 41 | +---- |
| 42 | +<1> Replace `<export_name>` with the `metadata.name` value from the `VirtualMachineExport` object. |
| 43 | + |
| 44 | +. Copy the `token_decode` file to the target cluster. |
| 45 | + |
| 46 | +. Get the `VirtualMachineExport` custom resource by running the following command: |
| 47 | ++ |
| 48 | +[source,terminal] |
| 49 | +---- |
| 50 | +$ oc get vmexport <export_name> -o yaml |
| 51 | +---- |
| 52 | + |
| 53 | +. Review the `status.links` stanza, which is divided into `external` and `internal` sections. Note the `manifests.url` fields within each section: |
| 54 | ++ |
| 55 | +.Example output |
| 56 | + |
| 57 | +[source,yaml] |
| 58 | +---- |
| 59 | +apiVersion: export.kubevirt.io/v1alpha1 |
| 60 | +kind: VirtualMachineExport |
| 61 | +metadata: |
| 62 | + name: example-export |
| 63 | +spec: |
| 64 | + source: |
| 65 | + apiGroup: "kubevirt.io" |
| 66 | + kind: VirtualMachine |
| 67 | + name: example-vm |
| 68 | + tokenSecretRef: example-token |
| 69 | +status: |
| 70 | +#... |
| 71 | + links: |
| 72 | + external: |
| 73 | +#... |
| 74 | + manifests: |
| 75 | + - type: all |
| 76 | + url: https://vmexport-proxy.test.net/api/export.kubevirt.io/v1alpha1/namespaces/example/virtualmachineexports/example-export/external/manifests/all <1> |
| 77 | + - type: auth-header-secret |
| 78 | + url: https://vmexport-proxy.test.net/api/export.kubevirt.io/v1alpha1/namespaces/example/virtualmachineexports/example-export/external/manifests/secret <2> |
| 79 | + internal: |
| 80 | +#... |
| 81 | + manifests: |
| 82 | + - type: all |
| 83 | + url: https://virt-export-export-pvc.default.svc/internal/manifests/all <3> |
| 84 | + - type: auth-header-secret |
| 85 | + url: https://virt-export-export-pvc.default.svc/internal/manifests/secret |
| 86 | + phase: Ready |
| 87 | + serviceName: virt-export-example-export |
| 88 | +---- |
| 89 | +<1> Contains the `VirtualMachine` manifest, `DataVolume` manifest, if present, and a `ConfigMap` manifest that contains the public certificate for the external URL's ingress or route. |
| 90 | +<2> Contains a secret containing a header that is compatible with Containerized Data Importer (CDI). The header contains a text version of the export token. |
| 91 | +<3> Contains the `VirtualMachine` manifest, `DataVolume` manifest, if present, and a `ConfigMap` manifest that contains the certificate for the internal URL's export server. |
| 92 | + |
| 93 | +. Log in to the target cluster. |
| 94 | + |
| 95 | +. Get the `Secret` manifest by running the following command: |
| 96 | ++ |
| 97 | +[source,terminal] |
| 98 | +---- |
| 99 | +$ curl --cacert cacert.crt <secret_manifest_url> -H \ <1> |
| 100 | +"x-kubevirt-export-token:token_decode" -H \ <2> |
| 101 | +"Accept:application/yaml" |
| 102 | +---- |
| 103 | +<1> Replace `<secret_manifest_url>` with an `auth-header-secret` URL from the `VirtualMachineExport` YAML output. |
| 104 | +<2> Reference the `token_decode` file that you created earlier. |
| 105 | ++ |
| 106 | +For example: |
| 107 | ++ |
| 108 | +[source,terminal] |
| 109 | +---- |
| 110 | +$ curl --cacert cacert.crt https://vmexport-proxy.test.net/api/export.kubevirt.io/v1alpha1/namespaces/example/virtualmachineexports/example-export/external/manifests/secret -H "x-kubevirt-export-token:token_decode" -H "Accept:application/yaml" |
| 111 | +---- |
| 112 | + |
| 113 | +. Get the manifests of `type: all`, such as the `ConfigMap` and `VirtualMachine` manifests, by running the following command: |
| 114 | ++ |
| 115 | +[source,terminal] |
| 116 | +---- |
| 117 | +$ curl --cacert cacert.crt <all_manifest_url> -H \ <1> |
| 118 | +"x-kubevirt-export-token:token_decode" -H \ <2> |
| 119 | +"Accept:application/yaml" |
| 120 | +---- |
| 121 | +<1> Replace `<all_manifest_url>` with a URL from the `VirtualMachineExport` YAML output. |
| 122 | +<2> Reference the `token_decode` file that you created earlier. |
| 123 | ++ |
| 124 | +For example: |
| 125 | ++ |
| 126 | +[source,terminal] |
| 127 | +---- |
| 128 | +$ curl --cacert cacert.crt https://vmexport-proxy.test.net/api/export.kubevirt.io/v1alpha1/namespaces/example/virtualmachineexports/example-export/external/manifests/all -H "x-kubevirt-export-token:token_decode" -H "Accept:application/yaml" |
| 129 | +---- |
| 130 | + |
| 131 | +.Next steps |
| 132 | + |
| 133 | +* You can now create the `ConfigMap` and `VirtualMachine` objects on the target cluster by using the exported manifests. |
0 commit comments