Skip to content

Commit

Permalink
Merge branch 'master' of github.com:zonca/jupyterhub-deploy-kubernete…
Browse files Browse the repository at this point in the history
…s-jetstream
  • Loading branch information
zonca committed Oct 30, 2018
2 parents e9781f0 + 55bddae commit cc28bae
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dummy_gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM continuumio/miniconda3

# Update
RUN conda install --yes -c conda-forge flask zarr s3fs xarray ipython && conda clean --yes --all
RUN pip install python-openstackclient

# Bundle app source
COPY gateway.py /src/gateway.py

# Object store credentials
RUN mkdir -p ~/.aws
COPY my_aws_config /root/.aws/config

EXPOSE 8000
CMD ["python", "/src/gateway.py", "-p 8000"]
4 changes: 4 additions & 0 deletions dummy_gateway/aws_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[default]
region=RegionOne
aws_access_key_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
29 changes: 29 additions & 0 deletions dummy_gateway/gateway.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from flask import Flask
import sys
import s3fs
import xarray as xr
import numpy as np
import subprocess
import os

app = Flask(__name__)

@app.route("/")
def hello():

return "Gateway up and running!\n"

@app.route("/submit_job/<job_id>")
def submit_job(job_id):
#fs = s3fs.S3FileSystem(use_ssl=True, client_kwargs=dict(endpoint_url="https://tacc.jetstream-cloud.org:8080", region_name="RegionOne"))
#d = s3fs.S3Map("gateway_results/{}".format(job_id), s3=fs, create=False)
ds = xr.Dataset({'foo': np.zeros(10), 'bar': ('x', [1, 2]), 'baz': np.pi})
out = "{}.nc".format(job_id)
ds.to_netcdf(out, mode='w')
subprocess.run("openstack object create dummy_gateway {}".format(out).split())
os.remove(out)

return "Submitted job {}\n".format(job_id)

if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000, debug=False)
1 change: 1 addition & 0 deletions dummy_gateway/run_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run -d --env-file openrc.sh --name gateway -p 80:8000 gateway
6 changes: 6 additions & 0 deletions workshop_vm/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
while read f; do
echo $f
cd $f
sudo runuser -l $f -c 'bash ../clean_one.sh'
cd ..
done < use.txt
5 changes: 5 additions & 0 deletions workshop_vm/clean_one.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source openrc.sh
cd jetstream_kubespray/inventory/$(whoami)
echo $(pwd)
export CLUSTER=$(whoami)
nohup bash terraform_destroy.sh &

0 comments on commit cc28bae

Please sign in to comment.