From 13e9cf6d8c827461ca36bcacb3b24fe452d7c565 Mon Sep 17 00:00:00 2001 From: Benjamin Raethlein Date: Wed, 13 Nov 2019 15:55:39 +0100 Subject: [PATCH 1/4] Add information about labels of the resources --- README.md | 2 ++ resources/mlhubspawner/mlhubspawner/utils.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 158abe7..3d7790e 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,8 @@ We override [DockerSpawner](https://github.com/ml-tooling/ml-hub/blob/master/res - Create / delete services for a workspace, so that the hub can access them via Kubernetes DNS. +All resources created by our custom spawners are labeled (Docker / Kubernetes labels) with the labels `mlhub.origin` set to the Hub name `$ENV_HUB_NAME`, `mlhub.user` set to the JupyterHub user the resources belongs to, and `mlhub.server_name` to the named server name. For example, if the hub name is "mlhub" and a user named "foo" has a named server "bar", the labels would be `mlhub.origin=mlhub`, `mlhub.user=foo`, `mlhub.server_name=bar`. + ## Support The ML Hub project is maintained by [@raethlein](https://twitter.com/raethlein) and [@LukasMasuch](https://twitter.com/LukasMasuch). Please understand that we won't be able diff --git a/resources/mlhubspawner/mlhubspawner/utils.py b/resources/mlhubspawner/mlhubspawner/utils.py index e9506b2..47a74d3 100644 --- a/resources/mlhubspawner/mlhubspawner/utils.py +++ b/resources/mlhubspawner/mlhubspawner/utils.py @@ -15,6 +15,7 @@ LABEL_NVIDIA_VISIBLE_DEVICES = 'nvidia_visible_devices' LABEL_EXPIRATION_TIMESTAMP = 'expiration_timestamp_seconds' +LABEL_MLHUB_ORIGIN = "mlhub.origin" LABEL_MLHUB_USER = "mlhub.user" LABEL_MLHUB_SERVER_NAME = "mlhub.server_name" @@ -23,7 +24,6 @@ EXECUTION_MODE_KUBERNETES = "k8s" ENV_NAME_CLEANUP_INTERVAL_SECONDS = "CLEANUP_INTERVAL_SECONDS" -LABEL_MLHUB_ORIGIN = "mlhub.origin" ENV_HUB_NAME = os.getenv("HUB_NAME", "mlhub") def get_lifetime_timestamp(labels: dict) -> float: From f675827da63aa153a6779712a77f7dfa12444e53 Mon Sep 17 00:00:00 2001 From: Benjamin Raethlein Date: Wed, 13 Nov 2019 16:11:18 +0100 Subject: [PATCH 2/4] Add Section about customizing the hub --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3d7790e..46f4764 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,10 @@ The service has two endpoints which can be reached under the Hub service url `/s - `GET /services/cleanup-service/expired`: When starting a named workspace, an expiration date can be assigned to it. This endpoint will delete all containers that are expired. The respective named server is deleted from the JupyterHub database and also the Docker/Kubernetes resource is deleted. +## Customization + +- Logo: if you want to have your own logo in the corner, place it at `/usr/local/share/jupyterhub/static/images/jupyter.png` inside the hub container. + ## Contribution - Pull requests are encouraged and always welcome. Read [`CONTRIBUTING.md`](https://github.com/ml-tooling/ml-hub/tree/master/CONTRIBUTING.md) and check out [help-wanted](https://github.com/ml-tooling/ml-hub/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+label%3A"help+wanted"+sort%3Areactions-%2B1-desc+) issues. From 0812ad606301276c7bb863c1709ee46d941c6107 Mon Sep 17 00:00:00 2001 From: Benjamin Raethlein Date: Wed, 13 Nov 2019 16:40:35 +0100 Subject: [PATCH 3/4] Put shm_size into Docker section, as it is not applicable to Kubernetes --- resources/jupyterhub_config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/jupyterhub_config.py b/resources/jupyterhub_config.py index 12d23d5..2681735 100644 --- a/resources/jupyterhub_config.py +++ b/resources/jupyterhub_config.py @@ -95,7 +95,6 @@ def combine_config_dicts(*configs) -> dict: # Connect containers to this Docker network c.Spawner.use_internal_ip = True -c.Spawner.extra_host_config = { 'shm_size': '256m' } c.Spawner.prefix = 'ws' c.Spawner.name_template = c.Spawner.prefix + '-{username}-' + ENV_HUB_NAME + '{servername}' # override in your config when you want to have a different name schema. Also consider changing c.Authenticator.username_pattern and check the environment variables to permit ssh connection @@ -161,6 +160,9 @@ def combine_config_dicts(*configs) -> dict: elif ENV_EXECUTION_MODE == utils.EXECUTION_MODE_LOCAL: + # shm_size can only be set for Docker, not Kubernetes (see https://stackoverflow.com/questions/43373463/how-to-increase-shm-size-of-a-kubernetes-container-shm-size-equivalent-of-doc) + c.Spawner.extra_host_config = { 'shm_size': '256m' } + client_kwargs = {**get_or_init(c.DockerSpawner.client_kwargs, dict), **get_or_init(c.MLHubDockerSpawner.client_kwargs, dict)} tls_config = {**get_or_init(c.DockerSpawner.tls_config, dict), **get_or_init(c.MLHubDockerSpawner.tls_config, dict)} From 381d0852efaf393580e6c10d78cda6aeba7014c6 Mon Sep 17 00:00:00 2001 From: Benjamin Raethlein Date: Fri, 22 Nov 2019 11:22:01 +0100 Subject: [PATCH 4/4] Update base image ssh-proxy to version 0.1.10 --- Dockerfile | 2 +- resources/docker-entrypoint.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 155d389..7ca6ab0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mltooling/ssh-proxy:0.1.8 +FROM mltooling/ssh-proxy:0.1.10 WORKDIR / diff --git a/resources/docker-entrypoint.sh b/resources/docker-entrypoint.sh index 397aefc..83d8ba2 100755 --- a/resources/docker-entrypoint.sh +++ b/resources/docker-entrypoint.sh @@ -25,7 +25,11 @@ fi $_RESOURCES_PATH/scripts/setup_certs.sh function start_ssh { + """See the documentation of the ssh-proxy image + - the image this hub image is based on - for more information""" + echo "Start SSH Daemon service" + export SSH_TARGET_LABELS="mlhub.origin=$HUB_NAME" # Run ssh-bastion image entrypoint nohup python $_RESOURCES_PATH/start_ssh.py & }