12.2. MTC 自定义资源清单
MTC 使用以下自定义资源(CR)清单来迁移应用程序。
12.2.1. DirectImageMigration
DirectImageMigration CR 直接将镜像从源集群复制到目标集群。
apiVersion: migration.openshift.io/v1alpha1
kind: DirectImageMigration
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: <direct_image_migration>
spec:
srcMigClusterRef:
name: <source_cluster>
namespace: openshift-migration
destMigClusterRef:
name: <destination_cluster>
namespace: openshift-migration
namespaces: 1
- <source_namespace_1>
- <source_namespace_2>:<destination_namespace_3> 212.2.2. DirectImageStreamMigration
DirectImageStreamMigration CR 直接将镜像流引用从源集群复制到目标集群。
apiVersion: migration.openshift.io/v1alpha1
kind: DirectImageStreamMigration
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: <direct_image_stream_migration>
spec:
srcMigClusterRef:
name: <source_cluster>
namespace: openshift-migration
destMigClusterRef:
name: <destination_cluster>
namespace: openshift-migration
imageStreamRef:
name: <image_stream>
namespace: <source_image_stream_namespace>
destNamespace: <destination_image_stream_namespace>12.2.3. DirectVolumeMigration
DirectVolumeMigration CR 直接将持久性卷(PV)从源集群复制到目标集群。
apiVersion: migration.openshift.io/v1alpha1 kind: DirectVolumeMigration metadata: name: <direct_volume_migration> namespace: openshift-migration spec: createDestinationNamespaces: false 1 deleteProgressReportingCRs: false 2 destMigClusterRef: name: <host_cluster> 3 namespace: openshift-migration persistentVolumeClaims: - name: <pvc> 4 namespace: <pvc_namespace> srcMigClusterRef: name: <source_cluster> namespace: openshift-migration
12.2.4. DirectVolumeMigrationProgress
DirectVolumeMigrationProgress CR 显示 DirectVolumeMigration CR 的进度。
apiVersion: migration.openshift.io/v1alpha1
kind: DirectVolumeMigrationProgress
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: <direct_volume_migration_progress>
spec:
clusterRef:
name: <source_cluster>
namespace: openshift-migration
podRef:
name: <rsync_pod>
namespace: openshift-migration12.2.5. MigAnalytic
MigAnalytic CR 从关联的 MigPlan CR 收集镜像、Kubernetes 资源和持久性卷(PV)容量的数量。
您可以配置它收集的数据。
apiVersion: migration.openshift.io/v1alpha1
kind: MigAnalytic
metadata:
annotations:
migplan: <migplan>
name: <miganalytic>
namespace: openshift-migration
labels:
migplan: <migplan>
spec:
analyzeImageCount: true 1
analyzeK8SResources: true 2
analyzePVCapacity: true 3
listImages: false 4
listImagesLimit: 50 5
migPlanRef:
name: <migplan>
namespace: openshift-migration12.2.6. MigCluster
MigCluster CR 定义一个主机、本地或远程集群。
apiVersion: migration.openshift.io/v1alpha1
kind: MigCluster
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: <host_cluster> 1
namespace: openshift-migration
spec:
isHostCluster: true 2
# The 'azureResourceGroup' parameter is relevant only for Microsoft Azure.
azureResourceGroup: <azure_resource_group> 3
caBundle: <ca_bundle_base64> 4
insecure: false 5
refresh: false 6
# The 'restartRestic' parameter is relevant for a source cluster.
restartRestic: true 7
# The following parameters are relevant for a remote cluster.
exposedRegistryPath: <registry_route> 8
url: <destination_cluster_url> 9
serviceAccountSecretRef:
name: <source_secret> 10
namespace: openshift-config- 1
- 如果
migration-controllerpod 没有在这个集群中运行,请更新集群名称。 - 2
- 如果为
true,则migration-controllerpod 在此集群中运行。 - 3
- 仅 Microsoft Azure:指定资源组。
- 4
- 可选:如果您为自签名 CA 证书创建了一个证书捆绑包,且
insecure参数值为false,请指定 base64 编码的证书捆绑包。 - 5
- 设置为
true以禁用 SSL 验证。 - 6
- 设置为
true以验证集群。 - 7
- 设置为
true,以在创建Stagepod 后重启源集群中的Resticpod。 - 8
- 远程集群和直接镜像迁移:指定公开的安全 registry 路径。
- 9
- 仅远程集群:指定 URL。
- 10
- 仅远程集群:指定
Secret对象的名称。
12.2.7. MigHook
MigHook CR 定义一个迁移 hook,它在迁移的指定阶段运行自定义代码。您可以创建最多四个迁移 hook。每个 hook 在迁移的不同阶段运行。
您可以配置 hook 名称、运行时持续时间、自定义镜像,以及 hook 将运行的集群。
hook 的迁移阶段和命名空间在 MigPlan CR 中配置。
apiVersion: migration.openshift.io/v1alpha1 kind: MigHook metadata: generateName: <hook_name_prefix> 1 name: <mighook> 2 namespace: openshift-migration spec: activeDeadlineSeconds: 1800 3 custom: false 4 image: <hook_image> 5 playbook: <ansible_playbook_base64> 6 targetCluster: source 7
- 1
- 可选:此参数的值后附加一个唯一的哈希值,以便每个迁移 hook 都有一个唯一的名称。您不需要指定
name参数的值。 - 2
- 指定迁移 hook 名称,除非指定了
generateName参数的值。 - 3
- 可选:指定 hook 可运行的最大秒数。默认值为
1800。 - 4
- 如果为
true,则 hook 是一个自定义镜像。自定义镜像可以包括 Ansible,也可以使用不同的编程语言编写。 - 5
- 指定自定义镜像,例如
quay.io/konveyor/hook-runner:latest。如果custom是true,则需要此项。 - 6
- base64 编码的 Ansible playbook.如果
custom是false,则必需。 - 7
- 指定要运行 hook 的集群。有效值为
source或destination。
12.2.8. MigMigration
MigMigration CR 运行一个 MigPlan CR。
您可以配置 Migmigration CR,以运行一个阶段或增量迁移,取消正在进行中的迁移,或回滚已完成的迁移。
apiVersion: migration.openshift.io/v1alpha1
kind: MigMigration
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: <migmigration>
namespace: openshift-migration
spec:
canceled: false 1
rollback: false 2
stage: false 3
quiescePods: true 4
keepAnnotations: true 5
verify: false 6
migPlanRef:
name: <migplan>
namespace: openshift-migration12.2.9. MigPlan
MigPlan CR 定义迁移计划的参数。
您可以配置目标命名空间、hook 阶段以及直接或间接迁移。
默认情况下,目标命名空间的名称与源命名空间相同。如果配置了一个不同的目标命名空间,您必须确保不会在源或目标集群上重复命名空间,因为在迁移过程中复制了 UID 和 GID 范围。
apiVersion: migration.openshift.io/v1alpha1
kind: MigPlan
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: <migplan>
namespace: openshift-migration
spec:
closed: false 1
srcMigClusterRef:
name: <source_cluster>
namespace: openshift-migration
destMigClusterRef:
name: <destination_cluster>
namespace: openshift-migration
hooks: 2
- executionNamespace: <namespace> 3
phase: <migration_phase> 4
reference:
name: <hook> 5
namespace: <hook_namespace> 6
serviceAccount: <service_account> 7
indirectImageMigration: true 8
indirectVolumeMigration: false 9
migStorageRef:
name: <migstorage>
namespace: openshift-migration
namespaces:
- <source_namespace_1> 10
- <source_namespace_2>
- <source_namespace_3>:<destination_namespace_4> 11
refresh: false 12- 1
- 如果为
true,则迁移已完成。您不能为此MigPlanCR 创建另一个MigMigrationCR。 - 2
- 可选:最多可指定四个迁移 hook。每个 hook 必须在不同的迁移阶段运行。
- 3
- 可选:指定运行 hook 的命名空间。
- 4
- 可选:指定 hook 运行期间的迁移阶段。一个 hook 可以分配给一个阶段。有效值为
PreBackup、PostBackup、PreRestore和PostRestore。 - 5
- 可选:指定
MigHookCR 的名称。 - 6
- 可选:指定
MigHookCR 的命名空间。 - 7
- 可选:指定一个具有
cluster-admin权限的服务帐户。 - 8
- 如果为
true,则禁用直接镜像迁移。镜像从源集群复制到复制存储库,并从复制存储库复制到目标集群。 - 9
- 如果为
true,则禁用直接卷迁移。PV 从源集群复制到复制存储库,再从复制存储库复制到目标集群。 - 10
- 指定一个或多个源命名空间。如果只指定源命名空间,则目标命名空间是相同的。
- 11
- 如果目标命名空间与源命名空间不同,请指定它。
- 12
- 如果为
true,MigPlanCR 会被验证。
12.2.10. MigStorage
MigStorage CR 描述了复制存储库的对象存储。
支持 Amazon Web Services(AWS)、Microsoft Azure、Google Cloud Storage、Multi-Cloud Object Gateway 和通用 S3 兼容云存储。
AWS 和快照复制方法具有额外的参数。
apiVersion: migration.openshift.io/v1alpha1
kind: MigStorage
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: <migstorage>
namespace: openshift-migration
spec:
backupStorageProvider: <backup_storage_provider> 1
volumeSnapshotProvider: <snapshot_storage_provider> 2
backupStorageConfig:
awsBucketName: <bucket> 3
awsRegion: <region> 4
credsSecretRef:
namespace: openshift-config
name: <storage_secret> 5
awsKmsKeyId: <key_id> 6
awsPublicUrl: <public_url> 7
awsSignatureVersion: <signature_version> 8
volumeSnapshotConfig:
awsRegion: <region> 9
credsSecretRef:
namespace: openshift-config
name: <storage_secret> 10
refresh: false 11