|
1 | 1 | # ocm-ramen-samples
|
2 | 2 |
|
3 |
| -OCM Stateful application samples, including Ramen resources. |
| 3 | +OCM Stateful application samples, including *Ramen* resources. |
4 | 4 |
|
5 |
| -## Initial setup |
6 |
| - |
7 |
| -1. Clone this git repository to get started: |
8 |
| - |
9 |
| - ``` |
10 |
| - git clone https://github.com/RamenDR/ocm-ramen-samples.git |
11 |
| - cd ocm-ramen-samples |
12 |
| - ``` |
13 |
| - |
14 |
| -1. Switch kubeconfig to point to the OCM Hub cluster |
15 |
| - |
16 |
| - ``` |
17 |
| - kubectl config use-context hub |
18 |
| - ``` |
19 |
| - |
20 |
| -1. Create DRClusters and DRPolicy |
21 |
| - |
22 |
| - When using the ramen testing environment this is not needed, but if |
23 |
| - you are using your own Kubernetes clusters you need to create the |
24 |
| - resources. |
25 |
| - |
26 |
| - Modify the DRCluster and DRpolicy resources in the `ramen` directory |
27 |
| - to match the actual cluster names in your environment, and apply |
28 |
| - the kustomization: |
29 |
| - |
30 |
| - ``` |
31 |
| - kubectl apply -k ramen |
32 |
| - ``` |
33 |
| - |
34 |
| - This creates DRPolicy and DRCluster resources in the cluster |
35 |
| - namespace that can be viewed using: |
36 |
| - |
37 |
| - ``` |
38 |
| - kubectl get drcluster,drpolicy |
39 |
| - ``` |
40 |
| - |
41 |
| -1. Setup the common OCM channel resources on the hub: |
42 |
| - |
43 |
| - ``` |
44 |
| - kubectl apply -k channel |
45 |
| - ``` |
46 |
| - |
47 |
| - This creates a Channel resource in the `ramen-samples` namespace and |
48 |
| - can be viewed using: |
49 |
| - |
50 |
| - ``` |
51 |
| - kubectl get channel ramen-gitops -n ramen-samples |
52 |
| - ``` |
53 |
| - |
54 |
| -## Sample applications |
55 |
| - |
56 |
| -In the workloads directory provides samples that can be deployed on |
57 |
| -Kubernetes and OpenShift. |
58 |
| - |
59 |
| -- deployment - busybox deployment |
60 |
| -- kubevirt |
61 |
| - - vm-pvc - PVC based VM |
62 |
| - - vm-dv - DataVolume based VM |
63 |
| - - vm-dvt - DataVolumeTemplate based VM |
64 |
| - |
65 |
| -## Deploying a sample application |
66 |
| - |
67 |
| -In the example we use the busybox deployment for Kubernetes regional DR |
68 |
| -environment using RBD storage: |
69 |
| - |
70 |
| - subscription/deployment-k8s-regional-rbd |
71 |
| - |
72 |
| -This application is deployed in the `deployment-rbd` namespace on the |
73 |
| -hub and managed clusters. |
74 |
| - |
75 |
| -You can use other overlays to deploy on other cluster types or use |
76 |
| -different storage class. You can also create your own overlays based on |
77 |
| -the examples. |
78 |
| - |
79 |
| -1. Deploy an OCM application subscription on hub: |
| 5 | +## Create an environment |
80 | 6 |
|
81 |
| - ``` |
82 |
| - kubectl apply -k subscription/deployment-k8s-regional-rbd |
83 |
| - ``` |
| 7 | +The easiest way to start is to use the *Ramen* testing environment |
| 8 | +created by the *drenv* tool. See |
| 9 | +[create environment](create-environment.md) to learn how to |
| 10 | +quickly create a your disaster recovery playground. |
84 | 11 |
|
85 |
| - This creates the required Subscription, Placement, and |
86 |
| - ManagedClusterSetBinding resources for the deployment in the |
87 |
| - `deployment-rbd` namespace and can be viewed using: |
88 |
| - |
89 |
| - ``` |
90 |
| - kubectl get subscription,placement -n deployment-rbd |
91 |
| - ``` |
92 |
| - |
93 |
| -1. Inspect subscribed resources from the channel created in the same |
94 |
| - namespace on the ManagedCluster selected by the Placement. |
95 |
| - |
96 |
| - The busybox deployment Placement `status` can be viewed on the hub |
97 |
| - using: |
98 |
| - |
99 |
| - ``` |
100 |
| - kubectl get placement placement -n deployment-rbd |
101 |
| - ``` |
102 |
| - |
103 |
| - The Busybox deployment subscribed resources, like the pod and the PVC |
104 |
| - can be viewed on the ManagedCluster using (example ManagedCluster |
105 |
| - `dr1`): |
106 |
| - |
107 |
| - ``` |
108 |
| - kubectl get pod,pvc -n deployment-rbd --context dr1 |
109 |
| - ``` |
110 |
| - |
111 |
| -## Undeploying a sample application |
112 |
| - |
113 |
| -To undeploy an application delete the subscription overlay used to |
114 |
| -deploy the application: |
115 |
| - |
116 |
| -``` |
117 |
| -kubectl delete -k subscription/deployment-k8s-regional-rbd |
118 |
| -``` |
119 |
| - |
120 |
| -## Enable DR for a deployed application |
121 |
| - |
122 |
| -1. Change the Placement to be reconciled by Ramen |
123 |
| - |
124 |
| - ``` |
125 |
| - kubectl annotate placement placement -n deployment-rbd \ |
126 |
| - cluster.open-cluster-management.io/experimental-scheduling-disable=true |
127 |
| - ``` |
128 |
| - |
129 |
| -1. Deploy a DRPlacementControl resource for the OCM application on the |
130 |
| - hub, for example: |
131 |
| - |
132 |
| - ``` |
133 |
| - kubectl apply -k dr/deployment-k8s-regional-rbd |
134 |
| - ``` |
135 |
| - |
136 |
| - This creates a DRPlacementControl resource for the busybox deployment |
137 |
| - in the `deployment-rbd` namespace and can be viewed using: |
138 |
| - |
139 |
| - ``` |
140 |
| - kubectl get drpc -n deployment-rbd |
141 |
| - ``` |
142 |
| - |
143 |
| - At this point the placement of the application is managed by *Ramen*. |
144 |
| - |
145 |
| -## Disable DR for a DR enabled application |
146 |
| - |
147 |
| -1. Ensure the placement is pointing to the cluster where the workload is |
148 |
| - currently placed to avoid data loss if OCM moves the application to |
149 |
| - another cluster. |
150 |
| - |
151 |
| - The sample `placement` does not require any change, but if you are |
152 |
| - using an application created by OpenShift Console, you may need to |
153 |
| - change the cluster name in the placement. |
154 |
| - |
155 |
| -1. Delete the drpc resource for the OCM application on the hub: |
156 |
| - |
157 |
| - ``` |
158 |
| - kubectl delete -k dr/deployment-k8s-regional-rbd |
159 |
| - ``` |
| 12 | +## Initial setup |
160 | 13 |
|
161 |
| - This deletes the DRPlacementControl resource for the busybox |
162 |
| - deployment, disabling replication and removing replicated data. |
| 14 | +Before experimenting with disaster recovery we need to configure the |
| 15 | +clusters. See [initial setup](docs/initial-setup.md) to learn how to set |
| 16 | +up your environment. |
163 | 17 |
|
164 |
| -1. Change the Placement to be reconciled by OCM |
| 18 | +## Experiments |
165 | 19 |
|
166 |
| - ``` |
167 |
| - kubectl annotate placement placement -n deployment-rbd \ |
168 |
| - cluster.open-cluster-management.io/experimental-scheduling-disable- |
169 |
| - ``` |
| 20 | +After setting up your environment you can experiments with various |
| 21 | +workloads and storage types: |
170 | 22 |
|
171 |
| - At this point the application is managed again by *OCM*. |
| 23 | +- Experiment with *OCM* managed [deployment](docs/ocm-rbd.md) |
| 24 | +- Experiment with *OCM* managed [virtual machine](docs/ocm-kubevirt.md) |
0 commit comments