RamenDR / ocm-ramen-samples

OCM Stateful application samples, including Ramen resources
Apache License 2.0
7 stars 66 forks source link

Add DataVolume and DataVolumeTemplate kubevirt samples #48

Closed nirs closed 8 months ago

nirs commented 8 months ago

Add new kubevirt samples:

Testing both requires kubevirt and CDI from git, since the required fixed are not available in the latest release.

I could not deploy yet latest kubevirt and CDI due to various issues, so I could not test the samples. They are based on the samples from Adam's repo: https://github.com/aglitke/ocm-kubevirt-samples

Status:

nirs commented 8 months ago

@aglitke, @mhenriks can you review the samples?

nirs commented 8 months ago

Example vm-dv run using ramen basic-test

Failover and relocate not tested yet, will test when I have a working setup with latest kubevirt and cdi.

Config

$ cat vm-dv-k8s-regional.yaml 
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: subscription/kubevirt/vm-dv-k8s-regional
branch: kubevirt-samples-test
name: vm-dv
namespace: vm-dv
dr_policy: dr-policy
pvc_label: vm

Deploy

$ basic-test/deploy -c vm-dv-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-18 19:41:51,660 INFO    [deploy] Deploying application
2024-03-18 19:41:51,660 INFO    [deploy] Deploying application 'vm-dv'
2024-03-18 19:41:52,939 INFO    [deploy] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-18 19:41:53,177 INFO    [deploy] Application running on cluster 'dr1'

Accessing the vm log

$ virtctl ssh cirros@vm --context dr1 -n vm-dv --known-hosts= -c 'head /var/log/ramen.log'
WARNING: skipping hostkey check, provide --known-hosts to fix this
Mon Mar 18 18:42:14 UTC 2024 START uptime=3.21
Mon Mar 18 18:42:24 UTC 2024 UPDATE
Mon Mar 18 18:42:34 UTC 2024 UPDATE
Mon Mar 18 18:42:44 UTC 2024 UPDATE
Mon Mar 18 18:42:54 UTC 2024 UPDATE
Mon Mar 18 18:43:04 UTC 2024 UPDATE
Mon Mar 18 18:43:14 UTC 2024 UPDATE
Mon Mar 18 18:43:24 UTC 2024 UPDATE
Mon Mar 18 18:43:34 UTC 2024 UPDATE
Mon Mar 18 18:43:44 UTC 2024 UPDATE

Enable DR

$ basic-test/enable-dr -c vm-dv-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-18 19:42:23,373 INFO    [enable-dr] Enable DR
2024-03-18 19:42:23,442 INFO    [enable-dr] Disabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-18 19:42:23,620 INFO    [enable-dr] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-18 19:42:24,078 INFO    [enable-dr] waiting for namespace vm-dv
2024-03-18 19:42:24,224 INFO    [enable-dr] Waiting until 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' reports status
2024-03-18 19:42:24,616 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' Available condition
2024-03-18 19:42:24,814 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' PeerReady condition
2024-03-18 19:42:25,021 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' first replication
2024-03-18 19:43:54,256 INFO    [enable-dr] DR enabled

Disable DR

$ basic-test/disable-dr -c vm-dv-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-18 19:45:06,523 INFO    [disable-dr] Disable DR
2024-03-18 19:45:06,592 INFO    [disable-dr] Deleting 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc'
2024-03-18 19:45:24,170 INFO    [disable-dr] Enabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-18 19:45:24,234 INFO    [disable-dr] DR was disabled

Undeploy

$ basic-test/undeploy -c vm-dv-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-18 19:45:52,641 INFO    [undeploy] Deleting application
2024-03-18 19:45:52,641 INFO    [undeploy] Undeploying application 'vm-dv'
2024-03-18 19:45:59,052 INFO    [undeploy] Application was deleted
nirs commented 8 months ago

Example vm-dvt run using ramen basic-test

Failover and relocate not tested yet, will test when I have a working setup with latest kubevirt and cdi.

Config

$ cat vm-dvt-k8s-regional.yaml 
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: subscription/kubevirt/vm-dvt-k8s-regional
branch: kubevirt-samples-test
name: vm-dvt
namespace: vm-dvt
dr_policy: dr-policy
pvc_label: vm

Deploy

$ basic-test/deploy -c vm-dvt-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-18 19:32:43,026 INFO    [deploy] Deploying application
2024-03-18 19:32:43,026 INFO    [deploy] Deploying application 'vm-dvt'
2024-03-18 19:32:44,210 INFO    [deploy] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-18 19:32:44,430 INFO    [deploy] Application running on cluster 'dr1'

