Creating and managing Disaster Recovery Policy for a TrueCopy pair or a Universal Replicator pair

Replication Plug-in for Containers Installation and User Guide

Version
3.18.x
Audience
anonymous
Part Number
MK-92ADPTR155-10
ft:lastEdition
2026-07-07

You can define a DR policy for an application, a namespace, or PVCs.

  1. Create a Disaster Recovery (DR) policy for a TrueCopy pair or Universal Replicator pair on the primary site. Enter:
    apiVersion: hspc.hitachi.com/v1alpha2
    kind: DRPolicy
    metadata:
      name: sample-app-drpolicy
    spec:
      pvcSelector:
        # matchWorkloadLabels:
        #   - app: sample_app
        matchNamespaces:
          - demo-db
          - demo-app
        # matchPvcs:
        #   - demo-db-pvc
        #   - demo-server-pvc
        #   - demo-ui-pvc
      drTarget:
      clusterName: site-62       # (1) 
      replicationMode: sync      # (2)
      consistencyRequired: true  # (3) 
      consistencyGroupName: Name # (4) 
      #primaryJournalId: 12      # (5)
      #secondaryJournalId: 2     # (6)
      #desiredState: pair
      readyOrderOfPvcByNamespace:
        - demo-db
        - demo-app
      # readyOrderOfPvcByLabel:
      #   - app: sample_app
      # replicationAttribute: primary
      #actionsAfterStorageFailover:
     unprotectedPvcs:
      - name: <pvc-1>          # (7)
        deleteSvol: true       # (8)
      actionsOnTarget:
        - scriptType: shell
          configMapRef:
            name: post-failover-script
            key: run.sh
    Legend:
    • (1) Specify the secondary site name where the replication must be performed.
    • (2) Specify the replication mode: sync for TrueCopy pair and async for Universal Replicator pair.
    • (3) Specify true to support consistency group.
    • (4) Specify the consistency group name if you have set the consistencyRequired parameter to true.
    • (5) Specify the primary journal ID for the Universal Replicator pair.
    • (6) Specify the secondary journal ID for the Universal Replicator pair.
    • (7) Specify the PVC name to exclude from DR protection. This setting also deletes the associated replication pair and VolumeReplication custom resource.
    • (8) Set deleteSvol to true to delete the secondary volume (S-VOL) associated with the excluded PVC from the secondary cluster.
      Note: The DR operator deletes the excluded PVCs only when desiredState is set to pair, split, or failback.

      To re-create the replication pair based on the protection rules (matchWorkloadLabels, matchNamespaces, or matchPvcs), remove the PVC from the unprotectedPvcs list and set desiredState to pair.

    Note:
    • For Universal Replicator pair, verify that the replicationMode is set to async.
    • By default, the desiredState is set to pair.
    • If you are creating a DR policy for namespaces, then create similar namespaces in the secondary site.
    • If you are creating a DR policy for PVCs, then create the corresponding namespaces in the secondary site.
  2. Apply the DR policy. Enter:
    kubectl apply -f test.yaml
    Note: The DR policy will be applied on the secondary site by default.

    To exclude more PVCs from DR protection, edit the DR policy. In the unprotectedPvcs section, add the PVC names, and set deleteSvol to true.

  3. Verify if the DR policy is applied on both the primary and secondary sites. Enter:
    kubectl get drpolicy
    Sample output:
    kubectl get drpolicy
    NAME                  SOURCE_CLUSTER   TARGET_CLUSTER   REPLICATION_TYPE   DESIRED_STATE   STATUS    CTG_ID   AGE
    sample-app-drpolicy   site-61          site-62          sync               pair            Healthy   21       6m9s
  4. Verify the replication status of the PVCs. Enter:
    kubectl get replication -A
    Sample output:
    kubectl get replication -A
    NAMESPACE          NAME                                   STATUS    DESIREDSTATE   OPERATION   AGE
    namespace1      replication--namespace1-test--pvc-name1   Pair   pair       none        1m
    namespace2      replication--namespace2-test--pvc-name2   Pair   pair       none        1m