1.6.3. 명령줄에서 애플리케이션 마이그레이션
MTC 사용자 정의 리소스(CR)를 사용하여 명령줄에서 애플리케이션을 마이그레이션할 수 있습니다.
로컬 클러스터에서 원격 클러스터, 원격 클러스터에서 로컬 클러스터, 원격 클러스터, 원격 클러스터 간에 애플리케이션을 마이그레이션할 수 있습니다.
MTC 용어
다음 용어는 클러스터 구성과 관련이 있습니다.
host
클러스터:-
migration-controller
포드는host
클러스터에서 실행됩니다. -
host
클러스터에 직접 이미지 마이그레이션을 위해 노출된 보안 레지스트리 경로가 필요하지 않습니다.
-
-
로컬 클러스터: 로컬 클러스터는 host
클러스터
와 종종 동일하지만 필수 클러스터는 아닙니다. 원격 클러스터:
- 원격 클러스터에 직접 이미지 마이그레이션을 위해 노출된 보안 레지스트리 경로를 보유해야 합니다.
-
원격 클러스터에
migration-controller
서비스 계정 토큰이 포함된Secret
CR이 있어야 합니다.
다음 용어는 마이그레이션 수행과 관련이 있습니다.
- 소스 클러스터: 애플리케이션이 마이그레이션되는 클러스터입니다.
- 대상 클러스터: 애플리케이션이 마이그레이션될 대상 클러스터입니다.
1.6.3.1. Migration Toolkit for Containers API를 사용하여 애플리케이션 마이그레이션
MTC(Migration Toolkit for Containers) API를 사용하여 명령줄에서 애플리케이션을 마이그레이션할 수 있습니다.
로컬 클러스터에서 원격 클러스터, 원격 클러스터에서 로컬 클러스터, 원격 클러스터, 원격 클러스터 간에 애플리케이션을 마이그레이션할 수 있습니다.
다음 프로세스에서는 간접 마이그레이션 및 직접 마이그레이션을 수행하는 방법을 설명합니다.
- 간접 마이그레이션: 이미지, 볼륨 및 Kubernetes 오브젝트는 소스 클러스터에서 복제 리포지토리로 복사한 다음 복제 리포지토리에서 대상 클러스터로 복사됩니다.
- 직접 마이그레이션: 이미지 또는 볼륨은 소스 클러스터에서 대상 클러스터로 직접 복사됩니다. 직접 이미지 마이그레이션 및 직접 볼륨 마이그레이션은 성능에 큰 이점이 있습니다.
다음 사용자 정의 리소스(CR)를 생성하여 마이그레이션을 수행합니다.
MigCluster
CR:호스트
, 로컬 또는 원격 클러스터 정의migration-controller
포드는host
클러스터에서 실행됩니다.-
Secret
CR: 원격 클러스터 또는 스토리지에 대한 인증 정보 포함 MigStorage
CR: 복제 리포지토리 정의스토리지 공급자마다
MigStorage
CR 매니페스트의 다른 매개변수가 필요합니다.-
MigPlan
CR: 마이그레이션 계획 정의 MigMigration
CR: 연결된MigPlan
에 정의된 마이그레이션을 수행합니다.다음과 같은 목적으로 단일
MigPlan
CR에 대해 여러MigMigration
CR을 생성할 수 있습니다.- 단계 마이그레이션을 수행하려면 마이그레이션을 실행하기 전에 애플리케이션을 중지하지 않고 대부분의 데이터를 복사합니다. 단계별 마이그레이션은 마이그레이션의 성능을 향상시킵니다.
- 진행 중인 마이그레이션을 취소하려면
- 완료된 마이그레이션을 롤백하려면
사전 요구 사항
-
모든 클러스터에 대한
cluster-admin
권한이 있어야 합니다. -
OpenShift Container Platform CLI(
oc
)를 설치해야 합니다. - 모든 클러스터에 Migration Toolkit for Containers Operator를 설치해야 합니다.
- 모든 클러스터에서 설치된 Migration Toolkit for Containers Operator 버전이 동일해야 합니다.
- 복제 리포지토리로 오브젝트 스토리지를 구성해야 합니다.
- 직접 이미지 마이그레이션을 사용하는 경우 모든 원격 클러스터에 보안 레지스트리 경로를 노출해야 합니다.
- 직접 볼륨 마이그레이션을 사용하는 경우 소스 클러스터에 HTTP 프록시가 구성되어 있지 않아야 합니다.
프로세스
host-cluster.yaml
이라는host
클러스터에 대한MigCluster
CR 매니페스트를 생성합니다.apiVersion: migration.openshift.io/v1alpha1 kind: MigCluster metadata: name: host namespace: openshift-migration spec: isHostCluster: true
host
클러스터에 대한MigCluster
CR을 생성합니다.$ oc create -f host-cluster.yaml -n openshift-migration
cluster-secret.yaml
이라는 각 원격 클러스터에 대한Secret
CR 매니페스트를 생성합니다.apiVersion: v1 kind: Secret metadata: name: <cluster_secret> namespace: openshift-config type: Opaque data: saToken: <sa_token> 1
- 1
- 원격 클러스터의 base64로 인코딩된
migration-controller
서비스 계정(SA) 토큰을 지정합니다.
다음 명령을 실행하여 SA 토큰을 확보할 수 있습니다.
$ oc sa get-token migration-controller -n openshift-migration | base64 -w 0
각 원격 클러스터에 대한
Secret
CR을 생성합니다.$ oc create -f cluster-secret.yaml
remote-cluster.yaml
이라는 각 원격 클러스터에 대해MigCluster
CR 매니페스트를 생성합니다.apiVersion: migration.openshift.io/v1alpha1 kind: MigCluster metadata: name: <remote_cluster> namespace: openshift-migration spec: exposedRegistryPath: <exposed_registry_route> 1 insecure: false 2 isHostCluster: false serviceAccountSecretRef: name: <remote_cluster_secret> 3 namespace: openshift-config url: <remote_cluster_url> 4
각 원격 클러스터에 대해
MigCluster
CR을 생성합니다.$ oc create -f remote-cluster.yaml -n openshift-migration
모든 클러스터가
Ready
상태에 있는지 확인합니다.$ oc describe cluster <cluster_name>
storage-secret.yaml
이라는 복제 리포지토리의Secret
CR 매니페스트를 생성합니다.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
AWS 인증 정보는 기본적으로 base64로 인코딩됩니다. 다른 스토리지 공급자를 사용하는 경우 각 키로 다음 명령을 실행하여 인증 정보를 인코딩해야 합니다.
$ echo -n "<key>" | base64 -w 0 1
- 1
- 키 ID 또는 시크릿 키를 지정합니다. 두 키 모두 base64로 인코딩되어야 합니다.
복제 리포지토리에 대한
Secret
CR을 생성합니다.$ oc create -f storage-secret.yaml
migstorage.yaml
이라는 복제 리포지토리에 대한MigStorage
CR 매니페스트를 생성합니다.apiVersion: migration.openshift.io/v1alpha1 kind: MigStorage metadata: name: <storage_name> namespace: openshift-migration spec: backupStorageConfig: awsBucketName: <bucket_name> 1 credsSecretRef: name: <storage_secret_ref> 2 namespace: openshift-config backupStorageProvider: <storage_provider_name> 3 volumeSnapshotConfig: credsSecretRef: name: <storage_secret_ref> 4 namespace: openshift-config volumeSnapshotProvider: <storage_provider_name> 5
MigStorage
CR을 생성합니다.$ oc create -f migstorage.yaml -n openshift-migration
MigStorage
CR이Ready
상태에 있는지 확인합니다.$ oc describe migstorage <migstorage_name>
migplan.yaml
이라는MigPlan
CR 매니페스트를 생성합니다.apiVersion: migration.openshift.io/v1alpha1 kind: MigPlan metadata: name: <migration_plan> namespace: openshift-migration spec: destMigClusterRef: name: host namespace: openshift-migration indirectImageMigration: true 1 indirectVolumeMigration: true 2 migStorageRef: name: <migstorage_ref> 3 namespace: openshift-migration namespaces: - <application_namespace> 4 srcMigClusterRef: name: <remote_cluster_ref> 5 namespace: openshift-migration
MigPlan
CR을 만듭니다.$ oc create -f migplan.yaml -n openshift-migration
MigPlan
인스턴스를 보고Ready
상태인지 확인합니다.$ oc describe migplan <migplan_name> -n openshift-migration
migmigration.yaml
이라는MigMigration
CR 매니페스트를 생성합니다.apiVersion: migration.openshift.io/v1alpha1 kind: MigMigration metadata: name: <migmigration_name> namespace: openshift-migration spec: migPlanRef: name: <migplan_name> 1 namespace: openshift-migration quiescePods: true 2 stage: false 3 rollback: false 4
MigPlan
CR에 정의된 마이그레이션을 시작하도록MigMigration
CR을 생성합니다.$ oc create -f migmigration.yaml -n openshift-migration
MigMigration
CR을 확인하여 마이그레이션 진행 상황을 확인합니다.$ oc watch migmigration <migmigration_name> -n openshift-migration
출력은 다음과 유사합니다.
출력 예
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: my_application 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