9.9.2. エクスポートされた仮想マシンマニフェストへのアクセス
仮想マシン (VM) またはスナップショットをエクスポートすると、エクスポートサーバーから VirtualMachine マニフェストと関連情報を取得できます。
前提条件
-
OpenShift CLI (
oc) がインストールされている。 VirtualMachineExportカスタムリソース (CR) を作成して、仮想マシンまたは VM スナップショットをエクスポートしている。注記spec.source.kind: PersistentVolumeClaimパラメーターを持つVirtualMachineExportオブジェクトは、仮想マシンマニフェストを生成しません。
手順
マニフェストにアクセスするには、まず証明書をソースクラスターからターゲットクラスターにコピーする必要があります。
- ソースクラスターにログインします。
次のコマンドを実行して、証明書を
cacert.crtファイルに保存します。$ oc get vmexport <export_name> -o jsonpath={.status.links.external.cert} > cacert.crt<export_name>を、VirtualMachineExportオブジェクトのmetadata.name値に置き換えます。-
cacert.crtファイルをターゲットクラスターにコピーします。
次のコマンドを実行して、ソースクラスター内のトークンをデコードし、
token_decodeファイルに保存します。$ oc get secret export-token-<export_name> -o jsonpath={.data.token} | base64 --decode > token_decode<export_name>を、VirtualMachineExportオブジェクトのmetadata.name値に置き換えます。-
token_decodeファイルをターゲットクラスターにコピーします。 次のコマンドを実行して、
VirtualMachineExportカスタムリソースを取得します。$ oc get vmexport <export_name> -o yamlstatus.linksスタンザを確認します。このスタンザはexternalセクションとinternalセクションに分かれています。各セクション内のmanifests.urlフィールドに注意してください。出力例
apiVersion: export.kubevirt.io/v1beta1 kind: VirtualMachineExport metadata: name: example-export spec: source: apiGroup: "kubevirt.io" kind: VirtualMachine name: example-vm tokenSecretRef: example-token status: #... links: external: #... manifests: - type: all url: https://vmexport-proxy.test.net/api/export.kubevirt.io/v1beta1/namespaces/example/virtualmachineexports/example-export/external/manifests/all - type: auth-header-secret url: https://vmexport-proxy.test.net/api/export.kubevirt.io/v1beta1/namespaces/example/virtualmachineexports/example-export/external/manifests/secret internal: #... manifests: - type: all url: https://virt-export-export-pvc.default.svc/internal/manifests/all - type: auth-header-secret url: https://virt-export-export-pvc.default.svc/internal/manifests/secret phase: Ready serviceName: virt-export-example-export-
status.links.external.manifests.url のタイプがall の場合、VirtualMachineマニフェスト、存在する場合はDataVolumeマニフェスト、および外部 URL の Ingress またはルートの公開証明書を含むConfigMapマニフェストが含まれます。 -
status.links.external.manifests.url のタイプがauth-header-secretの場合、Containerized Data Importer (CDI) と互換性のあるヘッダーを含むシークレットが含まれます。ヘッダーには、エクスポートトークンのテキストバージョンが含まれています。
-
- ターゲットクラスターにログインします。
次のコマンドを実行して
Secretマニフェストを取得します。$ curl --cacert cacert.crt <secret_manifest_url> -H \ "x-kubevirt-export-token:token_decode" -H \ "Accept:application/yaml"-
<secret_manifest_url>を、VirtualMachineExportYAML 出力のauth-header-secretURL に置き換えます。 前に作成した
token_decodeファイルを参照します。以下に例を示します。
$ curl --cacert cacert.crt https://vmexport-proxy.test.net/api/export.kubevirt.io/v1beta1/namespaces/example/virtualmachineexports/example-export/external/manifests/secret -H "x-kubevirt-export-token:token_decode" -H "Accept:application/yaml"
-
次のコマンドを実行して、
ConfigMapマニフェストやVirtualMachineマニフェストなどのtype: allマニフェストを取得します。$ curl --cacert cacert.crt <all_manifest_url> -H \ "x-kubevirt-export-token:token_decode" -H \ "Accept:application/yaml"-
<all_manifest_url>を、VirtualMachineExportYAML 出力の URL に置き換えます。 前に作成した
token_decodeファイルを参照します。以下に例を示します。
$ curl --cacert cacert.crt https://vmexport-proxy.test.net/api/export.kubevirt.io/v1beta1/namespaces/example/virtualmachineexports/example-export/external/manifests/all -H "x-kubevirt-export-token:token_decode" -H "Accept:application/yaml"
-
次のステップ
-
エクスポートしたマニフェストを使用して、ターゲットクラスター上に
ConfigMapオブジェクトとVirtualMachineオブジェクトを作成できます。