Migrating virtual machines from the CLI
You can migrate virtual machines from the command line (CLI) by creating the following custom resources (CRs):
-
Secret
CR: Contains the VMware provider credentials. -
Provider
CR: Describes the VMware provider. -
Plan
CR: Describes the source and target clusters, network mappings, data store mappings, and VMs to migrate. -
Migration
CR: Runs thePlan
CR.If a migration does not complete, you can create a new
Migration
CR, without changing thePlan
CR, to migrate the remaining VMs. You can associate multipleMigration
CRs with a singlePlan
CR.
-
KubeVirt Operator installed.
-
Forklift Operator installed.
-
OpenShift CLI installed.
-
VDDK image added to the
v2v-vmware
config map. -
You must be logged in as a user with
cluster-admin
privileges. -
You must have a VMware vCenter user account with administrator privileges.
-
Obtain the SHA-1 fingerprint of the vCenter host:
$ openssl s_client \ -connect <vcenter_host>:443 \ (1) < /dev/null 2>/dev/null \ | openssl x509 -fingerprint -noout -in /dev/stdin \ | cut -d '=' -f 2
-
Specify the vCenter host name.
Example output01:23:45:67:89:AB:CD:EF:01:23:45:67:89:AB:CD:EF:01:23:45:67
-
-
Create a
Secret
CR for the VMware provider:$ cat << EOF | oc apply -f - apiVersion: v1 kind: Secret metadata: name: vmware-secret namespace: konveyor-forklift type: Opaque stringData: user: <user_name> (1) password: <password> (2) thumbprint: <fingerprint> (3) EOF
-
Specify the vCenter administrator account, for example,
administrator@vsphere.local
. -
Specify the vCenter password.
-
Specify the SHA-1 fingerprint of the vCenter host.
-
-
Create a
Provider
CR for the VMware provider:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Provider metadata: name: vmware-provider namespace: konveyor-forklift spec: type: vsphere url: <api_end_point> (1) secret: name: <vmware_secret> (2) namespace: konveyor-forklift EOF
-
Specify the vSphere API end point, for example,
https://<vcenter.host.com>/sdk
. -
Specify the name of the VMware
Secret
CR.
-
-
Create a
Plan
CR for the migration:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Plan metadata: name: <plan_name> (1) namespace: konveyor-forklift spec: provider: source: name: vmware-provider namespace: konveyor-forklift destination: name: destination-cluster namespace: konveyor-forklift map: networks: (2) - source: (3) id: <source_network_mor> (4) name: <source_network_name> destination: type: pod name: pod namespace: konveyor-forklift datastores: (5) - source: (6) id: <source_datastore_mor> (7) name: <source_datastore_name> destination: storageClass: standard vms: (8) - id: <source_vm_mor> (9) - name: <source_vm_name> EOF
-
Specify the name of the
Plan
CR. -
You can create multiple network mappings for source and destination networks.
-
You can use either the
id
or thename
parameter to specify the source network. -
Managed object reference of the source network.
-
You can create multiple storage mappings for source data stores and destination storage classes.
-
You can use either the
id
or thename
parameter to specify the source data store. -
Managed object reference of the source data store.
-
You can use either the
id
or thename
parameter to specify the source VM. -
Managed object reference of the source VM.
-
-
Create a
Migration
CR to run thePlan
CR:$ cat << EOF | oc apply -f - apiVersion: forklift.konveyor.io/v1beta1 kind: Migration metadata: name: <migration_name> (1) namespace: konveyor-forklift spec: plan: name: <plan_name> (2) namespace: konveyor-forklift EOF
-
Specify the name of the
Migration
CR. -
Specify the name of the
Plan
CR that you are running.
The
Migration
CR creates aVirtualMachineImport
CR for each VM that is migrated. -
-
Monitor the progress of the migration by viewing the
VirtualMachineImport
pods:$ oc get pods -n konveyor-forklift