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/README.md b/README.md index 158abe7..46f4764 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 @@ -226,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. 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 & } diff --git a/resources/jupyterhub_config.py b/resources/jupyterhub_config.py index 41529a0..f4257c6 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)} 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: