Skip to content

Commit

Permalink
BZ2015590: Fixing and reorganizing state migration
Browse files Browse the repository at this point in the history
  • Loading branch information
apinnick authored and openshift-cherrypick-robot committed Oct 25, 2021
1 parent fc1574d commit de18695
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 136 deletions.
1 change: 0 additions & 1 deletion migrating_from_ocp_3_to_4/about-mtc-3-4.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ The service catalog is deprecated in {product-title} 4. You can migrate workload
include::modules/migration-terminology.adoc[leveloffset=+1]
include::modules/migration-mtc-workflow.adoc[leveloffset=+1]
include::modules/migration-understanding-data-copy-methods.adoc[leveloffset=+1]
include::modules/migration-about-state-migration.adoc[leveloffset=+1]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ include::modules/migration-prerequisites.adoc[leveloffset=+2]
include::modules/migration-creating-registry-route-for-dim.adoc[leveloffset=+2]
include::modules/migration-configuring-proxies.adoc[leveloffset=+2]
include::modules/migration-migrating-applications-api.adoc[leveloffset=+2]
include::modules/migration-state-migration-cli.adoc[leveloffset=+2]

include::modules/migration-state-migration-cli.adoc[leveloffset=+1]
include::modules/migration-excluding-pvcs.adoc[leveloffset=+2]
include::modules/migration-mapping-pvcs.adoc[leveloffset=+2]
include::modules/migration-kubernetes-objects.adoc[leveloffset=+2]

include::modules/migration-hooks.adoc[leveloffset=+1]
include::modules/migration-writing-ansible-playbook-hook.adoc[leveloffset=+2]
Expand Down
1 change: 0 additions & 1 deletion migration_toolkit_for_containers/about-mtc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ See xref:../migration_toolkit_for_containers/advanced-migration-options-mtc.adoc
include::modules/migration-terminology.adoc[leveloffset=+1]
include::modules/migration-mtc-workflow.adoc[leveloffset=+1]
include::modules/migration-understanding-data-copy-methods.adoc[leveloffset=+1]
include::modules/migration-about-state-migration.adoc[leveloffset=+1]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ include::modules/migration-creating-registry-route-for-dim.adoc[leveloffset=+2]
include::modules/migration-configuring-proxies.adoc[leveloffset=+2]
include::modules/migration-migrating-applications-api.adoc[leveloffset=+2]
include::modules/migration-mapping-destination-namespaces-in-the-migplan-cr.adoc[leveloffset=+2]
include::modules/migration-state-migration-cli.adoc[leveloffset=+2]

include::modules/migration-state-migration-cli.adoc[leveloffset=+1]
include::modules/migration-excluding-pvcs.adoc[leveloffset=+2]
include::modules/migration-mapping-pvcs.adoc[leveloffset=+2]
include::modules/migration-kubernetes-objects.adoc[leveloffset=+2]

include::modules/migration-hooks.adoc[leveloffset=+1]
include::modules/migration-writing-ansible-playbook-hook.adoc[leveloffset=+2]
Expand Down
20 changes: 0 additions & 20 deletions modules/migration-about-state-migration.adoc

This file was deleted.

35 changes: 35 additions & 0 deletions modules/migration-excluding-pvcs.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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

[id="migration-excluding-pvcs_{context}"]
= Excluding persistent volume claims

You select persistent volume claims (PVCs) for state migration by excluding the PVCs that you do not want to migrate. You exclude PVCs by setting the `spec.persistentVolumes.pvc.selection.action` parameter of the `MigPlan` custom resource (CR) after the persistent volumes (PVs) have been discovered.

.Prerequisites

* `MigPlan` CR with discovered PVs.

.Procedure

* Add the `spec.persistentVolumes.pvc.selection.action` parameter to the `MigPlan` CR and set it to `skip`:
+
[source,yaml]
----
apiVersion: migration.openshift.io/v1alpha1
kind: MigPlan
metadata:
name: <migplan>
namespace: openshift-migration
spec:
...
persistentVolumes:
- capacity: 10Gi
name: <pv_name>
pvc:
...
selection:
action: skip
----
45 changes: 45 additions & 0 deletions modules/migration-kubernetes-objects.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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

[id="migration-kubernetes-objects_{context}"]
= Migrating Kubernetes objects

You can perform a one-time migration of Kubernetes objects that constitute an application's state.

[NOTE]
====
After migration, the `closed` parameter of the `MigPlan` CR is set to `true`. You cannot create another `MigMigration` CR for this `MigPlan` CR.
====

You add Kubernetes objects to the `MigPlan` CR by using one of the following options:

* Adding the Kubernetes objects to the `includedResources` section.
* Using the `labelSelector` parameter to reference labeled Kubernetes objects.
* Adding Kubernetes objects to the `includedResources` section and then filtering them with the `labelSelector` parameter, for example, `Secret` and `ConfigMap` resources with the label `app: frontend`.

