In this blog post we will look into migrating an application from OpenShift Platform 3.11 (source) to ROSA (target) using the Migration Toolkit for Containers (MTC).

The OCP 3.11 source cluster is running on AWS, but this source cluster could be running anywhere on bare metal on-prem, on Azure, on GPC, or on virtualization platforms like Red Hat Virtualization or VMWare.

The target cluster is a ROSA cluster. ROSA is Managed OpenShift on AWS, and is running version 4.11.

Application running on OCP3

OSToy is a simple Node.js application that we will deploy on the OSP3. It will be used to help us explore the functionalities of MTC, and will be migrated from OCP3 to ROSA.

The applications backend microservice serves internal web requests and returns a JSON object containing the current hostname and a randomly generated color string. The backend is deployed on the OCP3 cluster as follows in the ostoy namespace:

oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml

The clients will be accessing the application via the frontend service, and it is deployed as follows:

oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/ros

Install the Migration Toolkit for Containers Operator on the ROSA cluster

Prerequisites

  • You must be logged in as a user with cluster-admin privileges on all clusters.

Procedure

  1. In the ROSA web console, click Operators → OperatorHub.
  2. Use the Filter by keyword field to find the Migration Toolkit for Containers Operator.
  3. Select the Migration Toolkit for Containers Operator and click Install.
  4. Click Install.
    On the
    Installed Operators page, the Migration Toolkit for Containers Operator appears in the openshift-migration project with the status Succeeded.
  5. Click Migration Toolkit for Containers Operator.
  6. Under Provided APIs, locate the Migration Controller tile, and click Create Instance.
  7. Click Create.
  8. Click Workloads → Pods to verify that the MTC pods are running.

image19-Sep-16-2022-03-51-29-00-PM

Configuring a replication repository

Now configure an AWS S3 object store to use as a replication repository. MTC copies the data from the OCP3 cluster to the replication repository, and then from the replication repository to the ROSA cluster. The AWS S3 storage bucket must be accessible to the source and target clusters. As you can seen from the AWS console we have created a S3 bucket called mtc-demo-1 to be used as the replication repository.

Install the legacy MTC Operator on OpenShift Container Platform 3 (OCP3)

Prerequisites

  • You must be logged in as a user with admin privileges on the OCP3 clusters.
  • You must have podman installed.
  • You must have access to registry.redhat.io.
  • Download the operator.yml
[lab-user@master1 0 ~]$ sudo yum install podman -y
[lab-user@master1 0 ~]$ sudo podman login registry.redhat.io
Authenticating with existing credentials...
Existing credentials are valid. Already logged in to registry.redhat.io
[lab-user@master1 0 ~]$ sudo podman cp $(sudo podman create registry.redhat.io/rhmtc/openshift-migration-legacy-rhel8-operator:v1.7.3):/operator.yml ./
Trying to pull registry.redhat.io/rhmtc/openshift-migration-legacy-rhel8-operator:v1.7.3...Getting image source signatures
Copying blob 237bfbffb5f2 skipped: already exists
Copying blob 39382676eb30 skipped: already exists
Copying blob 04ff7332b7d0 done
Copying blob 2a83e9b81ea2 done
Copying blob 7c20bc76d047 done
Copying blob fd900e8182bc done
Copying config 34c6ad0749 done
Writing manifest to image destination
Storing signatures

Download the controller .yml file:

[lab-user@master1 0 ~]$ sudo podman cp $(sudo podman create registry.redhat.io/rhmtc/openshift-migration-legacy-rhel8-operator:v1.7.3):/controller.yml ./

Create the Migration Toolkit for Containers Operator object:

[lab-user@master1 0 ~]$ oc apply -f operator.yml 
deployment.apps/migration-operator configured

Create the MigrationController object:

[lab-user@master1 0 ~]$ oc create -f controller.yml

Verify that the MTC pods are running:

