Chapter 11. Creating a sample application
In order to test failover
from the Primary managed cluster to the Secondary managed cluster and back again we need a simple application. Use the sample application called busybox
as an example.
Procedure
Create a namespace or project on the Hub cluster for a
busybox
sample application.$ oc new-project busybox-sample
NoteA 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.apiVersion: ramendr.openshift.io/v1alpha1 kind: DRPlacementControl metadata: labels: app: busybox-sample name: busybox-drpc spec: drPolicyRef: name: odr-policy placementRef: kind: PlacementRule name: busybox-placement preferredCluster: <cluster1> pvcSelector: matchLabels: appname: busybox
-
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:
$ oc create -f busybox-drpc.yaml -n busybox-sample
Example output:
drplacementcontrol.ramendr.openshift.io/busybox-drpc created
ImportantThis resource must be created in the
busybox-sample
namespace (or whatever namespace you created earlier).
-
On the Hub cluster, navigate to Installed Operators in the
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
.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
Create the Placement Rule resource for the
busybox-sample
application.$ oc create -f busybox-placementrule.yaml -n busybox-sample
Example output:
placementrule.apps.open-cluster-management.io/busybox-placement created
ImportantThis 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.
$ oc get route multicloud-console -n open-cluster-management -o jsonpath --template="https://{.spec.host}/multicloud/applications{'\n'}"
Example Output:
https://multicloud-console.apps.perf3.example.com/multicloud/applications
- 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 ismain
and Path isbusybox-odr-metro
.- 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.
On the follow-on screen scroll to the bottom. You should see that there are all Green checkmarks on the application topology.
NoteTo get more information, click on any of the topology elements and a window will appear on the right of the topology view.
Validating 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.Login to your managed cluster where
busybox
was deployed by RHACM.$ oc get pods,pvc -n busybox-sample
Example output:
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
Verify that the replication resources are also created for the
busybox
PVC.$ oc get volumereplicationgroup -n busybox-sample
Example output:
NAME AGE volumereplicationgroup.ramendr.openshift.io/busybox-drpc 6m
11.1. Deleting sample application
You can delete the sample application busybox
using the RHACM console.
The instructions to delete the sample application should not be executed until the failover and failback (relocate) testing is completed and the application is ready to be removed from RHACM and the managed clusters.
Procedure
- On the RHACM console, navigate to Applications.
-
Search for the sample application to be deleted (for example,
busybox
). - Click the Action Menu (⋮) next 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 thebusybox
application.-
Login 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 (⋮) next to the
busybox
application DRPlacementControl that you want to delete. - Click Delete DRPlacementControl.
- Click Delete.
-
Login to the OpenShift Web console for the Hub cluster and navigate to Installed Operators for the project
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.