Accessing the vm log

$ virtctl ssh cirros@vm --context dr1 -n vm-dvt --known-hosts= -c 'tail -f /var/log/ramen.log'WARNING: skipping hostkey check, provide --known-hosts to fix this
Mon Mar 18 18:33:08 UTC 2024 START uptime=3.21
Mon Mar 18 18:33:18 UTC 2024 UPDATE
Mon Mar 18 18:33:28 UTC 2024 UPDATE
Mon Mar 18 18:33:38 UTC 2024 UPDATE
Mon Mar 18 18:33:48 UTC 2024 UPDATE
Mon Mar 18 18:33:58 UTC 2024 UPDATE
Mon Mar 18 18:34:08 UTC 2024 UPDATE
Mon Mar 18 18:34:18 UTC 2024 UPDATE
Mon Mar 18 18:34:28 UTC 2024 UPDATE
Mon Mar 18 18:34:38 UTC 2024 UPDATE

Enable DR

$ basic-test/enable-dr -c vm-dvt-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-18 19:34:54,646 INFO    [enable-dr] Enable DR
2024-03-18 19:34:54,703 INFO    [enable-dr] Disabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-18 19:34:54,848 INFO    [enable-dr] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-18 19:34:55,254 INFO    [enable-dr] waiting for namespace vm-dvt
2024-03-18 19:34:55,417 INFO    [enable-dr] Waiting until 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' reports status
2024-03-18 19:34:55,941 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' Available condition
2024-03-18 19:34:56,183 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' PeerReady condition
2024-03-18 19:34:56,411 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' first replication
2024-03-18 19:36:25,238 INFO    [enable-dr] DR enabled

Disable DR

$ basic-test/disable-dr -c vm-dvt-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-18 19:36:50,492 INFO    [disable-dr] Disable DR
2024-03-18 19:36:50,547 INFO    [disable-dr] Deleting 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc'
2024-03-18 19:36:55,145 INFO    [disable-dr] Enabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-18 19:36:55,221 INFO    [disable-dr] DR was disabled

Undeploy

$ basic-test/undeploy -c vm-dvt-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-18 19:37:09,327 INFO    [undeploy] Deleting application
2024-03-18 19:37:09,327 INFO    [undeploy] Undeploying application 'vm-dvt'
2024-03-18 19:37:15,429 INFO    [undeploy] Application was deleted
nirs commented 8 months ago

Complete DR flow with latest kubevirt and CDI

Tested versions:

DataVolume based VM

$ cat vm-dv-k8s-regional.yaml 
---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: subscription/kubevirt/vm-dv-k8s-regional
branch: kubevirt-samples-test
name: vm-dv
namespace: vm-dv
dr_policy: dr-policy
pvc_label: vm

$ basic-test/run -c vm-dv-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-19 20:39:58,642 INFO    [deploy] Deploying application
2024-03-19 20:39:58,643 INFO    [deploy] Deploying application 'vm-dv'
2024-03-19 20:39:59,949 INFO    [deploy] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-19 20:40:00,235 INFO    [deploy] Application running on cluster 'dr1'
2024-03-19 20:40:00,382 INFO    [enable-dr] Enable DR
2024-03-19 20:40:00,455 INFO    [enable-dr] Disabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-19 20:40:00,658 INFO    [enable-dr] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-19 20:40:01,100 INFO    [enable-dr] waiting for namespace vm-dv
2024-03-19 20:40:01,258 INFO    [enable-dr] Waiting until 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' reports status
2024-03-19 20:40:01,484 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' Available condition
2024-03-19 20:40:01,708 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' PeerReady condition
2024-03-19 20:40:01,923 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' first replication
2024-03-19 20:41:31,156 INFO    [enable-dr] DR enabled
2024-03-19 20:41:31,349 INFO    [failover] Fail over application
2024-03-19 20:41:31,424 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' Available condition
2024-03-19 20:41:31,617 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' PeerReady condition
2024-03-19 20:41:31,807 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' first replication
2024-03-19 20:41:31,960 INFO    [failover] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-19 20:41:32,309 INFO    [failover] Starting failover for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' to cluster 'dr2'
2024-03-19 20:41:32,559 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' Available condition
2024-03-19 20:42:01,448 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' PeerReady condition
2024-03-19 20:45:01,237 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' first replication
2024-03-19 20:45:01,309 INFO    [failover] Application was failed over
2024-03-19 20:45:01,426 INFO    [relocate] Relocate application
2024-03-19 20:45:01,478 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' Available condition
2024-03-19 20:45:01,641 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' PeerReady condition
2024-03-19 20:45:01,802 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' first replication
2024-03-19 20:45:01,916 INFO    [relocate] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-19 20:45:02,195 INFO    [relocate] Starting relocate for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' to cluster 'dr1'
2024-03-19 20:45:02,329 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' phase 'Relocated'
2024-03-19 20:47:01,229 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' Available condition
2024-03-19 20:47:01,411 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' PeerReady condition
2024-03-19 20:47:31,237 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc' first replication
2024-03-19 20:47:31,310 INFO    [relocate] Application was relocated
2024-03-19 20:47:31,464 INFO    [disable-dr] Disable DR
2024-03-19 20:47:31,518 INFO    [disable-dr] Deleting 'drplacementcontrol.ramendr.openshift.io/vm-dv-drpc'
2024-03-19 20:48:01,226 INFO    [disable-dr] Enabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-19 20:48:01,360 INFO    [disable-dr] DR was disabled
2024-03-19 20:48:01,555 INFO    [undeploy] Deleting application
2024-03-19 20:48:01,555 INFO    [undeploy] Undeploying application 'vm-dv'
2024-03-19 20:48:07,908 INFO    [undeploy] Application was deleted

