diff --git a/test/README.md b/test/README.md index 9bf19ccfd..28b20b910 100644 --- a/test/README.md +++ b/test/README.md @@ -545,6 +545,7 @@ simpler and faster to work with a minimal environment. - `test.yaml` - for testing `drenv` - `example.yaml` - example for experimenting with the `drenv` tool +- `demo.yaml` - interactive demo for exploring the `drenv` tool - `external.yaml` - example for using external clusters - `minio.yaml` - for testing `minio` deployment - `ocm.yaml` - for testing `ocm` deployment diff --git a/test/addons/demo/deployment.yaml b/test/addons/demo/deployment.yaml new file mode 100644 index 000000000..bf68d6db6 --- /dev/null +++ b/test/addons/demo/deployment.yaml @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: demo-deployment + labels: + app: demo +spec: + replicas: 1 + selector: + matchLabels: + app: demo + template: + metadata: + labels: + app: demo + spec: + containers: + - name: demo + image: docker.io/library/nginx:stable + ports: + - containerPort: 80 + name: demo-port diff --git a/test/addons/demo/ingress.yaml b/test/addons/demo/ingress.yaml new file mode 100644 index 000000000..a4876c756 --- /dev/null +++ b/test/addons/demo/ingress.yaml @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: demo-ingress +spec: + rules: + - http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: demo-service + port: + number: 80 diff --git a/test/addons/demo/service.yaml b/test/addons/demo/service.yaml new file mode 100644 index 000000000..0499be29b --- /dev/null +++ b/test/addons/demo/service.yaml @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 +--- +apiVersion: v1 +kind: Service +metadata: + name: demo-service + labels: + app: demo +spec: + type: NodePort + ports: + - port: 80 + name: demo-port + selector: + app: demo diff --git a/test/addons/demo/start b/test/addons/demo/start new file mode 100755 index 000000000..7d0652a32 --- /dev/null +++ b/test/addons/demo/start @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +import os +import sys + +from drenv import kubectl + +if len(sys.argv) != 2: + print(f"Usage: {sys.argv[0]} cluster") + sys.exit(1) + +os.chdir(os.path.dirname(__file__)) +cluster = sys.argv[1] + +print("Deploying demo") +kubectl.apply("--filename", "deployment.yaml", context=cluster) + +print("Creating the service") +kubectl.apply("--filename", "service.yaml", context=cluster) + +print("Waiting until deployment is rolled out") +kubectl.rollout( + "status", + "deployment", + "--timeout=120s", + context=cluster, +) + +print("Waiting until ingress controller deployment is rolled out") +kubectl.rollout( + "status", + "ingress", + "--namespace=ingress-nginx", + "--timeout=120s", + context=cluster, +) + +print("Configuring ingress") +kubectl.apply("--filename", "ingress.yaml", context=cluster) diff --git a/test/addons/demo/test b/test/addons/demo/test new file mode 100755 index 000000000..4146d9af7 --- /dev/null +++ b/test/addons/demo/test @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +import os +import sys +import subprocess + +print(sys.argv) +if len(sys.argv) != 2: + print(f"Usage: {sys.argv[0]} cluster") + sys.exit(1) + +os.chdir(os.path.dirname(__file__)) +cluster = sys.argv[1] + +print("Testing demo deployment") + +cmd = ["minikube", "ip", "--profile", cluster] +node_addr = subprocess.check_output(cmd).decode().rstrip() + +cmd = ["curl", f"http://{node_addr}/"] +out = subprocess.check_output(cmd).decode().rstrip() + +assert "Welcome to nginx!" in out diff --git a/test/envs/demo.yaml b/test/envs/demo.yaml new file mode 100644 index 000000000..83e815213 --- /dev/null +++ b/test/envs/demo.yaml @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +# Demo environment. +--- +name: demo +templates: + - name: "demo-cluster" + driver: kvm2 + container_runtime: containerd + network: default + addons: + - ingress + workers: + - addons: + - name: demo +profiles: + - name: demo1 + template: demo-cluster + - name: demo2 + template: demo-cluster