You can deploy the Migration Toolkit for Containers (MTC) on an OpenShift Container Platform 4.6 target cluster and an OpenShift Container Platform 3 source cluster by installing the MTC Operator. The MTC Operator deploys MTC on the target cluster by default.

Optional: You can configure the MTC Operator to install the MTC on an OpenShift Container Platform 3 cluster or on a remote cluster.

In a restricted environment, you can install the MTC Operator from a local mirror registry.

After you have installed the MTC Operator on your clusters, you can launch the MTC web console.

Installing the MTC Operator

You can install the MTC Operator with the Operator Lifecycle Manager (OLM) on an OpenShift Container Platform 4.6 target cluster and manually on an OpenShift Container Platform 3 source cluster.

Installing the MTC Operator on an OpenShift Container Platform 4.6 target cluster

You can install the MTC Operator on an OpenShift Container Platform 4.6 target cluster with the Operator Lifecycle Manager (OLM).

The MTC Operator installs the Migration Toolkit for Containers on the target cluster by default.

Procedure
  1. In the OpenShift Container Platform web console, click OperatorsOperatorHub.

  2. Use the Filter by keyword field (in this case, Migration) to find the MTC Operator.

  3. Select the MTC Operator and click Install.

  4. On the Install Operator page, click Install.

    On the Installed Operators page, the MTC Operator appears in the openshift-migration project with the status Succeeded.

  5. Click MTC Operator.

  6. Under Provided APIs, locate the Migration Controller tile, and click Create Instance.

  7. Click Create.

  8. Click WorkloadsPods to verify that the Controller Manager, Migration UI, Restic, and Velero pods are running.

Installing the MTC Operator on an OpenShift Container Platform 3 source cluster

You can install the MTC Operator manually on an OpenShift Container Platform 3 source cluster.

You must install the same MTC version on the OpenShift Container Platform 3 and 4 clusters. The MTC Operator on the OpenShift Container Platform 4 cluster is updated automatically by the Operator Lifecycle Manager.

To ensure that you have the latest version on the OpenShift Container Platform 3 cluster, download the operator.yml and controller-3.yml files when you are ready to create and run the migration plan.

Prerequisites
  • Access to registry.redhat.io

  • OpenShift Container Platform 3 cluster configured to pull images from registry.redhat.io

    To pull images, you must create an imagestreamsecret and copy it to each node in your cluster.

Procedure
  1. Log in to registry.redhat.io with your Red Hat Customer Portal credentials:

    $ sudo podman login registry.redhat.io
  2. Download the operator.yml file:

    $ sudo podman cp $(sudo podman create registry.redhat.io/rhmtc/openshift-migration-rhel7-operator:v1.3.0):/operator.yml ./
  3. Download the controller-3.yml file:

    $ sudo podman cp $(sudo podman create registry.redhat.io/rhmtc/openshift-migration-rhel7-operator:v1.3.0):/controller-3.yml ./
  4. Log in to your OpenShift Container Platform 3 cluster.

  5. Verify that the cluster can authenticate with registry.redhat.io:

    $ oc run test --image registry.redhat.io/ubi8 --command sleep infinity
  6. Create the MTC Operator CR object:

    $ oc create -f operator.yml
    Example output
    namespace/openshift-migration created
    rolebinding.rbac.authorization.k8s.io/system:deployers created
    serviceaccount/migration-operator created
    customresourcedefinition.apiextensions.k8s.io/migrationcontrollers.migration.openshift.io created
    role.rbac.authorization.k8s.io/migration-operator created
    rolebinding.rbac.authorization.k8s.io/migration-operator created
    clusterrolebinding.rbac.authorization.k8s.io/migration-operator created
    deployment.apps/migration-operator created
    Error from server (AlreadyExists): error when creating "./operator.yml":
    rolebindings.rbac.authorization.k8s.io "system:image-builders" already exists (1)
    Error from server (AlreadyExists): error when creating "./operator.yml":
    rolebindings.rbac.authorization.k8s.io "system:image-pullers" already exists
    1 You can ignore Error from server (AlreadyExists) messages. They are caused by the MTC Operator creating resources for earlier versions of OpenShift Container Platform 3 that are provided in later releases.
  7. Create the Migration Controller CR object:

    $ oc create -f controller-3.yml
  8. Verify that the Velero and Restic pods are running:

    $ oc get pods -n openshift-migration

