From 34bb80a4e14da3bc72234383eac1d2d1b9a38a09 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Sun, 18 Jun 2023 22:49:10 +0300 Subject: [PATCH] Add volsync self test Testing volsync without ramen is the best way to understand how it works and how we need to use it when using minikube (or vanilla k8s?). For this test we have 2 directories: - source: resources for source cluster. Applying creates the namespace, pvc and busybox deployment. - destination: resources for destination cluster. Applying creates a namespace and volsync replication destination on destination cluster. We use security context to run the busybox app as unprivileged user and set the ownership of the pvc. Without this the busybox app runs as root on minikube. It is possible to allow volsync privileged movers using an annotation on the namespace but this is great pain to use and conflicts with ocm, and there is no reason to run the busybox app as root. To test replication I did this manually: - apply source kustomization to cluster dr1 - apply destination kustomization to cluster dr2 - copy the volsync secret from cluster dr2 to cluster dr1 - export the volsync service using subctl on cluster dr2 - apply the replication source on cluster dr1 These steps should be done by the test scripts in the next version. We also need to change the way the app writes data, logging every 10 seconds is not helpful for this test, it is better that the test will write data to the pod write before creating the replication source. Signed-off-by: Nir Soffer --- .../volsync/destination/kustomization.yaml | 7 +++ .../addons/volsync/destination/namespace.yaml | 8 ++++ .../volsync/destination/replication-dst.yaml | 20 ++++++++ test/addons/volsync/source/deploy.yaml | 47 +++++++++++++++++++ test/addons/volsync/source/kustomization.yaml | 8 ++++ test/addons/volsync/source/namespace.yaml | 8 ++++ test/addons/volsync/source/pvc.yaml | 17 +++++++ .../volsync/source/replication-src.yaml | 22 +++++++++ 8 files changed, 137 insertions(+) create mode 100644 test/addons/volsync/destination/kustomization.yaml create mode 100644 test/addons/volsync/destination/namespace.yaml create mode 100644 test/addons/volsync/destination/replication-dst.yaml create mode 100644 test/addons/volsync/source/deploy.yaml create mode 100644 test/addons/volsync/source/kustomization.yaml create mode 100644 test/addons/volsync/source/namespace.yaml create mode 100644 test/addons/volsync/source/pvc.yaml create mode 100644 test/addons/volsync/source/replication-src.yaml diff --git a/test/addons/volsync/destination/kustomization.yaml b/test/addons/volsync/destination/kustomization.yaml new file mode 100644 index 0000000000..15d4377777 --- /dev/null +++ b/test/addons/volsync/destination/kustomization.yaml @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +resources: +- namespace.yaml +- replication-dst.yaml diff --git a/test/addons/volsync/destination/namespace.yaml b/test/addons/volsync/destination/namespace.yaml new file mode 100644 index 0000000000..b3403dc81f --- /dev/null +++ b/test/addons/volsync/destination/namespace.yaml @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: v1 +kind: Namespace +metadata: + name: busybox diff --git a/test/addons/volsync/destination/replication-dst.yaml b/test/addons/volsync/destination/replication-dst.yaml new file mode 100644 index 0000000000..ec418efe00 --- /dev/null +++ b/test/addons/volsync/destination/replication-dst.yaml @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: volsync.backube/v1alpha1 +kind: ReplicationDestination +metadata: + name: busybox-dst + namespace: busybox +spec: + rsyncTLS: + copyMethod: Snapshot + capacity: 1Gi + accessModes: [ReadWriteOnce] + storageClassName: csi-hostpath-sc + volumeSnapshotClassName: csi-hostpath-snapclass + moverSecurityContext: + runAsUser: 10000 + runAsGroup: 10000 + fsGroup: 10000 diff --git a/test/addons/volsync/source/deploy.yaml b/test/addons/volsync/source/deploy.yaml new file mode 100644 index 0000000000..7820a30abc --- /dev/null +++ b/test/addons/volsync/source/deploy.yaml @@ -0,0 +1,47 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + appname: busybox + name: busybox + namespace: busybox +spec: + replicas: 1 + selector: + matchLabels: + appname: busybox + template: + metadata: + labels: + appname: busybox + spec: + containers: + - image: docker.io/library/busybox:latest + imagePullPolicy: IfNotPresent + name: busybox + command: + - sh + - -c + - | + trap exit TERM + while true; do + echo $(date) | tee -a /mnt/test/outfile + sync + sleep 10 & + wait + done + volumeMounts: + - name: volume + mountPath: /mnt/test + volumes: + - name: volume + persistentVolumeClaim: + claimName: busybox-pvc + securityContext: + runAsUser: 10000 + runAsGroup: 10000 + fsGroup: 10000 diff --git a/test/addons/volsync/source/kustomization.yaml b/test/addons/volsync/source/kustomization.yaml new file mode 100644 index 0000000000..bce64ee0ac --- /dev/null +++ b/test/addons/volsync/source/kustomization.yaml @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +resources: +- namespace.yaml +- pvc.yaml +- deploy.yaml diff --git a/test/addons/volsync/source/namespace.yaml b/test/addons/volsync/source/namespace.yaml new file mode 100644 index 0000000000..b3403dc81f --- /dev/null +++ b/test/addons/volsync/source/namespace.yaml @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: v1 +kind: Namespace +metadata: + name: busybox diff --git a/test/addons/volsync/source/pvc.yaml b/test/addons/volsync/source/pvc.yaml new file mode 100644 index 0000000000..753849b27d --- /dev/null +++ b/test/addons/volsync/source/pvc.yaml @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: busybox-pvc + namespace: busybox + labels: + appname: busybox +spec: + accessModes: [ReadWriteOnce] + storageClassName: csi-hostpath-sc + resources: + requests: + storage: 1Gi diff --git a/test/addons/volsync/source/replication-src.yaml b/test/addons/volsync/source/replication-src.yaml new file mode 100644 index 0000000000..7d5596a162 --- /dev/null +++ b/test/addons/volsync/source/replication-src.yaml @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: volsync.backube/v1alpha1 +kind: ReplicationSource +metadata: + name: busybox-src + namespace: busybox +spec: + sourcePVC: busybox-pvc + trigger: + manual: replication-1 + rsyncTLS: + keySecret: volsync-rsync-tls-busybox-dst + address: volsync-rsync-tls-dst-busybox-dst.busybox.svc.clusterset.local + copyMethod: Snapshot + volumeSnapshotClassName: csi-hostpath-snapclass + moverSecurityContext: + runAsUser: 10000 + runAsGroup: 10000 + fsGroup: 10000