[lab-user@master1 130 ~]$ oc get pods -n openshift-migration
NAME                                    READY     STATUS    RESTARTS   AGE
migration-log-reader-7b4d8677c4-swqg8   2/2       Running   0          4h
migration-operator-fddd58c6f-sph4z      1/1       Running   0          4h
restic-4hzch                            1/1       Running   0          4h
restic-bplws                            1/1       Running   0          4h
restic-cn56c                            1/1       Running   0          4h
restic-flfsq                            1/1       Running   0          4h
restic-fxwtb                            1/1       Running   0          4h
restic-hjsxz                            1/1       Running   0          4h
restic-m4vhb                            1/1       Running   0          4h
restic-q6jb9                            1/1       Running   0          4h
restic-vck6c                            1/1       Running   0          4h
restic-w8zk5                            1/1       Running   0          4h
velero-79b587879b-chg4w                 1/1       Running   0          4h

Start the Migration using the MTC console

Access the MTC console by clicking on the migration Route in the openshift-migration namespace on the ROSA (target) cluster.

image12-Sep-16-2022-03-51-28-56-PM

In the MTC console, you will see the host cluster already listed. This is the ROSA or the target cluster where you will be migrating the application or the service to from the OCP3 cluster.

Add the OCP3 cluster by clicking on the Add cluster button.

Enter the Cluster name, URL of the cluster’s API server, the Service account token, and the route to the cluster’s image registry, and then click the Add cluster button.

Cluster name = ocp3-new

URL = https://master.kjnn5.sandbox1216.opentlc.com:443

Service account token = output of <oc sa get-token migration-controller -n openshift-migration >

Exposed route host to image registry = output of <oc get routes>

If the connection is successful, you will see the OCP3 cluster added to the list of clusters

image17-Sep-16-2022-03-51-28-42-PM

Next we will add the S3 by going to Replication repositories and clicking on the Add replication repository button.

Make sure that the Status shows as Connected before proceeding.

Next create the Migration plan, clicking on the Add migration plan button.

Next select the project to be migrated. For this demo we will select the roadshow project.

Next, MTC will discover the Persistent volumes for the project to be migrated.

Next, for each of the persistent volumes to be copied, you can select the target PVC and target storage class.

image6-Sep-16-2022-03-51-28-63-PM

Next, select the Migration options. For this blog post we will select the Direct image migration option.

In the next screen we can add Hooks, which are commands that can run at various steps in the migration process. They are defined in a container image or an Ansible playbook and can be run on either the source or the target ROSA cluster.

On clicking the Next button, you should see the Validation successful screen

Clicking the Close button take you to the screen listing the Migration plans

Next, click on the three dots on the right of the above screen. It will show you Migration options like Stage, Cutover, and Rollback. For this blog we will go with the Cutover migration option. During cutover migration by default all applications on the source namespaces included in the plane are halted for the duration of the migration. Also, the PVs associated with the projects being migrated are moved or copied to the target cluster as specified in the migration plan.

We will click on the checkbox that halts the application on the source namespace during migration.

image13-Sep-16-2022-03-51-28-41-PM

On successful completion of the migration you will see the Last state as Migration succeeded.

Clicking on the Migration 1 link shows the Status of the migration as it is progressing.

Test the application on ROSA

On the ROSA console go to Workloads -> Pods and check if both the ostoy-frontend and ostoy-microservice pods are running. Also, under Workloads check the Deployments, Persistent Volumes, ConfigMaps, Secrets. Under Networking check the Services and Routes. Click on the Location URL to see if the Application can be accessed using the route.

Conclusion

The Migration Toolkit for Containers (MTC) enables you to migrate stateful application workloads between OpenShift Container Platform 3 and ROSA clusters at the granularity of a namespace. In this blog we have migrated a Node.js application with Persistent Volumes running on OCP3 to a ROSA cluster using the MTC web console.

I would recommend listening to the The benefits of migrating to Red Hat OpenShift Service on AWS webinar as a follow up action, as it will cover benefits to migrating to ROSA, including - Reduced time and costs by not having to maintain and manage a platform on your own, AWS service integration with a self-service deployment model, Improvements in operational efficiency and developer productivity, and Full-stack management by our Red Hat SRE team.


About the author

Mayur Shetty is a Principal Solution Architect with Red Hat’s Global Partners and Alliances (GPA) organization,  working closely with cloud and system partners. He has been with Red Hat for more than five years and was part of the OpenStack Tiger Team.

Read full bio