Migrating a Kubernetes cluster

This tutorial is an example of how to use the Konveyor tool Crane to migrate an application (inventory) from the source Kubernetes cluster (src) to the destination cluster (dest).

Refer to the Crane Documentation for more detailed information.

Note: In addition to migrating with Crane, it is helpful to push the application to git so it can be automatically deployed to any cluster in the future. This demo includes those steps.

  1. View details of the destination and source clusters.
    > $ minikube profile list
  1. View the applications on the source cluster.
    > $ kubectl --context src get namespace
  1. View the inventory and postgres services.
    > $ kubectl --context src --namespace inventory get all
  1. View the inventory storage capacity.
    > $ kubectl --context src --namespace inventory get pvc
  1. View the front-end database content.
    > $ curl http://…
  1. Set the context to the source.
    > $ kubectx src
  1. List the application namespaces on the source.
    > $ kubectl get ns

Tip: Use the kubectx and kubectl get ns commands to change the context to the destination and verify the migrating application does not exist.

  1. Create an export folder.
    > $crane export --namespace=inventory
  1. View what was extracted from the source cluster into yaml files.
    > $ tree export

Note: These files cannot be imported into another cluster because of the existing IP addresses, timestamps, etc. which should not be pushed to git. View this data using the cat command.

When the application is migrated, this information must be updated to the new cluster.

  1. Clean the manifest files before pushing to git.
    > $ crane transform list-plugins

Note: This example uses the Kubernetes plugin. Use the crane plugin-manager list command to view available plugins to install and translate the manifest into OpenShift for example.

  1. View available options that can be used to change the manifests before pushing to git.
    > $ crane transform optionals
  1. Create a transform folder using the default Kubernetes transform options.
    > $ crane transform
  1. View the patches in the transform folder that will be applied to the original manifests to create new ones.
    > $ tree transform
  1. Open the patches and verify the data that will be changed before the transform.
    > $ cat [directory path]
  1. Clean up the manifest files using the patches and create an output folder.
    > $ crane apply
  1. View the cleaned manifest files.
    > $ tree output
  1. Copy the cleaned manifests to the git folder for future migrations.
    > $ crane apply -o
  1. Change the context to the destination.
    > $ kubectx dest
  1. Create a new namespace.
    > $ kubectl --context dest create ns inventory \ namespace/inventory created
  1. Verify the name of the pvc needed for migration.
    > $ kubectl --context src --namespace inventory get pvc
  1. Begin the migration.
    > $ crane transfer-pvc --source-context=src \ --pvc-name=postgres-pv-claim --destination-context=dest

Tip: Perform the migration while the application is running and then again during a maintenance window when the application has been shut down to only migrate over the delta between the migrations. 22. List the contents of the demo directory.

    > $ ls
  1. View the migrated files.
    > $ tree output
  1. View the argo inventory file and verify the git repoURL, namespace, and server.
    > $ cat inventory.argo.yaml
  1. Copy the file into the argo cd.
    > $ kubectl --context dest --namespace argocd apply -f inventory.argo.yaml
  1. Open the Argo CD user interface.
  2. Open the migrated application.
  3. Verify Argo picked up and provisioned all the manifests from the git repo.
  4. Click the Sync button at the top of the screen where the application can be resynced from the git repo.

Source