Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce docs directory #57

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 15 additions & 195 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,204 +1,24 @@
# ocm-ramen-samples

OCM Stateful application samples, including Ramen resources.
OCM Stateful application samples, including *Ramen* resources.

## Initial setup

1. Clone this git repository to get started:

```
git clone https://github.com/RamenDR/ocm-ramen-samples.git
cd ocm-ramen-samples
```

1. Switch kubeconfig to point to the OCM Hub cluster

```
kubectl config use-context hub
```

1. Create DRClusters and DRPolicy

When using the ramen testing environment this is not needed, but if
you are using your own Kubernetes clusters you need to create the
resources.

Modify the DRCluster and DRpolicy resources in the `ramen` directory
to match the actual cluster names in your environment, and apply
the kustomization:

```
kubectl apply -k ramen
```

This creates DRPolicy and DRCluster resources in the cluster
namespace that can be viewed using:

```
kubectl get drcluster,drpolicy
```

1. Setup the common OCM channel resources on the hub:

```
kubectl apply -k channel
```

This creates a Channel resource in the `ramen-samples` namespace and
can be viewed using:

```
kubectl get channel ramen-gitops -n ramen-samples
```

## Sample applications

In the workloads directory provides samples that can be deployed on
Kubernetes and OpenShift.

- deployment - busybox deployment
- kubevirt
- vm-pvc - PVC based VM
- vm-dv - DataVolume based VM
- vm-dvt - DataVolumeTemplate based VM

## Deploying a sample application

In the example we use the busybox deployment for Kubernetes regional DR
environment using RBD storage:

subscription/deployment-k8s-regional-rbd

This application is deployed in the `deployment-rbd` namespace on the
hub and managed clusters.

You can use other overlays to deploy on other cluster types or use
different storage class. You can also create your own overlays based on
the examples.

1. Deploy an OCM application subscription on hub:

```
kubectl apply -k subscription/deployment-k8s-regional-rbd
```

This creates the required Subscription, Placement, and
ManagedClusterSetBinding resources for the deployment in the
`deployment-rbd` namespace and can be viewed using:
## Create an environment

```
kubectl get subscription,placement -n deployment-rbd
```
The easiest way to start is to use the *Ramen* testing environment
created by the *drenv* tool. See
[create environment](create-environment.md) to learn how to
quickly create a your disaster recovery playground.

1. Inspect subscribed resources from the channel created in the same
namespace on the ManagedCluster selected by the Placement.

The busybox deployment Placement `status` can be viewed on the hub
using:

```
kubectl get placement placement -n deployment-rbd
```

The Busybox deployment subscribed resources, like the pod and the PVC
can be viewed on the ManagedCluster using (example ManagedCluster
`dr1`):

```
kubectl get pod,pvc -n deployment-rbd --context dr1
```

## Undeploying a sample application

To undeploy an application delete the subscription overlay used to
deploy the application:

```
kubectl delete -k subscription/deployment-k8s-regional-rbd
```

## Enable DR for a deployed application

1. Change the Placement to be reconciled by Ramen

```
kubectl annotate placement placement -n deployment-rbd \
cluster.open-cluster-management.io/experimental-scheduling-disable=true
```

1. Deploy a DRPlacementControl resource for the OCM application on the
hub, for example:

```
kubectl apply -k dr/deployment-k8s-regional-rbd
```

This creates a DRPlacementControl resource for the busybox deployment
in the `deployment-rbd` namespace and can be viewed using:

```
kubectl get drpc -n deployment-rbd
```

At this point the placement of the application is managed by *Ramen*.

## Disable DR for a DR enabled application

1. Delete the drpc resource for the OCM application on the hub:

```
kubectl delete -k dr/deployment-k8s-regional-rbd
```

This deletes the DRPlacementControl resource for the busybox
deployment, disabling replication and removing replicated data.

> [!IMPORTANT]
> Do not delete the Placement annotation
> `cluster.open-cluster-management.io/experimental-scheduling-disable`
> to ensure that OCM will not change the placement of the application,
> which can result in data loss.

### Optional: enabling OCM scheduling for the application

It is not recommended to enable OCM scheduling on after disabling DR,
since OCM does not support moving workload storage between clusters. If
the placement point to wrong cluster, OCM will delete the application
and its storage from the current cluster, and deploy the application
with new storage on the cluster selected by the placement.

Find the current placement of the application:

```
kubectl get placementdecisions -n deployment-rbd --context hub \
-o jsonpath='{.items[0].status.decisions[0].clusterName}{"\n"}'
```

Ensure that the `Placement` predicates is pointing to the cluster where
the workload is currently placed. Here is example predicates selecting
the cluster `dr1`:
## Initial setup

```
spec:
clusterSets:
- default
numberOfClusters: 1
predicates:
- requiredClusterSelector:
claimSelector: {}
labelSelector:
matchExpressions:
- key: name
operator: In
values:
- dr1
```
Before experimenting with disaster recovery we need to configure the
clusters. See [initial setup](docs/initial-setup.md) to learn how to set
up your environment.

Change the Placement to be reconciled by OCM:
## Experiments

```
kubectl annotate placement placement -n deployment-rbd \
cluster.open-cluster-management.io/experimental-scheduling-disable-
```
After setting up your environment you can experiments with various
workloads and storage types:

At this point the application is managed again by *OCM*.
- Experiment with *OCM* managed [deployment](docs/ocm-rbd.md)
- Experiment with *OCM* managed [virtual machine](docs/ocm-kubevirt.md)
Loading