From 681c3fba44402de057ce27cb0f5d0bede2c61946 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Fri, 2 Jun 2023 00:39:27 +0300 Subject: [PATCH] Add velero self test Work in progress: - backup succeeds, and files are stored in the bucket. - restore complete successfully - but has warning: Warnings: Velero: Cluster: Namespaces: nginx-example: could not restore, Endpoints "my-nginx" already exists. Warning: the in-cluster version is different than the backed-up version. After the restore, the nginx-deployment is missing: $ kubectl get all -n nginx-example NAME READY STATUS RESTARTS AGE pod/nginx-deployment-7c89967545-n2fdb 1/1 Running 0 2m40s pod/nginx-deployment-7c89967545-nmznz 1/1 Running 0 2m40s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/my-nginx LoadBalancer 10.103.20.188 80:32439/TCP 2m40s NAME DESIRED CURRENT READY AGE replicaset.apps/nginx-deployment-7c89967545 2 2 2 2m40s - Need to detect and log the warning after the restore. I could not find away to get the restore name programmatically for querying the restore. - Need to cleanup up after the test - delete the deployment and the backup. - Code for using velero is too complicated for a test, I think we need a simple `drenv.velero` helper. Signed-off-by: Nir Soffer --- test/addons/velero/credentials.conf | 3 ++ test/addons/velero/nginx.yaml | 48 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/addons/velero/credentials.conf create mode 100644 test/addons/velero/nginx.yaml diff --git a/test/addons/velero/credentials.conf b/test/addons/velero/credentials.conf new file mode 100644 index 0000000000..735edc7c17 --- /dev/null +++ b/test/addons/velero/credentials.conf @@ -0,0 +1,3 @@ +[default] +aws_access_key_id = minio +aws_secret_access_key = minio123 diff --git a/test/addons/velero/nginx.yaml b/test/addons/velero/nginx.yaml new file mode 100644 index 0000000000..3ef39cd146 --- /dev/null +++ b/test/addons/velero/nginx.yaml @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: 2017 the Velero contributors +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: v1 +kind: Namespace +metadata: + name: nginx-example + labels: + app: nginx + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + namespace: nginx-example +spec: + replicas: 2 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - image: nginx:1.17.6 + name: nginx + ports: + - containerPort: 80 + +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: nginx + name: my-nginx + namespace: nginx-example +spec: + ports: + - port: 80 + targetPort: 80 + selector: + app: nginx + type: LoadBalancer