Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setting environment variables #94

Merged
merged 3 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions daskhub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ The following table lists the configurable parameters of the Daskhub chart and t
| Parameter | Description | Default |
| ------------------------ | ----------------------- | -------------- |
| `rbac.enabled` | Create and use roles and service accounts on an rbac-enabled cluster. | `true` |
| `jupyterhub.hub.extraEnv` | Configure jupyterhub to work with dask gateway. | `[{"name": "DASK_GATEWAY__ADDRESS", "valueFrom": {"configMapKeyRef": {"name": "daskhub-config", "key": "DASK_GATEWAY__ADDRESS"}}}, {"name": "DASK_GATEWAY__PROXY_ADDRESS", "valueFrom": {"configMapKeyRef": {"name": "daskhub-config", "key": "DASK_GATEWAY__PROXY_ADDRESS"}}}, {"name": "DASKHUB_JUPYTERHUB_SERVICE_GATEWAY_URL", "valueFrom": {"configMapKeyRef": {"name": "daskhub-config", "key": "DASKHUB_JUPYTERHUB_SERVICE_GATEWAY_URL"}}}]` |
| `jupyterhub.hub.extraConfig.00-add-dask-gateway-values` | | `"import os\n\n# Adds a few variables to singluser.ExtraEnv which depend on the release name.\nfor key in [\"DASK_GATEWAY__ADDRESS\", \"DASK_GATEWAY__PROXY_ADDRESS\"]:\n c.KubeSpawner.environment[key] = os.environ[key]\n\n# Adds Dask Gateway as a JupyterHub service to make the gateway available at\n# {HUB_URL}/services/dask-gateway\nfor service in c.JupyterHub.services:\n if service[\"name\"] == \"dask-gateway\":\n if not service.get(\"url\", None):\n print(\"Adding dask-gateway service URL\")\n service[\"url\"] = os.environ[\"DASKHUB_JUPYTERHUB_SERVICE_GATEWAY_URL\"]\n break\nelse:\n print(\"dask-gateway service not found. Did you set jupyterhub.hub.services.dask-gateway.apiToken?\")\n"` |
| `jupyterhub.hub.extraConfig.00-add-dask-gateway-values` | | `"# 1. Sets `DASK_GATEWAY__PROXY_ADDRESS` in the singleuser environment.\n# 2. Adds the URL for the Dask Gateway JupyterHub service.\nimport os\n\n# These are set by jupyterhub.\nrelease_name = os.environ[\"HELM_RELEASE_NAME\"]\nrelease_namespace = os.environ[\"POD_NAMESPACE\"]\n\nc.KubeSpawner.environment[\"DASK_GATEWAY__ADDRESS\"] = \"http://proxy-public/services/dask-gateway\"\nc.KubeSpawner.environment[\"DASK_GATEWAY__PROXY_ADDRESS\"] = \"gateway://traefik-{}-dask-gateway.{}:80\".format(release_name, release_namespace)\n\n# Adds Dask Gateway as a JupyterHub service to make the gateway available at\n# {HUB_URL}/services/dask-gateway\nservice_url = \"http://traefik-{}-dask-gateway.{}\".format(release_name, release_namespace)\nfor service in c.JupyterHub.services:\n if service[\"name\"] == \"dask-gateway\":\n if not service.get(\"url\", None):\n print(\"Adding dask-gateway service URL\")\n service[\"url\"] = service_url\n break\nelse:\n print(\"dask-gateway service not found. Did you set jupyterhub.hub.services.dask-gateway.apiToken?\")\n"` |
| `jupyterhub.singleuser.image.name` | Image to use for singleuser environment. must include dask-gateyway. | `"pangeo/base-notebook"` |
| `jupyterhub.singleuser.image.tag` | | `"2020.07.28"` |
| `jupyterhub.singleuser.defaultUrl` | Use jupyterlab by defualt. | `"/lab"` |
| `jupyterhub.singleuser.extraEnv.DASK_GATEWAY__ADDRESS` | Internal address to connect to the dask gateway. | `"http://proxy-public/services/dask-gateway"` |
| `jupyterhub.singleuser.extraEnv.DASK_GATEWAY__PUBLIC_ADDRESS` | Sets the dask dashboard link in cluster and client reprs. | `"/services/dask-gateway/"` |
| `jupyterhub.singleuser.extraEnv.DASK_GATEWAY__AUTH__TYPE` | Use jupyterhub to authenticate with dask gateway. | `"jupyterhub"` |
| `dask-gateway.enabled` | Enabling dask-gateway will install dask gateway as a dependency. | `true` |
Expand Down
8 changes: 0 additions & 8 deletions daskhub/templates/daskhub-configmap.yaml

