A simple creator of machines with Jupyterlab
Project description
labmachine
This a POC about creating a jupyter instance on demand and registering it into a dns provider and HTTPS.
Right now only works for Google Cloud but should be easy expand to other providers.
For examples, see examples
There you can see infra_[cpu|gpu].py
and lab_[cpu|gpu].py
infra files are raw implementacion of the cluster library. lab files are abstractions built over this library for jupyter lab provisioning.
For authentication the google app cred variable should be defined:
./scripts/gce_auth_key.sh <ACCOUNT>@<PROJECT_ID>.iam.gserviceaccount.com
mv gce.json ${HOME}/.ssh/gce.json
export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/.ssh/gce.json
Run gcloud iam service-accounts list
to see SA available in your project.
Suggested approach:
If you don't have a SA already created, you can take this strategy to create one and asign permissions to it.
gcloud iam service-accounts create labcreator
--description="Jupyter lab creator" \
--display-name="lab-creator"
Then add the following roles to the account:
roles/compute.instanceAdmin.v1
roles/iam.serviceAccountUser
roles/dns.admin
check https://cloud.google.com/dns/docs/access-controlroles/artifactregistry.reader
If artifacts is used for pulling containers
DNS role is needed only if the google dns provider is used
Warning: those roles can be too permissive, please check this for more information
roles="roles/compute.instanceAdmin.v1 roles/iam.serviceAccountUser"
for $perm in `cat $roles`; do
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:labcreator@PROJECT_ID.iam.gserviceaccount.com" \
--role=$perm
done
Destroy lab
python3 examples/destroy_lab.py
Next work
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file labmachine-0.2.0.tar.gz
.
File metadata
- Download URL: labmachine-0.2.0.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.18.19_1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3666c530f7fb7678c06defb03c6f3b5018417eaf9c088b906efc1109a5ea8cea |
|
MD5 | 305f3effdf796fac9d3e63ca459cfa4e |
|
BLAKE2b-256 | f4bee1bc35796f76397a39a2890fe6a7fcd697f86ab520780a589a2711ff6745 |
File details
Details for the file labmachine-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: labmachine-0.2.0-py3-none-any.whl
- Upload date:
- Size: 39.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.18.19_1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 974a52cbee36a62508e3199c49038eb8477b38a461b826fbc9c2e9bb3d5cf03b |
|
MD5 | bdcea74fa769d911f7a88cfe171106d8 |
|
BLAKE2b-256 | 5b144b27f5aba049ff78af0732c31e21fe37d04c1ebd4d97d381b69d3ade5d58 |