This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.11.2.4. Migration einer Anwendung mit Hilfe der MTC-API
Sie können eine Anwendung über die Befehlszeile migrieren, indem Sie die MTC-API (Migration Toolkit for Containers) verwenden.
Vorgehensweise
Erstellen Sie ein
MigCluster
-CR-Manifest für den Host-Cluster:$ cat << EOF | oc apply -f - apiVersion: migration.openshift.io/v1alpha1 kind: MigCluster metadata: name: <host_cluster> namespace: openshift-migration spec: isHostCluster: true EOF
$ cat << EOF | oc apply -f - apiVersion: migration.openshift.io/v1alpha1 kind: MigCluster metadata: name: <host_cluster> namespace: openshift-migration spec: isHostCluster: true EOF
Copy to Clipboard Copied! Erstellen Sie ein
Secret
-Objektmanifest für jeden Remote-Cluster:$ cat << EOF | oc apply -f - apiVersion: v1 kind: Secret metadata: name: <cluster_secret> namespace: openshift-config type: Opaque data: saToken: <sa_token> EOF
$ cat << EOF | oc apply -f - apiVersion: v1 kind: Secret metadata: name: <cluster_secret> namespace: openshift-config type: Opaque data: saToken: <sa_token>
1 EOF
Copy to Clipboard Copied! - 1
- Geben Sie das base64-kodierte SA-Token (Service Account)
migration-controller
des Remote-Clusters an. Sie erhalten das Token, indem Sie den folgenden Befehl ausführen:
oc sa get-token migration-controller -n openshift-migration | base64 -w 0
$ oc sa get-token migration-controller -n openshift-migration | base64 -w 0
Copy to Clipboard Copied! Erstellen Sie für jeden Remote-Cluster ein
MigCluster
-CR-Manifest:$ cat << EOF | oc apply -f - apiVersion: migration.openshift.io/v1alpha1 kind: MigCluster metadata: name: <remote_cluster> namespace: openshift-migration spec: exposedRegistryPath: <exposed_registry_route> insecure: false isHostCluster: false serviceAccountSecretRef: name: <remote_cluster_secret> namespace: openshift-config url: <remote_cluster_url> EOF
$ 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
Copy to Clipboard Copied! - 1
- Geben Sie die CR
Cluster
des Remote-Clusters an. - 2
- Optional: Geben Sie für die Direct Image Migration die verfügbare Registrierungsroute an.
- 3
- Bei
false
ist die SSL-Verifizierung aktiviert. CA-Zertifikate sind nicht erforderlich und werden nicht überprüft, wenntrue
. - 4
- Geben Sie das Objekt
Secret
des Remote-Clusters an. - 5
- Geben Sie die URL des Remote-Clusters an.
Verifizieren Sie, dass sich alle Cluster im Status
Ready
befinden:oc describe cluster <cluster>
$ oc describe cluster <cluster>
Copy to Clipboard Copied! Erstellen Sie ein
Secret
-Objektmanifest für das Replikations-Repository:$ 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> aws-secret-access-key: <secret_key_base64> EOF
$ 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
Copy to Clipboard Copied! AWS-Anmeldedaten sind standardmäßig base64-kodiert. Bei anderen Speicheranbietern müssen Sie Ihre Anmeldedaten verschlüsseln, indem Sie den folgenden Befehl mit jedem Schlüssel ausführen:
echo -n "<key>" | base64 -w 0
$ echo -n "<key>" | base64 -w 0
1 Copy to Clipboard Copied! - 1
- Geben Sie die Schlüssel-ID oder den geheimen Schlüssel an. Beide Schlüssel müssen base64-kodiert sein.
Erstellen Sie ein
MigStorage
-CR-Manifest für das Replikations-Repository:$ cat << EOF | oc apply -f - apiVersion: migration.openshift.io/v1alpha1 kind: MigStorage metadata: name: <migstorage> namespace: openshift-migration spec: backupStorageConfig: awsBucketName: <bucket> credsSecretRef: name: <storage_secret> namespace: openshift-config backupStorageProvider: <storage_provider> volumeSnapshotConfig: credsSecretRef: name: <storage_secret> namespace: openshift-config volumeSnapshotProvider: <storage_provider> EOF
$ 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
Copy to Clipboard Copied! - 1
- Geben Sie den Bucket-Namen an.
- 2
- Geben Sie die CR
Secrets
des Objektspeichers an. Sie müssen sicherstellen, dass die in der CRSecrets
des Objektspeichers gespeicherten Anmeldedaten korrekt sind. - 3
- Geben Sie den Speicheranbieter an.
- 4
- Optional: Wenn Sie Daten mit Hilfe von Schnappschüssen kopieren, geben Sie die CR
Secrets
des Objektspeichers an. Sie müssen sicherstellen, dass die in der CRSecrets
des Objektspeichers gespeicherten Anmeldedaten korrekt sind. - 5
- Optional: Wenn Sie Daten mit Hilfe von Schnappschüssen kopieren, geben Sie den Speicheranbieter an.
Verifizieren Sie, dass die CR
MigStorage
den StatusReady
hat:oc describe migstorage <migstorage>
$ oc describe migstorage <migstorage>
Copy to Clipboard Copied! Erstellen Sie ein
MigPlan
-CR-Manifest:$ 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 indirectVolumeMigration: true migStorageRef: name: <migstorage> namespace: openshift-migration namespaces: - <source_namespace_1> - <source_namespace_2> - <source_namespace_3>:<destination_namespace> srcMigClusterRef: name: <remote_cluster> namespace: openshift-migration EOF
$ 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
Copy to Clipboard Copied! - 1
- Direct Image Migration ist aktiviert, wenn
false
. - 2
- Direct Volume Migration ist aktiviert, wenn
false
. - 3
- Geben Sie den Namen der CR-Instanz
MigStorage
an. - 4
- Geben Sie einen oder mehrere Quell-Namespaces an. Standardmäßig hat der Ziel-Namespace denselben Namen.
- 5
- Geben Sie einen Ziel-Namespace an, wenn er sich vom Quell-Namespace unterscheidet.
- 6
- Geben Sie den Namen der Instanz
MigCluster
des Quell-Clusters an.
Vergewissern Sie sich, dass die Instanz
MigPlan
sich im StatusReady
befindet:oc describe migplan <migplan> -n openshift-migration
$ oc describe migplan <migplan> -n openshift-migration
Copy to Clipboard Copied! Erstellen Sie ein
MigMigration
-CR-Manifest, um die in der InstanzMigPlan
definierte Migration zu starten:$ cat << EOF | oc apply -f - apiVersion: migration.openshift.io/v1alpha1 kind: MigMigration metadata: name: <migmigration> namespace: openshift-migration spec: migPlanRef: name: <migplan> namespace: openshift-migration quiescePods: true stage: false rollback: false EOF
$ 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
Copy to Clipboard Copied! - 1
- Geben Sie den Namen der CR
MigPlan
an. - 2
- Die Pods auf dem Quell-Cluster werden vor der Migration gestoppt, wenn
true
. - 3
- Wenn
true
, wird eine Stage-Migration durchgeführt, bei der die meisten Daten kopiert werden, ohne die Anwendung anzuhalten. - 4
- Eine abgeschlossene Migration wird rückgängig gemacht, wenn
true
.
Überprüfen Sie die Migration, indem Sie den Fortschritt der CR
MigMigration
beobachten:oc watch migmigration <migmigration> -n openshift-migration
$ oc watch migmigration <migmigration> -n openshift-migration
Copy to Clipboard Copied! Die Ausgabe sieht wie folgt aus:
Beispielausgabe
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
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
Copy to Clipboard Copied!