This file was deleted.

34 changes: 11 additions & 23 deletions daskhub/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,28 @@ jupyterhub:
# JupyterHub configuration goes here.
# See https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/master/jupyterhub/values.yaml
hub:
# These environment variables are declared in templates/daskhub-configmap.yaml
# They are eventually set in the singleuser environment.
extraEnv: # Configure JupyterHub to work with Dask Gateway.
- name: DASK_GATEWAY__ADDRESS
valueFrom:
configMapKeyRef:
name: daskhub-config
key: DASK_GATEWAY__ADDRESS
- name: DASK_GATEWAY__PROXY_ADDRESS
valueFrom:
configMapKeyRef:
name: daskhub-config
key: DASK_GATEWAY__PROXY_ADDRESS
- name: DASKHUB_JUPYTERHUB_SERVICE_GATEWAY_URL
valueFrom:
configMapKeyRef:
name: daskhub-config
key: DASKHUB_JUPYTERHUB_SERVICE_GATEWAY_URL

extraConfig:
# Register Dask Gateway service and setup singleuser environment.
00-add-dask-gateway-values: |
# 1. Sets `DASK_GATEWAY__PROXY_ADDRESS` in the singleuser environment.
# 2. Adds the URL for the Dask Gateway JupyterHub service.
import os

# Adds a few variables to singluser.ExtraEnv which depend on the release name.
for key in ["DASK_GATEWAY__ADDRESS", "DASK_GATEWAY__PROXY_ADDRESS"]:
c.KubeSpawner.environment[key] = os.environ[key]
# These are set by jupyterhub.
release_name = os.environ["HELM_RELEASE_NAME"]
release_namespace = os.environ["POD_NAMESPACE"]

c.KubeSpawner.environment["DASK_GATEWAY__ADDRESS"] = "http://proxy-public/services/dask-gateway"
c.KubeSpawner.environment["DASK_GATEWAY__PROXY_ADDRESS"] = "gateway://traefik-{}-dask-gateway.{}:80".format(release_name, release_namespace)

# Adds Dask Gateway as a JupyterHub service to make the gateway available at
# {HUB_URL}/services/dask-gateway
service_url = "http://traefik-{}-dask-gateway.{}".format(release_name, release_namespace)
for service in c.JupyterHub.services:
if service["name"] == "dask-gateway":
if not service.get("url", None):
print("Adding dask-gateway service URL")
service["url"] = os.environ["DASKHUB_JUPYTERHUB_SERVICE_GATEWAY_URL"]
service["url"] = service_url
break
else:
print("dask-gateway service not found. Did you set jupyterhub.hub.services.dask-gateway.apiToken?")
Expand All @@ -52,6 +39,7 @@ jupyterhub:
tag: 2020.07.28
defaultUrl: "/lab" # Use jupyterlab by defualt.
extraEnv:
DASK_GATEWAY__ADDRESS: "http://proxy-public/services/dask-gateway" # Internal address to connect to the Dask Gateway.
DASK_GATEWAY__PUBLIC_ADDRESS: "/services/dask-gateway/" # Sets the Dask dashboard link in cluster and client reprs.
DASK_GATEWAY__AUTH__TYPE: "jupyterhub" # Use JupyterHub to authenticate with Dask Gateway.
TomAugspurger marked this conversation as resolved.
Show resolved Hide resolved

Expand Down