Installing the MTC Operator in a restricted environment

You can install the MTC Operator with the Operator Lifecycle Manager (OLM) on an OpenShift Container Platform 4.6 target cluster and manually on an OpenShift Container Platform 3 source cluster.

For OpenShift Container Platform 4.6, you can build a custom Operator catalog image, push it to a local mirror image registry, and configure OLM to install the MTC Operator from the local registry. A mapping.txt file is created when you run the oc adm catalog mirror command.

On the OpenShift Container Platform 3 cluster, you can create a manifest file based on the Operator image and edit the file to point to your local image registry. The image value in the manifest file uses the sha256 value from the mapping.txt file. Then, you can use the local image to create the MTC Operator.

Prerequisites

  • If you want to prune the default catalog and selectively mirror only a subset of Operators, install the opm CLI.

Disabling the default OperatorHub sources

Operator catalogs that source content provided by Red Hat and community projects are configured for OperatorHub by default during an OpenShift Container Platform installation. Before configuring OperatorHub to instead use local catalog sources in a restricted network environment, you must disable the default catalogs.

Procedure
  • Disable the sources for the default catalogs by adding disableAllDefaultSources: true to the OperatorHub spec:

    $ oc patch OperatorHub cluster --type json \
        -p '[{"op": "add", "path": "/spec/disableAllDefaultSources", "value": true}]'

Pruning an index image

An index image, based on the Operator Bundle Format, is a containerized snapshot of an Operator catalog. You can prune an index of all but a specified list of packages, creating a copy of the source index containing only the Operators that you want.

When configuring Operator Lifecycle Manager (OLM) to use mirrored content on restricted network OpenShift Container Platform clusters, use this pruning method if you want to only mirror a subset of Operators from the default catalogs.

For the steps in this procedure, the target registry is an existing mirror registry that is accessible by both your cluster and a workstation with unrestricted network access. This example also shows pruning the index image for the default redhat-operators catalog, but the process is the same for all index images.

Prerequisites
  • Workstation with unrestricted network access

  • podman version 1.4.4+

  • grpcurl

  • opm version 1.12.3+

  • Access to a registry that supports Docker v2-2

