diff --git a/README.md b/README.md index 0aaf962..7a5604a 100644 --- a/README.md +++ b/README.md @@ -203,3 +203,55 @@ kubectl delete -k subscription/deployment-k8s-regional-rbd ``` At this point the application is managed again by *OCM*. + +## Deploy OCM discovered application + +The sample application is configured to run cluster `dr1`. To deploy it +on cluster `dr1` and make it possible to fail over or relocate to +cluster `dr2` we need to create the namespace on both clusters: + +``` +kubectl create ns deployment-rbd --context dr1 +kubectl create ns deployment-rbd --context dr2 +``` + +To deploy the application apply the deployment-rbd workload to created +namespace on cluster `dr1`: + +``` +kubectl apply -k workloads/deployment/k8s-regional-rbd -n deployment-rbd --context dr1 +``` + +## Enabling DR for OCM discovered application + +Unlike OCM managed applications, the DR resources for all applications +are in the `ramen-ops` namespace. + +To prepare the `ramen-ops` namespaces apply the managed clusterset +binding resource. This should be done once before enabling DR for +discovered applications. + +``` +kubectl apply -f dr/discovered/ramen-ops/binding.yaml --context hub +``` + +To enable DR for the application, apply the DR resources to the hub +cluster: + +``` +kubectl apply -k dr/discovered/deploymnet-rbd --context hub +``` + +To set the application placement, patch the placement decision resource +in the `ramern-ops` namespace on the hub: + +``` +kubectl patch placementdecision deployment-rbd-placement-decision \ + --subresource status \ + --patch '{"status": {"decisions": [{"clusterName": "dr1", "reason": "dr1"}]}}' \ + --type merge \ + --namespace ramen-ops \ + --context hub +``` + +At this point *Ramen* take over and start protecting the application. diff --git a/dr/discovered/deployment-rbd/drpc.yaml b/dr/discovered/deployment-rbd/drpc.yaml new file mode 100644 index 0000000..d1ce73b --- /dev/null +++ b/dr/discovered/deployment-rbd/drpc.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: ramendr.openshift.io/v1alpha1 +kind: DRPlacementControl +metadata: + name: drpc +spec: + preferredCluster: dr1 + drPolicyRef: + name: dr-policy + placementRef: + kind: Placement + # Match kustomization namePrefix + name: deployment-rbd-placement + pvcSelector: + matchLabels: + appname: busybox + protectedNamespaces: + - deployment-rbd + kubeObjectProtection: + captureInterval: 1m + kubeObjectSelector: + matchExpressions: + - key: appname + operator: In + values: + - busybox diff --git a/dr/discovered/deployment-rbd/kustomization.yaml b/dr/discovered/deployment-rbd/kustomization.yaml new file mode 100644 index 0000000..e2b18a9 --- /dev/null +++ b/dr/discovered/deployment-rbd/kustomization.yaml @@ -0,0 +1,9 @@ +--- +namespace: ramen-ops +namePrefix: deployment-rbd- +commonLabels: + app: deployment-rbd +resources: + - drpc.yaml + - placement.yaml + - placement-decision.yaml diff --git a/dr/discovered/deployment-rbd/placement-decision.yaml b/dr/discovered/deployment-rbd/placement-decision.yaml new file mode 100644 index 0000000..aa66cd8 --- /dev/null +++ b/dr/discovered/deployment-rbd/placement-decision.yaml @@ -0,0 +1,10 @@ +apiVersion: cluster.open-cluster-management.io/v1beta1 +kind: PlacementDecision +metadata: + labels: + cluster.open-cluster-management.io/placement: deployment-rbd-placement + name: placement-decision +status: + decisions: + - clusterName: dr1 + reason: dr1 diff --git a/dr/discovered/deployment-rbd/placement.yaml b/dr/discovered/deployment-rbd/placement.yaml new file mode 100644 index 0000000..4bf27a2 --- /dev/null +++ b/dr/discovered/deployment-rbd/placement.yaml @@ -0,0 +1,19 @@ +--- +apiVersion: cluster.open-cluster-management.io/v1beta1 +kind: Placement +metadata: + annotations: + cluster.open-cluster-management.io/experimental-scheduling-disable: "true" + name: placement +spec: + clusterSets: + - default + numberOfClusters: 1 + predicates: + - requiredClusterSelector: + claimSelector: + matchExpressions: + - key: name + operator: In + values: + - dr1 diff --git a/dr/discovered/ramen-ops/binding.yaml b/dr/discovered/ramen-ops/binding.yaml new file mode 100644 index 0000000..b2d28ca --- /dev/null +++ b/dr/discovered/ramen-ops/binding.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: cluster.open-cluster-management.io/v1beta2 +kind: ManagedClusterSetBinding +metadata: + name: default + namespace: ramen-ops +spec: + clusterSet: default