.Procedure

* Update the `MigPlan` CR:
+
[source,yaml]
----
apiVersion: migration.openshift.io/v1alpha1
kind: MigPlan
metadata:
name: <migplan>
namespace: openshift-migration
spec:
includedResources: <1>
- kind: <Secret>
group: ""
- kind: <ConfigMap>
group: ""
...
labelSelector:
matchLabels:
<app: frontend> <2>
----
<1> Specify the `kind` and `group` of each resource.
<2> Specify the label of the resources to migrate.
36 changes: 36 additions & 0 deletions modules/migration-mapping-pvcs.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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

[id="migration-mapping-pvcs_{context}"]
= Mapping persistent volume claims

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.

You 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.

.Prerequisites

* `MigPlan` CR with discovered PVs.

.Procedure

* Update the `spec.persistentVolumes.pvc.name` parameter in the `MigPlan` CR:
+
[source,yaml]
----
apiVersion: migration.openshift.io/v1alpha1
kind: MigPlan
metadata:
name: <migplan>
namespace: openshift-migration
spec:
...
persistentVolumes:
- capacity: 10Gi
name: <pv_name>
pvc:
name: <source_pvc>:<destination_pvc> <1>
----
<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.
118 changes: 6 additions & 112 deletions modules/migration-state-migration-cli.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,123 +4,17 @@
// * migration_toolkit_for_containers/advanced-migration-options-mtc.adoc

[id="migration-state-migration-cli_{context}"]
= Migrating an application's state
= State migration

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.
You can perform repeatable, state-only migrations by using {mtc-full} ({mtc-short}) to migrate persistent volume claims (PVCs) that constitute an application's state. Persistent volume (PV) data is copied to the target cluster. The PV references are not moved. The application pods continue to run on the source cluster.

You can perform a one-time migration of Kubernetes objects that constitute an application's state.

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}.

You can use state migration to migrate namespaces within the same cluster.
You can perform a state migration between clusters or within the same cluster.

[IMPORTANT]
====
Do not use state migration to migrate namespaces between clusters. Use stage or cutover migration instead.
State migration migrates only the components that constitute an application's state. If you want to migrate an entire namespace, use stage or cutover migration.
====

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.

You can perform a one-time migration of Kubernetes objects that store application state.

[id="excluding-pvcs_{context}"]
== Excluding persistent volume claims

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.

.Prerequisites

* `MigPlan` CR with discovered PVs.

.Procedure

* Add the `spec.persistentVolumes.pvc.selection.action` parameter to the `MigPlan` CR and set its value to `skip`:
+
[source,yaml]
----
apiVersion: migration.openshift.io/v1alpha1
kind: MigPlan
metadata:
name: <migplan>
namespace: openshift-migration
spec:
...
persistentVolumes:
- capacity: 10Gi
name: <pv_name>
pvc:
...
selection:
action: skip <1>
----
<1> `skip` excludes the PVC from the migration plan.

[id="mapping-pvcs_{context}"]
== Mapping persistent volume claims

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.

.Prerequisites

* `MigPlan` CR with discovered PVs.

.Procedure

* Update the `spec.persistentVolumes.pvc.name` parameter in the `MigPlan` CR:
+
[source,yaml]
----
apiVersion: migration.openshift.io/v1alpha1
kind: MigPlan
metadata:
name: <migplan>
namespace: openshift-migration
spec:
...
persistentVolumes:
- capacity: 10Gi
name: <pv_name>
pvc:
name: <source_pvc>:<destination_pvc> <1>
----
<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.

[id="migrating-kubernetes-objects_{context}"]
== Migrating Kubernetes objects

You can perform a one-time migration of Kubernetes objects that constitute an application's state.

[NOTE]
====
After migration, the `closed` parameter of the `MigPlan` CR is set to `true`. You cannot create another `MigMigration` CR for this `MigPlan` CR.
====

You add Kubernetes objects to the `MigPlan` CR by using the following options:

* Adding the Kubernetes objects to the `includedResources` section.
* Using the `labelSelector` parameter to reference labeled Kubernetes objects.

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`.

.Procedure

* Update the `MigPlan` CR:
+
[source,yaml]
----
apiVersion: migration.openshift.io/v1alpha1
kind: MigPlan
metadata:
name: <migplan>
namespace: openshift-migration
spec:
includedResources: <1>
- kind: <Secret>
group: ""
- kind: <ConfigMap>
group: ""
...
labelSelector:
matchLabels:
<app: frontend> <2>
----
<1> Specify the `kind` and `group` of each resource.
<2> Specify the label of the resources to migrate.

0 comments on commit de18695

Please sign in to comment.