|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * migrating_from_ocp_3_to_4/about-mtc-3-4.adoc |
| 4 | +// * migration_toolkit_for_containers/about-mtc.adoc |
| 5 | + |
| 6 | +[id="migration-state-migration-cli_{context}"] |
| 7 | += Migrating an application's state |
| 8 | + |
| 9 | +You can perform repeatable, state-only migrations by selecting specific persistent volume claims (PVCs). During a state migration, {mtc-full} ({mtc-short}) copies persistent volume (PV) data to the target cluster. PV references are not moved. The application pods continue to run on the source cluster. |
| 10 | + |
| 11 | +If you have a CI/CD pipeline, you can migrate stateless components by deploying them on the target cluster. Then you can migrate stateful components by using {mtc-short}. |
| 12 | + |
| 13 | +You can migrate PV data from the source cluster to PVCs that are already provisioned in the target cluster by mapping PVCs in the `MigPlan` CR. This ensures that the target PVCs of migrated applications are synchronized with the source PVCs. |
| 14 | + |
| 15 | +You can perform a one-time migration of Kubernetes objects that store application state. |
| 16 | + |
| 17 | +[id="excluding-pvcs_{context}"] |
| 18 | +== Excluding persistent volume claims |
| 19 | + |
| 20 | +You can exclude persistent volume claims (PVCs) by adding the `spec.persistentVolumes.pvc.selection.action` parameter to the `MigPlan` custom resource (CR) after the persistent volumes (PVs) have been discovered. |
| 21 | + |
| 22 | +.Prerequisites |
| 23 | + |
| 24 | +* `MigPlan` CR with discovered PVs. |
| 25 | + |
| 26 | +.Procedure |
| 27 | + |
| 28 | +* Add the `spec.persistentVolumes.pvc.selection.action` parameter to the `MigPlan` CR and set its value to `skip`: |
| 29 | ++ |
| 30 | +[source,yaml] |
| 31 | +---- |
| 32 | +apiVersion: migration.openshift.io/v1alpha1 |
| 33 | +kind: MigPlan |
| 34 | +metadata: |
| 35 | + name: <migplan> |
| 36 | + namespace: openshift-migration |
| 37 | +spec: |
| 38 | +... |
| 39 | + persistentVolumes: |
| 40 | + - capacity: 10Gi |
| 41 | + name: <pv_name> |
| 42 | + pvc: |
| 43 | +... |
| 44 | + selection: |
| 45 | + action: skip <1> |
| 46 | +---- |
| 47 | +<1> `skip` excludes the PVC from the migration plan. |
| 48 | + |
| 49 | +[id="mapping-pvcs_{context}"] |
| 50 | +== Mapping persistent volume claims |
| 51 | + |
| 52 | +You can map persistent volume claims (PVCs) by updating the `spec.persistentVolumes.pvc.name` parameter in the `MigPlan` custom resource (CR) after the persistent volumes (PVs) have been discovered. |
| 53 | + |
| 54 | +.Prerequisites |
| 55 | + |
| 56 | +* `MigPlan` CR with discovered PVs. |
| 57 | + |
| 58 | +.Procedure |
| 59 | + |
| 60 | +* Update the `spec.persistentVolumes.pvc.name` parameter in the `MigPlan` CR: |
| 61 | ++ |
| 62 | +[source,yaml] |
| 63 | +---- |
| 64 | +apiVersion: migration.openshift.io/v1alpha1 |
| 65 | +kind: MigPlan |
| 66 | +metadata: |
| 67 | + name: <migplan> |
| 68 | + namespace: openshift-migration |
| 69 | +spec: |
| 70 | +... |
| 71 | + persistentVolumes: |
| 72 | + - capacity: 10Gi |
| 73 | + name: <pv_name> |
| 74 | + pvc: |
| 75 | + name: <source_pvc>:<destination_pvc> <1> |
| 76 | +---- |
| 77 | +<1> Specify the PVC on the source cluster and the PVC on the destination cluster. If the destination PVC does not exist, it will be created. You can use this mapping to change the PVC name during migration. |
| 78 | + |
| 79 | +[id="migrating-kubernetes-objects_{context}"] |
| 80 | +== Migrating Kubernetes objects |
| 81 | + |
| 82 | +You can perform a one-time migration of Kubernetes objects that store an application's state. |
| 83 | + |
| 84 | +[NOTE] |
| 85 | +==== |
| 86 | +After migration, the `closed` parameter of the `MigPlan` CR is set to `true`. You cannot create another `MigMigration` CR for this `MigPlan` CR. |
| 87 | +==== |
| 88 | + |
| 89 | +You add Kubernetes objects to the `MigPlan` CR by using the following options: |
| 90 | + |
| 91 | +* Adding the Kubernetes objects to the `includedResources` section. |
| 92 | +* Using the `labelSelector` parameter to reference labeled Kubernetes objects. |
| 93 | + |
| 94 | +If you set both parameters, the label is used to filter the included resources, for example, to migrate `Secret` and `ConfigMap` resources with the label `app: frontend`. |
| 95 | + |
| 96 | +.Procedure |
| 97 | + |
| 98 | +* Update the `MigPlan` CR: |
| 99 | ++ |
| 100 | +[source,yaml] |
| 101 | +---- |
| 102 | +apiVersion: migration.openshift.io/v1alpha1 |
| 103 | +kind: MigPlan |
| 104 | +metadata: |
| 105 | + name: <migplan> |
| 106 | + namespace: openshift-migration |
| 107 | +spec: |
| 108 | + includedResources: <1> |
| 109 | + - kind: <Secret> |
| 110 | + group: "" |
| 111 | + - kind: <ConfigMap> |
| 112 | + group: "" |
| 113 | +... |
| 114 | + labelSelector: |
| 115 | + matchLabels: |
| 116 | + <app: frontend> <2> |
| 117 | +---- |
| 118 | +<1> Specify the `kind` and `group` of each resource. |
| 119 | +<2> Specify the label of the resources to migrate. |
0 commit comments