1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/migration-migrating-applications-api.adoc
2024-11-01 12:40:53 +00:00

299 lines
9.1 KiB
Plaintext

// Module included in the following assemblies:
//
// * migrating_from_ocp_3_to_4/advanced-migration-options-3-4.adoc
// * migration_toolkit_for_containers/advanced-migration-options-mtc.adoc
:_mod-docs-content-type: PROCEDURE
[id="migration-migrating-applications-api_{context}"]
= Migrating an application by using the {mtc-short} API
You can migrate an application from the command line by using the {mtc-first} API.
.Procedure
. Create a `MigCluster` CR manifest for the host cluster:
+
[source,yaml]
----
$ cat << EOF | oc apply -f -
apiVersion: migration.openshift.io/v1alpha1
kind: MigCluster
metadata:
name: <host_cluster>
namespace: openshift-migration
spec:
isHostCluster: true
EOF
----
. Create a `Secret` object manifest for each remote cluster:
+
[source,yaml]
----
$ cat << EOF | oc apply -f -
apiVersion: v1
kind: Secret
metadata:
name: <cluster_secret>
namespace: openshift-config
type: Opaque
data:
saToken: <sa_token> <1>
EOF
----
<1> Specify the base64-encoded `migration-controller` service account (SA) token of the remote cluster. You can obtain the token by running the following command:
+
[source,terminal]
----
$ oc sa get-token migration-controller -n openshift-migration | base64 -w 0
----
. Create a `MigCluster` CR manifest for each remote cluster:
+
[source,yaml]
----
$ cat << EOF | oc apply -f -
apiVersion: migration.openshift.io/v1alpha1
kind: MigCluster
metadata:
name: <remote_cluster> <1>
namespace: openshift-migration
spec:
exposedRegistryPath: <exposed_registry_route> <2>
insecure: false <3>
isHostCluster: false
serviceAccountSecretRef:
name: <remote_cluster_secret> <4>
namespace: openshift-config
url: <remote_cluster_url> <5>
EOF
----
<1> Specify the `Cluster` CR of the remote cluster.
<2> Optional: For direct image migration, specify the exposed registry route.
<3> SSL verification is enabled if `false`. CA certificates are not required or checked if `true`.
<4> Specify the `Secret` object of the remote cluster.
<5> Specify the URL of the remote cluster.
. Verify that all clusters are in a `Ready` state:
+
[source,terminal]
----
$ oc describe MigCluster <cluster>
----
. Create a `Secret` object manifest for the replication repository:
+
[source,yaml]
----
$ cat << EOF | oc apply -f -
apiVersion: v1
kind: Secret
metadata:
namespace: openshift-config
name: <migstorage_creds>
type: Opaque
data:
aws-access-key-id: <key_id_base64> <1>
aws-secret-access-key: <secret_key_base64> <2>
EOF
----
<1> Specify the key ID in base64 format.
<2> Specify the secret key in base64 format.
+
AWS credentials are base64-encoded by default. For other storage providers, you must encode your credentials by running the following command with each key:
+
[source,terminal]
----
$ echo -n "<key>" | base64 -w 0 <1>
----
<1> Specify the key ID or the secret key. Both keys must be base64-encoded.
. Create a `MigStorage` CR manifest for the replication repository:
+
[source,yaml]
----
$ cat << EOF | oc apply -f -
apiVersion: migration.openshift.io/v1alpha1
kind: MigStorage
metadata:
name: <migstorage>
namespace: openshift-migration
spec:
backupStorageConfig:
awsBucketName: <bucket> <1>
credsSecretRef:
name: <storage_secret> <2>
namespace: openshift-config
backupStorageProvider: <storage_provider> <3>
volumeSnapshotConfig:
credsSecretRef:
name: <storage_secret> <4>
namespace: openshift-config
volumeSnapshotProvider: <storage_provider> <5>
EOF
----
<1> Specify the bucket name.
<2> Specify the `Secrets` CR of the object storage. You must ensure that the credentials stored in the `Secrets` CR of the object storage are correct.
<3> Specify the storage provider.
<4> Optional: If you are copying data by using snapshots, specify the `Secrets` CR of the object storage. You must ensure that the credentials stored in the `Secrets` CR of the object storage are correct.
<5> Optional: If you are copying data by using snapshots, specify the storage provider.
. Verify that the `MigStorage` CR is in a `Ready` state:
+
[source,terminal]
----
$ oc describe migstorage <migstorage>
----
. Create a `MigPlan` CR manifest:
+
[source,yaml]
----
$ cat << EOF | oc apply -f -
apiVersion: migration.openshift.io/v1alpha1
kind: MigPlan
metadata:
name: <migplan>
namespace: openshift-migration
spec:
destMigClusterRef:
name: <host_cluster>
namespace: openshift-migration
indirectImageMigration: true <1>
indirectVolumeMigration: true <2>
migStorageRef:
name: <migstorage> <3>
namespace: openshift-migration
namespaces:
- <source_namespace_1> <4>
- <source_namespace_2>
- <source_namespace_3>:<destination_namespace> <5>
srcMigClusterRef:
name: <remote_cluster> <6>
namespace: openshift-migration
EOF
----
<1> Direct image migration is enabled if `false`.
<2> Direct volume migration is enabled if `false`.
<3> Specify the name of the `MigStorage` CR instance.
<4> Specify one or more source namespaces. By default, the destination namespace has the same name.
<5> Specify a destination namespace if it is different from the source namespace.
<6> Specify the name of the source cluster `MigCluster` instance.
. Verify that the `MigPlan` instance is in a `Ready` state:
+
[source,terminal]
----
$ oc describe migplan <migplan> -n openshift-migration
----
. Create a `MigMigration` CR manifest to start the migration defined in the `MigPlan` instance:
+
[source,yaml]
----
$ cat << EOF | oc apply -f -
apiVersion: migration.openshift.io/v1alpha1
kind: MigMigration
metadata:
name: <migmigration>
namespace: openshift-migration
spec:
migPlanRef:
name: <migplan> <1>
namespace: openshift-migration
quiescePods: true <2>
stage: false <3>
rollback: false <4>
EOF
----
<1> Specify the `MigPlan` CR name.
<2> The pods on the source cluster are stopped before migration if `true`.
<3> A stage migration, which copies most of the data without stopping the application, is performed if `true`.
<4> A completed migration is rolled back if `true`.
. Verify the migration by watching the `MigMigration` CR progress:
+
[source,terminal]
----
$ oc watch migmigration <migmigration> -n openshift-migration
----
+
The output resembles the following:
+
.Example output
+
[source,text]
----
Name: c8b034c0-6567-11eb-9a4f-0bc004db0fbc
Namespace: openshift-migration
Labels: migration.openshift.io/migplan-name=django
Annotations: openshift.io/touch: e99f9083-6567-11eb-8420-0a580a81020c
API Version: migration.openshift.io/v1alpha1
Kind: MigMigration
...
Spec:
Mig Plan Ref:
Name: migplan
Namespace: openshift-migration
Stage: false
Status:
Conditions:
Category: Advisory
Last Transition Time: 2021-02-02T15:04:09Z
Message: Step: 19/47
Reason: InitialBackupCreated
Status: True
Type: Running
Category: Required
Last Transition Time: 2021-02-02T15:03:19Z
Message: The migration is ready.
Status: True
Type: Ready
Category: Required
Durable: true
Last Transition Time: 2021-02-02T15:04:05Z
Message: The migration registries are healthy.
Status: True
Type: RegistriesHealthy
Itinerary: Final
Observed Digest: 7fae9d21f15979c71ddc7dd075cb97061895caac5b936d92fae967019ab616d5
Phase: InitialBackupCreated
Pipeline:
Completed: 2021-02-02T15:04:07Z
Message: Completed
Name: Prepare
Started: 2021-02-02T15:03:18Z
Message: Waiting for initial Velero backup to complete.
Name: Backup
Phase: InitialBackupCreated
Progress:
Backup openshift-migration/c8b034c0-6567-11eb-9a4f-0bc004db0fbc-wpc44: 0 out of estimated total of 0 objects backed up (5s)
Started: 2021-02-02T15:04:07Z
Message: Not started
Name: StageBackup
Message: Not started
Name: StageRestore
Message: Not started
Name: DirectImage
Message: Not started
Name: DirectVolume
Message: Not started
Name: Restore
Message: Not started
Name: Cleanup
Start Timestamp: 2021-02-02T15:03:18Z
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Running 57s migmigration_controller Step: 2/47
Normal Running 57s migmigration_controller Step: 3/47
Normal Running 57s (x3 over 57s) migmigration_controller Step: 4/47
Normal Running 54s migmigration_controller Step: 5/47
Normal Running 54s migmigration_controller Step: 6/47
Normal Running 52s (x2 over 53s) migmigration_controller Step: 7/47
Normal Running 51s (x2 over 51s) migmigration_controller Step: 8/47
Normal Ready 50s (x12 over 57s) migmigration_controller The migration is ready.
Normal Running 50s migmigration_controller Step: 9/47
Normal Running 50s migmigration_controller Step: 10/47
----