Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
scrgiorgio committed May 30, 2024
1 parent b08b575 commit 5807482
Show file tree
Hide file tree
Showing 21 changed files with 308 additions and 114 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ build
.vscode
**/*.npz
**/*.npy
deploy/.env
deploy/inventory.ini



Expand Down
96 changes: 0 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,102 +78,6 @@ jupyter trust notebooks/test-panel.ipynb



## Docker Compose

Create an `.env` file with a token:

```bash
cat <<EOF > .env
NSDF_TOKEN=whatever-but-secure
EOF
```

```bash
# sudo docker compose up chess1_service
# sudo docker compose up chess2_service
# sudo docker compose up jupyterlab_service

sudo docker compose up
```

You can check if it's working going to any of the URL:

- http://localhost/chess1
- http://localhost/chess2
- http://localhost/lab



## Ansible

Create an `.env` file with a token:

```bash
cat <<EOF > .env
NSDF_TOKEN=whatever-but-secure
EOF
```

Create an ``./inventory.ini` file. For example

```ini
[all:vars]
ansible_ssh_connection=ssh
ansible_ssh_user=root
ansible_ssh_private_key_file=~/.ssh/id_rsa

[my_vps]
127.0.0.1
```

Run the ansible playbooks:

```bash

# this is needed for WSL2
export ANSIBLE_CONFIG=${PWD}/ansible.cfg

# check connectivity
ansible all -m ping

ansible-playbook ./ansible/setup.yml # --tags "restart"

# you can run it later...
# OPTIONAL, you can even use without precaching (cached=arco will cache blocks on demand)
ansible-playbook ./ansible/precache.yml

# check docker ps
ansible --become-user root --become all -m shell -a 'cd /root/deploy && docker compose ps'
ansible --become-user root --become all -m shell -a 'df -h' | grep "/dev/sda1"


