Migrating virtual machines from the CLI

You can migrate virtual machines from the command line (CLI) by creating the following custom resources (CRs):

Prerequisites
Procedure
  1. 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
    1. Specify the vCenter host name.

    Example output
    01:23:45:67:89:AB:CD:EF:01:23:45:67:89:AB:CD:EF:01:23:45:67
  2. 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
    1. Specify the vCenter administrator account, for example, administrator@vsphere.local.

    2. Specify the vCenter password.

    3. Specify the SHA-1 fingerprint of the vCenter host.

  3. 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
    1. Specify the vSphere API end point, for example, https://<vcenter.host.com>/sdk.

    2. Specify the name of the VMware Secret CR.

  4. 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
    1. Specify the name of the Plan CR.

    2. You can create multiple network mappings for source and destination networks.

    3. You can use either the id or the name parameter to specify the source network.

    4. Managed object reference of the source network.

    5. You can create multiple storage mappings for source data stores and destination storage classes.

    6. You can use either the id or the name parameter to specify the source data store.

    7. Managed object reference of the source data store.

    8. You can use either the id or the name parameter to specify the source VM.

    9. Managed object reference of the source VM.

  5. Create a Migration CR to run the Plan 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
    1. Specify the name of the Migration CR.

    2. Specify the name of the Plan CR that you are running.

    The Migration CR creates a VirtualMachineImport CR for each VM that is migrated.

  6. Monitor the progress of the migration by viewing the VirtualMachineImport pods:

    $ oc get pods -n konveyor-forklift