pvc-migrate
automates migration of PersistentVolumeClaims (PVCs) and PersistentVolumes (PVs) from OCP 3.x to OCP 4.x.
- The application on the source side needs to be quiesced before attempting migration
- PVs to be migrated need to be attached with pods, unattached PVs will not be migrated
- SSH Connection to 3.x Clusters need to be configured - Instructions
- Storage Class Selections must be made - Instructions
git clone https://github.com/konveyor/pvc-migrate && cd pvc-migrate
git checkout <version>
-
Installing Virtualenv
python3 -m pip install --user virtualenv python3 -m venv env
-
Activate Virtualenv and install requirements
source env/bin/activate pip install -r requirements.txt
-
Install selinux dependency if selinux is enabled
pip install selinux
-
To update any requirements
pip freeze &> requirements.txt
pip3 install ansible==2.9.7 --user # ansible 2.9
pip3 install kubernetes==11.0.0 --user # kubernetes module for ansible
pip3 install openshift==0.11.2 --user # openshift module for ansible
pip3 install PyYAML==5.1.1 --user # pyyaml module for python
pip3 install jmespath==0.10.0 --user # for json querying from ansible
pip3 install urllib3==1.24.2 --user # stage 1 requirement
sudo dnf install jq # jq-1.6 for json processing
sudo dnf install bind-utils
sudo dnf install dnsutils
sudo dnf install python3-libselinux
Copy source and destination cluster KUBECONFIG files authenticated with cluster-admin privileges to auth
directory
- Create
auth
directory inside of repository root:mkdir auth
- Copy source cluster kubeconfig to
auth/KUBECONFIG_SRC
- Copy destination cluster kubeconfig to
auth/KUBECONFIG_TARGET
- Copy sample config file as starting point:
cp 1_pvc_data_gen/vars/pvc-data-gen.yml.example 1_pvc_data_gen/vars/pvc-data-gen.yml
- Edit
1_pvc_data_gen/vars/pvc-data-gen.yml
, adding list of namespaces for which PV/PVC data should be migrated
namespaces_to_migrate:
- rocket-chat
- nginx-pv
The pvc-migrate
tooling is designed to work in 3 stages :
Stage 1 - Detect source cluster info (PVCs, Pods, Nodes) (Stage 1 README)
1_pvc_data_gen
This preliminary stage collects information about PVCs, PVs and Pods from the Source cluster. It creates a JSON report of collected data which will be consumed by subsequent stages.
Note: changes to the source cluster after completion of Stage 1 will not be considered by next stages. You can re-run stage 1 to refresh data as needed before running Stages 2 and 3.
Stage 2 - Migrate PVC definitions to destination cluster (Stage 2 README)
2_pvc_destination_gen
This stage translates and migrates PVC resource definitions from the source to the destination cluster.
Note: after completion of this stage, you will have PVCs created on the destination cluster which may or may not be Bound
. This is expected as some provisioners do not create PVs until PVCs are bound to pods. This stage requires users to provide Storage Class selections for the destination cluster. Please see notes on Storage Class Selection
Stage 3 - RSync PVC data to destination cluster (Stage 3 README)
3_run_rsync
This final stage launches pods to attach with the PVCs created in the previous stage.
- Each PVC is attached to its own dummy pod. The pods have
rsync
andssh
installed. - The tooling then uses
rsync
from source side to sync files to the PVs mounted on Pods in the destination side.
Note: This stage requires users to provide node info on the source cluster. Please see notes on Configuring SSH and Inventory for Stage 3
- Run steps in: 1_pvc_data_gen/README.md
- Run steps in: 2_pvc_destination_gen/README.md
- Run steps in: 3_run_rsync/README.md
- Your PV/PVC data has been migrated. You can use CAM to migrate the remaining OpenShift resources, which will connect to the PV/PVC data created by this tool.
- To run CAM in "no PVC migration" mode, modify the
MigrationController
resource on the destination cluster by swapping out the mig-controller image, then execute a migration as usual. The PVC migration steps will be skipped, but all other resources will be migrated, and workloads will connect back to the newly provisioned PVCs..
oc edit MigrationController -n openshift-migration
apiVersion: migration.openshift.io/v1alpha1
kind: MigrationController
metadata:
name: migration-controller
namespace: openshift-migration
spec:
[...]
mig_controller_image_fqin: quay.io/konveyor/mig-controller:release-1.2.2-hotfix-nopvs
[...]
- Create a MigPlan and MigMigration covering the same namespaces migrated with
pvc-migrate
.