DataVolumeTemplate based VM

$ cat vm-dvt-k8s-regional.yaml 
---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: subscription/kubevirt/vm-dvt-k8s-regional
branch: kubevirt-samples-test
name: vm-dvt
namespace: vm-dvt
dr_policy: dr-policy
pvc_label: vm

$ basic-test/run -c vm-dvt-k8s-regional.yaml envs/regional-dr-kubevirt.yaml 
2024-03-19 20:55:36,971 INFO    [deploy] Deploying application
2024-03-19 20:55:36,971 INFO    [deploy] Deploying application 'vm-dvt'
2024-03-19 20:55:38,215 INFO    [deploy] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-19 20:55:38,450 INFO    [deploy] Application running on cluster 'dr1'
2024-03-19 20:55:38,606 INFO    [enable-dr] Enable DR
2024-03-19 20:55:38,672 INFO    [enable-dr] Disabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-19 20:55:38,858 INFO    [enable-dr] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-19 20:55:39,363 INFO    [enable-dr] waiting for namespace vm-dvt
2024-03-19 20:55:39,573 INFO    [enable-dr] Waiting until 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' reports status
2024-03-19 20:55:40,080 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' Available condition
2024-03-19 20:55:40,309 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' PeerReady condition
2024-03-19 20:55:40,566 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' first replication
2024-03-19 20:57:39,152 INFO    [enable-dr] DR enabled
2024-03-19 20:57:39,363 INFO    [failover] Fail over application
2024-03-19 20:57:39,437 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' Available condition
2024-03-19 20:57:39,663 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' PeerReady condition
2024-03-19 20:57:39,842 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' first replication
2024-03-19 20:57:39,964 INFO    [failover] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-19 20:57:40,228 INFO    [failover] Starting failover for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' to cluster 'dr2'
2024-03-19 20:57:40,370 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' Available condition
2024-03-19 20:58:09,254 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' PeerReady condition
2024-03-19 21:00:39,182 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' first replication
2024-03-19 21:00:39,252 INFO    [failover] Application was failed over
2024-03-19 21:00:39,368 INFO    [relocate] Relocate application
2024-03-19 21:00:39,411 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' Available condition
2024-03-19 21:00:39,564 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' PeerReady condition
2024-03-19 21:00:39,721 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' first replication
2024-03-19 21:00:39,841 INFO    [relocate] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-19 21:00:40,095 INFO    [relocate] Starting relocate for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' to cluster 'dr1'
2024-03-19 21:00:40,223 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' phase 'Relocated'
2024-03-19 21:02:39,294 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' Available condition
2024-03-19 21:02:39,462 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' PeerReady condition
2024-03-19 21:03:09,191 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc' first replication
2024-03-19 21:03:09,256 INFO    [relocate] Application was relocated
2024-03-19 21:03:09,371 INFO    [disable-dr] Disable DR
2024-03-19 21:03:09,420 INFO    [disable-dr] Deleting 'drplacementcontrol.ramendr.openshift.io/vm-dvt-drpc'
2024-03-19 21:03:39,151 INFO    [disable-dr] Enabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-19 21:03:39,246 INFO    [disable-dr] DR was disabled
2024-03-19 21:03:39,405 INFO    [undeploy] Deleting application
2024-03-19 21:03:39,405 INFO    [undeploy] Undeploying application 'vm-dvt'
2024-03-19 21:03:45,602 INFO    [undeploy] Application was deleted