Chapter 9. Creating a sample application You need a sample application to test failover from the Primary managed cluster to the Secondary managed cluster and back again. Use the sample application called busybox as an example. Procedure Create a namespace or project on the Hub cluster for a busybox sample application. Note A different project name other than busybox-sample can be used if desired. Make sure when deploying the sample application via the Advanced Cluster Manager console to use the same project name as what is created in this step. Create DRPlacementControl resource DRPlacementControl is an API available after the OpenShift DR Hub Operator is installed on the Hub cluster. It is broadly an Advanced Cluster Manager PlacementRule reconciler that orchestrates placement decisions based on data availability across clusters that are part of a DRPolicy. On the Hub cluster, navigate to Installed Operators in the busybox-sample project and click on OpenShift DR Hub Operator . You should see two available APIs, DRPolicy and DRPlacementControl. Create an instance for DRPlacementControl and then go to the YAML view. Make sure the busybox-sample project is selected. Copy and save the following YAML to filename busybox-drpc.yaml after replacing <cluster1> with the correct name of your managed cluster in Advanced Cluster Manager. Copy the contents of your unique busybox-drpc.yaml file into the YAML view (completely replacing original content). Click Create on the YAML view screen. You can also create this resource using the following CLI command: Example output: Important This resource must be created in the busybox-sample namespace (or whatever namespace you created earlier). Create Placement Rule resource that defines the target clusters where resource templates can be deployed. Use placement rules to facilitate the multicluster deployment of your applications. Copy and save the following YAML to filename busybox-placementrule.yaml . Create the Placement Rule resource for the busybox-sample application. Example output: Important This resource must be created in the busybox-sample namespace (or whatever namespace you created earlier). Create sample application using RHACM console Log in to the RHACM console using your OpenShift credentials if not already logged in. Example Output: Navigate to Applications and click Create application . Select type as Subscription . Enter your application Name (for example, busybox ) and Namespace (for example, busybox-sample ). In Repository location for resources section, select Repository type Git . Enter the Git repository URL for the sample application, the github Branch and Path where the resources busybox Pod and PVC will be created. Use the sample application repository as https://github.com/RamenDR/ocm-ramen-samples where the Branch is main and Path is busybox-odr . Important Make sure that the new StorageClass ocs-storagecluster-ceph-rbdmirror is created as detailed in section [Create Mirroring StorageClass resource] before proceeding. Verify that it is created using the following command: Example output: Scroll down the form to the section Select clusters to deploy to and click Select an existing placement configuration . Select an Existing Placement Rule (for example, busybox-placement ) from the drop-down list. Click Save . When the application is created, the application details page is displayed. You can scroll down to Resource topology section. There should be Green check marks on the elements and application in the topology. Note To view more information, click on any of the topology elements and a window will appear in the right of the topology view. Verify the sample application deployment and replication. Now that the busybox application has been deployed to your preferred Cluster (specified in the DRPlacementControl) the deployment can be validated. Logon to your managed cluster where busybox was deployed by RHACM. Example output: Verify that the replication resources are also created for the busybox PVC. Example output: Verify that the busybox volume has been replicated to the alternate cluster by running the following command on both the Primary managed cluster and the Secondary managed cluster . Example output: Note Both managed clusters should have the exact same output with a new status of "states":{"replaying":2}` . 9.1. Deleting sample application You can delete the sample application busybox using the RHACM console. Procedure On the RHACM console, navigate to Applications . Search for the sample application to be deleted (for example, busybox ). Click the Action Menu (...) to the application you want to delete. Click Delete application . When Delete application is selected a new screen will appear asking if the application related resources should also be deleted. Select Remove application related resources checkbox to delete the Subscription and PlacementRule. Click Delete . This will delete the busybox application on the Primary managed cluster (or whatever cluster the application was running on). In addition to the resources deleted using the RHACM console, the DRPlacementControl must also be deleted immediately after deleting the busybox application. Logon to the OpenShift Web console for the Hub cluster and navigate to Installed Operators for the project busybox-sample . Click OpenShift DR Hub Operator and then click DRPlacementControl tab. Click the Action Menu (...) to the busybox application DRPlacementControl that you want to delete. Click Delete DRPlacementControl . Click Delete . Note This process can be used to delete any application with a DRPlacementControl resource. The DRPlacementControl resource can also be deleted in the application namespace using CLI.

Commands:
oc new-project busybox-sample
apiVersion: ramendr.openshift.io/v1alpha1 kind: DRPlacementControl metadata: labels: app: busybox-sample name: busybox-drpc spec: drPolicyRef: name: odr-policy-5m placementRef: kind: PlacementRule name: busybox-placement preferredCluster: <cluster1> pvcSelector: matchLabels: appname: busybox
oc create -f busybox-drpc.yaml -n busybox-sample
drplacementcontrol.ramendr.openshift.io/busybox-drpc created
apiVersion: apps.open-cluster-management.io/v1 kind: PlacementRule metadata: labels: app: busybox-sample name: busybox-placement spec: clusterConditions: - status: "True" type: ManagedClusterConditionAvailable clusterReplicas: 1 schedulerName: ramen
oc create -f busybox-placementrule.yaml -n busybox-sample
placementrule.apps.open-cluster-management.io/busybox-placement created
oc get route multicloud-console -n open-cluster-management -o jsonpath --template="https://{.spec.host}/multicloud/applications{'\n'}"
https://multicloud-console.apps.perf3.example.com/multicloud/applications
get storageclass | grep rbdmirror | awk '{print USD1}'
ocs-storagecluster-ceph-rbdmirror
oc get pods,pvc -n busybox-sample
NAME READY STATUS RESTARTS AGE pod/busybox 1/1 Running 0 6m NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE persistentvolumeclaim/busybox-pvc Bound pvc-a56c138a-a1a9-4465-927f-af02afbbff37 1Gi RWO ocs-storagecluster-ceph-rbd 6m
oc get volumereplication,volumereplicationgroup -n busybox-sample
NAME AGE VOLUMEREPLICATIONCLASS PVCNAME DESIREDSTATE CURRENTSTATE volumereplication.replication.storage.openshift.io/busybox-pvc 6m odf-rbd-volumereplicationclass busybox-pvc primary Primary NAME AGE volumereplicationgroup.ramendr.openshift.io/busybox-drpc 6m
oc get cephblockpool ocs-storagecluster-cephblockpool -n openshift-storage -o jsonpath='{.status.mirroringStatus.summary}{"\n"}'
{"daemon_health":"OK","health":"OK","image_health":"OK","states":{"replaying":2}}