Procedure
  1. Authenticate with registry.redhat.io:

    $ podman login registry.redhat.io
  2. Authenticate with your target registry:

    $ podman login <target_registry>
  3. Determine the list of packages you want to include in your pruned index.

    1. Run the source index image that you want to prune in a container. For example:

      $ podman run -p50051:50051 \
          -it registry.redhat.io/redhat/redhat-operator-index:v4.6
      Example output
      Trying to pull registry.redhat.io/redhat/redhat-operator-index:v4.6...
      Getting image source signatures
      Copying blob ae8a0c23f5b1 done
      ...
      INFO[0000] serving registry                              database=/database/index.db port=50051
    2. In a separate terminal session, use the grpcurl command to get a list of the packages provided by the index:

      $ grpcurl -plaintext localhost:50051 api.Registry/ListPackages > packages.out
    3. Inspect the packages.out file and identify which package names from this list you want to keep in your pruned index. For example:

      Example snippets of packages list
      ...
      {
        "name": "advanced-cluster-management"
      }
      ...
      {
        "name": "jaeger-product"
      }
      ...
      {
      {
        "name": "quay-operator"
      }
      ...
    4. In the terminal session where you executed the podman run command, press Ctrl and C to stop the container process.

  4. Run the following command to prune the source index of all but the specified packages:

    $ opm index prune \
        -f registry.redhat.io/redhat/redhat-operator-index:v4.6 \(1)
        -p advanced-cluster-management,jaeger-product,quay-operator \(2)
        -t <target_registry>:<port>/<namespace>/redhat-operator-index:v4.6 (3)
    1 Index to prune.
    2 Comma-separated list of packages to keep.
    3 Custom tag for new index image being built.
  5. Run the following command to push the new index image to your target registry:

    $ podman push <target_registry>:<port>/<namespace>/redhat-operator-index:v4.6

    where <namespace> is any existing namespace on the registry. For example, you might create an olm-mirror namespace to push all mirrored content to.

Mirroring an Operator catalog

You can mirror the Operator content of a Red Hat-provided catalog, or a custom catalog, into a container image registry using the oc adm catalog mirror command. The target registry must support Docker v2-2. For a cluster on a restricted network, this registry can be a registry that the cluster has network access to, such as a mirror registry created during a restricted network cluster installation.

You must also mirror the Red Hat-provided index image, or push your own custom-built index image, to the target registry by using the oc image mirror command. You can then use the mirrored index image to create a CatalogSource that allows Operator Lifecycle Manager (OLM) to load the mirrored catalog onto your OpenShift Container Platform cluster.

For the steps in this procedure, the target registry is an existing mirror registry that is accessible by both your cluster and a workstation with unrestricted network access. This example also shows mirroring the default redhat-operators catalog, but the process is the same for all catalogs.

Prerequisites
  • Workstation with unrestricted network access

  • podman version 1.4.4+

  • Access to mirror registry that supports Docker v2-2

  • If you are working with private registries, set the REG_CREDS environment variable to the file path of your registry credentials for use in later steps. For example, for the podman CLI:

    $ REG_CREDS=${XDG_RUNTIME_DIR}/containers/auth.json
Procedure
  1. On your workstation with unrestricted network access, use the podman login command to authenticate with the your target mirror registry:

    $ podman login <mirror_registry>
  2. Authenticate with registry.redhat.io:

    $ podman login registry.redhat.io
  3. The oc adm catalog mirror command extracts the contents of an index image to generate the manifests required for mirroring. You can choose either of the following:

    • Allow the default behavior of the command to automatically mirror all of the image content from the index image to your mirror registry after generating manifests.

    • Add the --manifests-only flag to only generate the manifests required for mirroring, but do not actually mirror the image content to the registry yet. This can be useful for reviewing what will be mirrored, and it allows you to make any changes to the mapping list if you only require a subset of packages. You can then use that file with the oc image mirror command to mirror the modified list of images in a later step.

      The --manifests-only flag is intended for advanced selective mirroring of content from the catalog. The opm index prune command, if you used it previously to prune the index image, is suitable for most use cases.

    On your workstation with unrestricted network access, run the following command:

    $ oc adm catalog mirror \
        <index_image> \(1)
        <mirror_registry>:<port> \(2)
        [-a ${REG_CREDS}] \(3)
        [--insecure] \(4)
        [--filter-by-os="<os>/<arch>"] \(5)
        [--manifests-only] (6)
    1 Specify the index image for the catalog you want to mirror. For example, this might be a pruned index image that you created previously, or one of the source index images for the default catalogs, such as registry.redhat.io/redhat/redhat-operator-index:v4.6.
    2 Specify the target registry to mirror the Operator content to.
    3 Optional: If required, specify the location of your registry credentials file.
    4 Optional: If you do not want to configure trust for the target registry, add the --insecure flag.
    5 Optional: Because the catalog might reference images that support multiple architectures and operating systems, you can filter by architecture and operating system to mirror only the images that match. Valid values are linux/amd64, linux/ppc64le, and linux/s390x.
    6 Optional: Only generate the manifests required for mirroring and do not actually mirror the image content to a registry.
    Example output
    src image has index label for database path: /database/index.db
    using database path mapping: /database/index.db:/tmp/153048078
    wrote database to /tmp/153048078 (1)
    ...
    wrote mirroring manifests to redhat-operator-index-manifests
    1 Directory for the temporary index.db database generated by the command.

    After running the command, a <image_name>-manifests/ directory is created in the current directory and generates the following files:

    • The imageContentSourcePolicy.yaml file defines an ImageContentSourcePolicy object that can configure nodes to translate between the image references stored in Operator manifests and the mirrored registry.

    • The mapping.txt file contains all of the source images and where to map them in the target registry. This file is compatible with the oc image mirror command and can be used to further customize the mirroring configuration.

  4. If you used the --manifests-only flag in the previous step and want to further trim the subset of packages to be mirrored:

    1. Modify the list of images in your mapping.txt file to your specifications. If you are unsure of the exact names and versions of the subset of images you want to mirror, use the following steps to find them:

      1. Run the sqlite3 tool against the temporary database that was generated by the oc adm catalog mirror command to retrieve a list of images matching a general search query. The output helps inform how you will later edit your mapping.txt file.

        For example, to retrieve a list of images that are similar to the string jaeger:

        $ echo "select * from related_image \
            where operatorbundle_name like '%jaeger%';" \
            | sqlite3 -line /tmp/153048078/index.db (1)
        1 Refer to the previous output of the oc adm catalog mirror command to find the path of the database file.
        Example output
        ...
        image = registry.redhat.io/distributed-tracing/jaeger-all-in-one-rhel7@sha256:41f769c2c32f3f050aa42d86f084b739914ff9ba2f0aed2d9b0b69357b48459d
        operatorbundle_name = jaeger-operator.v1.17.6
        
        image = registry.redhat.io/distributed-tracing/jaeger-es-index-cleaner-rhel7@sha256:c64ac461d96523516a199bd132ad4d7148317e503a735028f0d8f7ba063a61cb
        operatorbundle_name = jaeger-operator.v1.17.6
        
        image = registry.redhat.io/distributed-tracing/jaeger-rhel7-operator:1.13.2
        operatorbundle_name = jaeger-operator.v1.13.2-1
      2. Use the results from the previous step to help you edit the mapping.txt file to only include the subset of images you want to mirror.

        For example, you can use the image values from the previous example output to find that the following matching lines exist in your mapping.txt file:

        Matching image mappings in mapping.txt
        ...
        registry.redhat.io/distributed-tracing/jaeger-all-in-one-rhel7@sha256:41f769c2c32f3f050aa42d86f084b739914ff9ba2f0aed2d9b0b69357b48459d=quay.io/adellape/distributed-tracing-jaeger-all-in-one-rhel7:5cf7a033
        ...
        registry.redhat.io/distributed-tracing/jaeger-es-index-cleaner-rhel7@sha256:c64ac461d96523516a199bd132ad4d7148317e503a735028f0d8f7ba063a61cb=quay.io/adellape/distributed-tracing-jaeger-es-index-cleaner-rhel7:ecfd2ca7
        ...
        registry.redhat.io/distributed-tracing/jaeger-rhel7-operator:1.13.2=quay.io/adellape/distributed-tracing-jaeger-rhel7-operator:1.13.2
        ...

        In this example, if you only want to mirror these images, you would then remove all other entries in the mapping.txt file and leave only the above matching image mapping lines.

    2. Still on your workstation with unrestricted network access, use your modified mapping.txt file to mirror the images to your registry using the oc image mirror command:

      $ oc image mirror \
          [-a ${REG_CREDS}] \
          -f ./redhat-operator-index-manifests/mapping.txt
  5. Apply the ImageContentSourcePolicy:

    $ oc apply -f ./redhat-operator-index-manifests/imageContentSourcePolicy.yaml
  6. If you are not using a custom, pruned version of an index image, push the Red Hat-provided index image to your registry:

    $ oc image mirror \
        [-a ${REG_CREDS}] \
        registry.redhat.io/redhat/redhat-operator-index:v4.6 \(1)
        <mirror_registry>:<port>/<namespace>/redhat-operator-index:v4.6 (2)
    1 Specify the index image for catalog that you mirrored content for in the previous step.
    2 Specify where to mirror the index image.

You can now create a CatalogSource to reference your mirrored index image and Operator content.

Creating a catalog from an index image

You can create an Operator catalog from an index image and apply it to an OpenShift Container Platform cluster for use with Operator Lifecycle Manager (OLM).

Prerequisites
  • An index image built and pushed to a registry.

Procedure
  1. Create a CatalogSource object that references your index image.

    1. Modify the following to your specifications and save it as a catalogsource.yaml file:

      apiVersion: operators.coreos.com/v1alpha1
      kind: CatalogSource
      metadata:
        name: my-operator-catalog
        namespace: openshift-marketplace
      spec:
        sourceType: grpc
        image: <mirror_registry>:<port>/<namespace>/redhat-operator-index:v4.6 (1)
        displayName: My Operator Catalog
        publisher: <publisher_name> (2)
        updateStrategy:
          registryPoll: (3)
            interval: 30m
      1 Specify your index image.
      2 Specify your name or an organization name publishing the catalog.
      3 CatalogSources can automatically check for new versions to keep up to date.
    2. Use the file to create the CatalogSource object:

      $ oc create -f catalogsource.yaml
  2. Verify the following resources are created successfully.

    1. Check the pods:

      $ oc get pods -n openshift-marketplace
      Example output
      NAME                                    READY   STATUS    RESTARTS  AGE
      my-operator-catalog-6njx6               1/1     Running   0         28s
      marketplace-operator-d9f549946-96sgr    1/1     Running   0         26h
    2. Check the CatalogSource:

      $ oc get catalogsource -n openshift-marketplace
      Example output
      NAME                  DISPLAY               TYPE PUBLISHER  AGE
      my-operator-catalog   My Operator Catalog   grpc            5s
    3. Check the PackageManifest:

      $ oc get packagemanifest -n openshift-marketplace
      Example output
      NAME                          CATALOG               AGE
      jaeger-product                My Operator Catalog   93s

You can now install the Operators from the OperatorHub page on your OpenShift Container Platform web console.

Installing the MTC Operator on an OpenShift Container Platform 4.6 target cluster in a restricted environment

You can install the MTC Operator on an OpenShift Container Platform 4.6 target cluster with the Operator Lifecycle Manager (OLM).

The MTC Operator installs the Migration Toolkit for Containers on the target cluster by default.

Prerequisites
  • You have created a custom Operator catalog and pushed it to a mirror registry.

  • You have configured OLM to install the MTC Operator from the mirror registry.

Procedure
  1. In the OpenShift Container Platform web console, click OperatorsOperatorHub.

  2. Use the Filter by keyword field (in this case, Migration) to find the MTC Operator.

  3. Select the MTC Operator and click Install.

  4. On the Install Operator page, click Install.

    On the Installed Operators page, the MTC Operator appears in the openshift-migration project with the status Succeeded.

  5. Click MTC Operator.

  6. Under Provided APIs, locate the Migration Controller tile, and click Create Instance.

  7. Click Create.

  8. Click WorkloadsPods to verify that the Controller Manager, Migration UI, Restic, and Velero pods are running.

Installing the MTC Operator on an OpenShift Container Platform 3 source cluster in a restricted environment

You can create a manifest file based on the MTC Operator image and edit the manifest to point to your local image registry. Then, you can use the local image to create the MTC Operator on an OpenShift Container Platform 3 source cluster.

You must install the same MTC version on the OpenShift Container Platform 3 and 4 clusters. The MTC Operator on the OpenShift Container Platform 4 cluster is updated automatically by the Operator Lifecycle Manager.

To ensure that you have the latest version on the OpenShift Container Platform 3 cluster, download the operator.yml and controller-3.yml files when you are ready to create and run the migration plan.

Prerequisites
  • Access to registry.redhat.io

  • Linux workstation with unrestricted network access

  • Mirror registry that supports Docker v2-2

  • Custom Operator catalog pushed to a mirror registry

Procedure
  1. On the workstation with unrestricted network access, log in to registry.redhat.io with your Red Hat Customer Portal credentials:

    $ sudo podman login registry.redhat.io
  2. Download the operator.yml file:

    $ sudo podman cp $(sudo podman create registry.redhat.io/rhmtc/openshift-migration-rhel7-operator:v1.3.0):/operator.yml ./
  3. Download the controller-3.yml file:

    $ sudo podman cp $(sudo podman create registry.redhat.io/rhmtc/openshift-migration-rhel7-operator:v1.3.0):/controller-3.yml ./
  4. Obtain the Operator image value from the mapping.txt file that was created when you ran the oc adm catalog mirror on the OpenShift Container Platform 4 cluster:

    $ grep openshift-migration-rhel7-operator ./mapping.txt | grep rhmtc

    The output shows the mapping between the registry.redhat.io image and your mirror registry image.

    Example output
    registry.redhat.io/rhmtc/openshift-migration-rhel7-operator@sha256:468a6126f73b1ee12085ca53a312d1f96ef5a2ca03442bcb63724af5e2614e8a=<registry.apps.example.com>/rhmtc/openshift-migration-rhel7-operator
  5. Update the image and REGISTRY values in the operator.yml file:

    containers:
      - name: ansible
        image: <registry.apps.example.com>/rhmtc/openshift-migration-rhel7-operator@sha256:<468a6126f73b1ee12085ca53a312d1f96ef5a2ca03442bcb63724af5e2614e8a> (1)
    ...
      - name: operator
        image: <registry.apps.example.com>/rhmtc/openshift-migration-rhel7-operator@sha256:<468a6126f73b1ee12085ca53a312d1f96ef5a2ca03442bcb63724af5e2614e8a> (2)
    ...
        env:
        - name: REGISTRY
          value: <registry.apps.example.com> (3)
    1 Specify your mirror registry and the sha256 value of the Operator image in the mapping.txt file.
    2 Specify your mirror registry and the sha256 value of the Operator image in the mapping.txt file.
    3 Specify your mirror registry.
  6. Log in to your OpenShift Container Platform 3 cluster.

  7. Create the MTC Operator CR object:

    $ oc create -f operator.yml
    Example output
    namespace/openshift-migration created
    rolebinding.rbac.authorization.k8s.io/system:deployers created
    serviceaccount/migration-operator created
    customresourcedefinition.apiextensions.k8s.io/migrationcontrollers.migration.openshift.io created
    role.rbac.authorization.k8s.io/migration-operator created
    rolebinding.rbac.authorization.k8s.io/migration-operator created
    clusterrolebinding.rbac.authorization.k8s.io/migration-operator created
    deployment.apps/migration-operator created
    Error from server (AlreadyExists): error when creating "./operator.yml":
    rolebindings.rbac.authorization.k8s.io "system:image-builders" already exists (1)
    Error from server (AlreadyExists): error when creating "./operator.yml":
    rolebindings.rbac.authorization.k8s.io "system:image-pullers" already exists
    1 You can ignore Error from server (AlreadyExists) messages. They are caused by the MTC Operator creating resources for earlier versions of OpenShift Container Platform 3 that are provided in later releases.
  8. Create the Migration Controller CR object:

    $ oc create -f controller-3.yml
  9. Verify that the Velero and Restic pods are running:

    $ oc get pods -n openshift-migration

Launching the MTC web console

You can launch the MTC web console in a browser.

Procedure
  1. Log in to the OpenShift Container Platform cluster on which you have installed MTC.

  2. Obtain the MTC web console URL by entering the following command:

    $ oc get -n openshift-migration route/migration -o go-template='https://{{ .spec.host }}'

    The output resembles the following: https://migration-openshift-migration.apps.cluster.openshift.com.

  3. Launch a browser and navigate to the MTC web console.

    If you try to access the MTC web console immediately after installing the MTC Operator, the console may not load because the Operator is still configuring the cluster. Wait a few minutes and retry.

  4. If you are using self-signed CA certificates, you will be prompted to accept the CA certificate of the source cluster’s API server. The web page guides you through the process of accepting the remaining certificates.

  5. Log in with your OpenShift Container Platform username and password.