# check load balancer
VPS=$(ansible hetzner --list-hosts | tail -n +2)
for it in ${VPS} ; do
echo ${it}
echo " HEALTH" $(curl -L -s -o /dev/null -w "%{http_code}" http://$it/health)
echo " LAB " $(curl -L -s -o /dev/null -w "%{http_code}" http://$it/lab)
echo " CHESS1" $(curl -L -s -o /dev/null -w "%{http_code}" http://$it/chess1)
echo " CHESS2" $(curl -L -s -o /dev/null -w "%{http_code}" http://$it/chess2)
done



# ansible-playbook ./ansible/benchmark.yml --verbose
# ansible-playbook ./ansible/run.yml --tags "stop"

# Clean up notebooks
for it in $(find ./notebooks/*.ipynb) ; do
jupyter nbconvert --clear-output --inplace ${it}
jupyter trust ${it}
done

# --tags "configuration,packages"
# --limit=<hostname>
# -l <group-name>
# -vvv

```

## Volume Rendering

Expand Down
97 changes: 97 additions & 0 deletions deploy/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Instructions

## Docker Compose

```bash

cd deploy

# Create an `.env` file with a token:
cat <<EOF > .env
NSDF_TOKEN=whatever-but-secure
EOF

# this is needed for WSL2
export ANSIBLE_CONFIG=${PWD}/ansible.cfg

sudo docker compose up chess1_service
sudo docker compose up chess2_service
sudo docker compose up jupyter_service
sudo docker compose up
```

You can check if it's working going to any of the URL:

- http://localhost/
- http://localhost/chess1
- http://localhost/chess2
- http://localhost/lab

## Ansible

```bash

cd deploy

# Create an `.env` file with a token:
cat <<EOF > .env
NSDF_TOKEN=whatever-but-secure
EOF

# only needed for ansible (!)
cat <<EOF > ./inventory.ini
[all:vars]
ansible_ssh_connection=ssh
ansible_ssh_user=root
ansible_ssh_private_key_file=~/.ssh/id_rsa
[my_vps]
127.0.0.1
EOF

# this is needed for WSL2
export ANSIBLE_CONFIG=${PWD}/ansible.cfg

# check connectivity
ansible all -m ping

# ansible-playbook options
# --tags "configuration,packages"
# --limit=<hostname>
# -l <group-name>
# -vvv

ansible-playbook ./setup.yml # --tags "restart"

ansible-playbook ./benchmark.yml --verbose

# (OPTIONAL) Clean up notebooks
for it in $(find ./notebooks/*.ipynb) ; do
jupyter nbconvert --clear-output --inplace ${it}
jupyter trust ${it}
done

ansible-playbook ./run.yml

# if you need to restart
ansible-playbook ./run.yml --tags restart -l 5.161.228.121

# if you need to check all services

# you can run it later...
# OPTIONAL, you can even use without precaching (cached=arco will cache blocks on demand)
ansible-playbook ./precache.yml

# check docker ps
ansible --become-user root --become all -m shell -a 'cd /root/deploy && docker compose ps'
ansible --become-user root --become all -m shell -a 'df -h' | grep "/dev/sda1"
```

if you want to debug:

```
ssh -i <identity> root@vps-ip
cd deploy
docker ps
docker exec -it <service> bash
```
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions docker-compose.yml → deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ services:
retries: 5

# Jupyter Lab
jupyterlab_service:
jupyter_service:
restart: unless-stopped
image: docker.io/nsdf/openvisuspy:1.0.64
ports:
Expand All @@ -52,9 +52,9 @@ services:
volumes:
- /mnt/data:/mnt/data
- ./notebooks:/home/notebooks
command: jupyter lab --allow-root --notebook-dir="/home/notebooks" --port 8888 --NotebookApp.token='${NSDF_TOKEN}' --NotebookApp.allow_origin='*' --ip '0.0.0.0'
command: jupyter lab --allow-root --notebook-dir="/home/notebooks" --port 8888 --NotebookApp.token='${NSDF_TOKEN}' --NotebookApp.allow_origin='*' --ip '0.0.0.0' --NotebookApp.base_url=jupyter
healthcheck:
test: curl --fail http://localhost:8888 || exit 1
test: curl --fail http://localhost:8888/jupyter || exit 1
interval: 10s
timeout: 5s
retries: 5
Expand All @@ -68,12 +68,13 @@ services:
volumes:
- /var/log/nginx:/var/log/nginx
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- ./html:/usr/share/nginx/html
depends_on:
chess1_service:
condition: service_healthy
chess2_service:
condition: service_healthy
jupyterlab_service:
jupyter_service:
condition: service_healthy

# autoheal_service
Expand Down
99 changes: 99 additions & 0 deletions deploy/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!DOCTYPE html>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>NSDF@CHESS - 2024 CHESS User Meeting </title>
<link rel="stylesheet" media="all" href="./resources/style2.css">
<link rel="stylesheet" media="all" href="./resources/style1.css">
</head>

<body class="is-ultimenu-canvas is-ultimenu-canvas--hover path-node page-node-type-enhanced-section">

<div class="dialog-off-canvas-main-canvas" data-off-canvas-main-canvas="">
<header role="banner">
<div class="region region-header">
<div class="views-element-container block block-views block-views-blockpage-content-block-banner-image"
id="block-block-banner-image">
<div block="block-block-banner-image">
<div
class="banner-image view view-page-content view-id-page_content view-display-id-block_banner_image js-view-dom-id-6008bf085842f9014c210080636d5015cdbed8b3b0123194f9e207367b135c52">
<div class="view-content">
<div class="views-row"> <img loading="lazy" src="./resources/header.jpg" width="5000" height="1667"
alt="user meeting header" style="margin-top: -17.031px;">
<div class="container-fluid">
<h1>NSDF@CHESS - 2024 CHESS User Meeting</h1>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</header>
</div>

<div style="text-align: center;">

<div class="row" >
<div style="color: rgba(8, 116, 80, 0.815); font-weight: bold;">
JUNE 4TH and 5TH, 2024 AT CORNELL UNIVERSITY
<br>
<A href="http://nationalsciencedatafabric.org">

<img src="resources/logo.png" width="200" /><img src="resources/chess.png" width="200" /><br>
National Science Data Fabric<br>
</A>
<br>
</div>

<div class="row" style="background-color: whitesmoke ;">
<H1>NSDF Dashboards v2</H1>
<img src="resources/dashboards-v2.png" width="400" style="filter:drop-shadow(5px 5px 5px #222);"/><br><br>
<a
href="https://chess-tutorial.nationalsciencedatafabric.org/chess2">https://chess-tutorial.nationalsciencedatafabric.org/chess2</a><br>
<br>
</div>


<div class="row" style="background-color: rgb(224, 224, 224);">
<H1>NSDF Dashboards v1</H1>
<img src="resources/dashboards-v1.png" width="400" style="filter:drop-shadow(5px 5px 5px #222);"/><br><br>
<a
href="https://chess-tutorial.nationalsciencedatafabric.org/chess1">https://chess-tutorial.nationalsciencedatafabric.org/chess1</a><br>
<br>
</div>

<div class="row" style="background-color: whitesmoke;">
<H1>NSDF Poster</H1>
<img src="resources/poster.png" width="400" width="400" style="filter:drop-shadow(5px 5px 5px #222);"/><br><br>
Come and see our poster <a href="https://www.chess.cornell.edu/user-meeting-2024/poster-submission-award">here</a>
<br><br>
</div>

<div class="row" style="background-color: rgb(224, 224, 224);">
<H1>NSDF Jupyter</H1>
<img src="resources/jupyter.png" width="400" width="400" style="filter:drop-shadow(5px 5px 5px #222);"/><br><br>
<!--
<a
href="https://chess-tutorial.nationalsciencedatafabric.org/jupyter">https://chess-tutorial.nationalsciencedatafabric.org/jupyter</a><br>
-->
Work in progress...
<br><br>
</div>

<hr>
This material is based upon work supported by the National Science Foundation under Grant No. 2138811.
Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and
do not necessarily reflect the views of the National Science Foundation.
Copyright © 2024 National Science Data Fabric<br>


<img src="resources/nsf.jpg" width="200" /><br>

</div>

</body>

</html>
Binary file added deploy/html/resources/chess.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added deploy/html/resources/dashboards-v1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added deploy/html/resources/dashboards-v2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added deploy/html/resources/header.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added deploy/html/resources/jupyter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added deploy/html/resources/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added deploy/html/resources/nsf.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added deploy/html/resources/poster.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5807482

Please sign in to comment.