Migrating Cloud Pak for Data projects and supported Kubernetes resources for Portworx asynchronous disaster recovery

Migrate Cloud Pak for Data projects and supported Kubernetes resources to the destination cluster for Portworx asynchronous disaster recovery.

Procedure

  1. Create a Cloud Pak for Data instance (tenant) schedule policy.

    Replace <interval> with the amount of time, in minutes, that you want the migration to occur. For example, if you want the migration to occur every hour, set <interval> to 60.

    Note: Do not set the schedule policy to an interval that is less than 60 minutes.
    cat << EOF | oc apply -f -
    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: SchedulePolicy
    metadata:
      name: cpd-tenant-policy
    policy:
      interval:
        intervalMinutes: <interval>
    EOF
  2. Create the pre-backup rule for the Cloud Pak for Data tenant operators project (namespace):
    cat << EOF | oc apply -f -
    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: Rule
    metadata:
      name: cpd-tenant-prebackup
      namespace: ${PROJECT_CPD_INST_OPERATORS}
    rules:
      - actions:
          - runInSinglePod: true
            type: command
            value: /usr/bin/bash -c "/cpdbr-scripts/cpdbr/cpdbr-pre-backup.sh ${PROJECT_CPD_INST_OPERATORS}"
        podSelector:
          component: cpdbr-tenant
          icpdsupport/addOnId: cpdbr
          icpdsupport/app: br-service
    EOF
  3. Create the pre-backup rule for the Cloud Pak for Data tenant operands project:
    cat << EOF | oc apply -f -
    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: Rule
    metadata:
      name: cpd-tenant-prebackup
      namespace: ${PROJECT_CPD_INST_OPERANDS}
    rules:
      - actions:
          - runInSinglePod: true
            type: command
            value: /usr/bin/bash -c "pwd"
        podSelector:
          component: zen-audit
          icpdsupport/addOnId: zen-lite
          icpdsupport/app: framework
    EOF
  4. Create the pre-backup rule for the Portworx admin project:
    cat << EOF | oc apply -f -
    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: Rule
    metadata:
      name: cpd-tenant-prebackup
      namespace: ${PX_ADMIN_NS}
    rules:
    - actions:
      - runInSinglePod: true
        type: command
        value: /usr/bin/bash -c "echo cpd-tenant-prebackup"
      podSelector:
        name: stork
    EOF
  5. Create the post-backup rule for the Cloud Pak for Data tenant operators project:
    cat << EOF | oc apply -f -
    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: Rule
    metadata:
      name: cpd-tenant-postbackup
      namespace: ${PROJECT_CPD_INST_OPERATORS}
    rules:
      - actions:
          - runInSinglePod: true
            type: command
            value: /usr/bin/bash -c "/cpdbr-scripts/cpdbr/cpdbr-post-backup.sh ${PROJECT_CPD_INST_OPERATORS}"
        podSelector:
          component: cpdbr-tenant
          icpdsupport/addOnId: cpdbr
          icpdsupport/app: br-service
    EOF
  6. Create the post-backup rule for the Cloud Pak for Data tenant operands project:
    cat << EOF | oc apply -f -
    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: Rule
    metadata:
      name: cpd-tenant-postbackup
      namespace: ${PROJECT_CPD_INST_OPERANDS}
    rules:
      - actions:
          - runInSinglePod: true
            type: command
            value: /usr/bin/bash -c "pwd"
        podSelector:
          component: zen-audit
          icpdsupport/addOnId: zen-lite
          icpdsupport/app: framework
    EOF
  7. Create the post-backup rule for the Portworx admin project:
    cat << EOF | oc apply -f -
    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: Rule
    metadata:
      name: cpd-tenant-postbackup
      namespace: ${PX_ADMIN_NS}
    rules:
    - actions:
      - runInSinglePod: true
        type: command
        value: /usr/bin/bash -c "echo cpd-tenant-postbackup"
      podSelector:
        name: stork
    EOF
  8. Create the tenant migration schedule:
    cat << EOF | oc apply -f -
    apiVersion: stork.libopenstorage.org/v1alpha1
    kind: MigrationSchedule
    metadata:
      name: cpd-tenant-migrationschedule
      namespace: ${PX_ADMIN_NS}
    spec:
      autoSuspend: false
      schedulePolicyName: cpd-tenant-policy
      suspend: true
      template:
        spec:
          adminClusterPair: ""
          clusterPair: mig-clusterpair
          includeNetworkPolicyWithCIDR: null
          includeOptionalResourceTypes: null
          includeResources: true
          includeVolumes: true
          namespaces:
            - ${PROJECT_CPD_INST_OPERATORS}
            - ${PROJECT_CPD_INST_OPERANDS}
          postExecRule: cpd-tenant-postbackup
          preExecRule: cpd-tenant-prebackup
          purgeDeletedResources: null
          selectors:
            icpdsupport/cpdbr: "true"
          skipDeletedNamespaces: null
          skipServiceUpdate: null
          startApplications: false
    EOF
  9. To pause the migration schedule, run the following command:
    storkctl suspend migrationschedule cpd-tenant-migrationschedule -n ${PX_ADMIN_NS}
  10. To resume the migration schedule, run the following command:
    storkctl resume migrationschedule cpd-tenant-migrationschedule -n ${PX_ADMIN_NS}
  11. To check the migration, run the following command:
    storkctl get migration -n ${PX_ADMIN_NS}
    The command returns output like in the following example:
    NAME                                                CLUSTERPAIR       STAGE   STATUS       VOLUMES   RESOURCES   CREATED               ELAPSED                           TOTAL BYTES TRANSFERRED
    cpd-tenant-migrationschedule-interval-<timestamp>   mig-clusterpair   Final   Successful   24/24     50/50       22 Sep 23 11:26 UTC   Volumes (3m15s) Resources (54s)   1242890240
  12. To view events that are logged against the migration, run the following command:
    kubectl describe migration -n ${PX_ADMIN_NS}

Results

After a successful migration, only the Cloud Pak for Data deployment definition was moved to the target cluster, and no pods are created.

Tip: For a list of Kubernetes resources that are migrated, see Supported Kubernetes resources in the Portworx documentation.