Skip to content

Commit

Permalink
Add discovered deployment-rbd dr resources
Browse files Browse the repository at this point in the history
The ManagedClusterBinding belongs to the ramen-ops namespace and
not to the application, so we keep it in the ramen-ops directory.

The rest of the resources are in the deployment-rbd directory. I'm not
sure how easy it will be to share a base kustomization with other
workloads so lets start with something simple.

Unfinished:
- failover
- relocate
- disable DR
- undeploy

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Jun 4, 2024
1 parent 16a7016 commit 28e09bc
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 0 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
26 changes: 26 additions & 0 deletions dr/discovered/deployment-rbd/drpc.yaml
Original file line number Diff line number Diff line change
@@ -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
namespace: ramen-ops
pvcSelector:
matchLabels:
appname: busybox
protectedNamespaces:
- deployment-rbd
kubeObjectProtection:
kubeObjectSelector:
matchExpressions:
- key: appname
operator: In
values:
- busybox
9 changes: 9 additions & 0 deletions dr/discovered/deployment-rbd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
namespace: ramen-ops
namePrefix: deployment-rbd-
commonLabels:
app: deployment-rbd
resources:
- drpc.yaml
- placement.yaml
- placement-decision.yaml
6 changes: 6 additions & 0 deletions dr/discovered/deployment-rbd/placement-decision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: PlacementDecision
metadata:
labels:
cluster.open-cluster-management.io/placement: deployment-rbd-placement
name: placement-decision
11 changes: 11 additions & 0 deletions dr/discovered/deployment-rbd/placement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
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
8 changes: 8 additions & 0 deletions dr/discovered/ramen-ops/binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSetBinding
metadata:
name: default
namespace: ramen-ops
spec:
clusterSet: default

0 comments on commit 28e09bc

Please sign in to comment.