forked from RamenDR/ramen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
demo environment deploys a web page accessible from a web browser or curl command. This is an attempt to create an interesting demonstration of drenv tool with an interactive use case. Example run: $ drenv start envs/demo.yaml 2023-06-14 17:40:35,327 INFO [demo] Starting environment 2023-06-14 17:40:36,008 INFO [demo1] Starting minikube cluster 2023-06-14 17:40:37,069 INFO [demo2] Starting minikube cluster 2023-06-14 17:45:00,790 INFO [demo1] Cluster started in 264.78 seconds 2023-06-14 17:45:00,790 INFO [demo1/0] Running addons/demo/start 2023-06-14 17:45:30,166 INFO [demo2] Cluster started in 293.10 seconds 2023-06-14 17:45:30,167 INFO [demo2/0] Running addons/demo/start 2023-06-14 17:46:09,158 INFO [demo1/0] addons/demo/start completed in 68.37 seconds 2023-06-14 17:46:09,158 INFO [demo1/0] Running addons/demo/test 2023-06-14 17:46:09,857 INFO [demo1/0] addons/demo/test completed in 0.70 seconds 2023-06-14 17:46:45,639 INFO [demo2/0] addons/demo/start completed in 75.47 seconds 2023-06-14 17:46:45,640 INFO [demo2/0] Running addons/demo/test 2023-06-14 17:46:45,989 INFO [demo2/0] addons/demo/test completed in 0.35 seconds 2023-06-14 17:46:45,989 INFO [demo] Environment started in 370.66 seconds Example interaction with the webpage for the context demo1: - obtain the url of the deployed web page $minikube ip --profile demo1 http://192.168.122.133 - use curl to access the web page in html format $curl http://192.168.122.133/ | grep '<h1>' <h1>Welcome to nginx!</h1> OR pass the obtained url on your favorite browser to see the welcome web page of nginx server. Updates: RamenDR#643 Signed-off-by: Shwetha K Acharya <sacharya@redhat.com>
- Loading branch information
1 parent
79607ae
commit 21aed61
Showing
7 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |