daskhub
by Dask
Multi-user JupyterHub and Dask deployment.
About this chart
Daskhub
This chart provides a multi-user, Dask-Gateway enabled JupyterHub. It combines the JupyterHub and Dask Gateway helm charts.
For single users, a simpler setup is supported by the dask helm chart.
See CHANGELOG for a information about changes in the daskhub helm chart.
Chart Details
This chart will deploy the following
- A standard Dask Gateway deployment using the Dask Gateway helm chart, configured to use JupyterHub for authentication.
- A standard JupyterHub deployment using the JupyterHub helm chart, configured proxy Dask Gateway requests and set Dask Gateway-related environment variables.
Install DaskHub
This example installs into the namespace dhub. Create and pass chart
configuration via config.yaml.
$ helm upgrade --wait --install --render-subchart-notes \
dhub dask/daskhub \
--namespace=dhub \
--values=config.yaml
The output explains how to find the IPs for your JupyterHub and Dask Gateway.
$ kubectl -n dhub get service proxy-public
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
proxy-public LoadBalancer 10.43.249.239 35.202.158.223 443:31587/TCP,80:30500/TCP 2m40s
JupyterHub is available at the proxy-public external ip (35.202.158.223 in this example).
Creating a Dask Cluster
To create a Dask cluster users can create a dask_gateway.GatewayCluster.
>>> from dask_gateway import GatewayCluster
>>> cluster = GatewayCluster()
>>> client = cluster.get_client()
If necessary (say to set options, create clusters that outlive the notebook session, etc.), users can connect to the Gateway
>>> from dask_gateway import Gateway
>>> gateway = Gateway()
See https://gateway.dask.org/ for more on using Dask Gateway.
Matching the user environment
Dask Clients will be running the JupyterHub's singleuser environment. To ensure that the same environment is used for the scheduler and workers, you can provide it as a Gateway option.
# config.yaml
jupyterhub:
singleuser:
extraEnv:
DASK_GATEWAY__CLUSTER__OPTIONS__IMAGE: '{JUPYTER_IMAGE_SPEC}'
dask-gateway:
gateway:
extraConfig:
optionHandler: |
from dask_gateway_server.options import Options, Integer, Float, String
def option_handler(options):
if ":" not in options.image:
raise ValueError("When specifying an image you must also provide a tag")
return {
"image": options.image,
}
c.Backend.cluster_options = Options(
String("image", default="pangeo/base-notebook:2022.09.21", label="Image"),
handler=option_handler,
)
The user environment will need to include dask-gateway.
Using dask-kubernetes instead of Dask Gateway
Users who don't need Dask Gateway can use dask-kubernetes to manage creating Dask Clusters. To use dask-kubernetes, you should set
# config.yaml
daskhub:
jupyterhub:
singleuser:
servieAccountName: daskkubernetes
dask-gateway:
enabled: false
dask-kubernetes:
enabled: true
When deploying, helm will create a Kubernetes ServiceAccount, Role, and RoleBinding. This ensures that the pods serving JupyterHub singleusers have the eleveated permissions for starting and stopping pods.
Configuration
The following table lists the configurable parameters of the Daskhub chart and their default values.
| Parameter | Description | Default |
|---|---|---|
rbac.enabled | Create and use roles and service accounts on an RBAC-enabled cluster. | true |
jupyterhub.hub.services.dask-gateway.display | false | |
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\nif \"PROXY_HTTP_SERVICE_HOST\" in os.environ:\n # https is enabled, we want to use the internal http service.\n gateway_address = \"http://{}:{}/services/dask-gateway/\".format(\n os.environ[\"PROXY_HTTP_SERVICE_HOST\"],\n os.environ[\"PROXY_HTTP_SERVICE_PORT\"],\n )\n print(\"Setting DASK_GATEWAY__ADDRESS {} from HTTP service\".format(gateway_address))\nelse:\n gateway_address = \"http://proxy-public/services/dask-gateway\"\n print(\"Setting DASK_GATEWAY__ADDRESS {}\".format(gateway_address))\n\n# Internal address to connect to the Dask Gateway.\nc.KubeSpawner.environment.setdefault(\"DASK_GATEWAY__ADDRESS\", gateway_address)\n# Internal address for the Dask Gateway proxy.\nc.KubeSpawner.environment.setdefault(\"DASK_GATEWAY__PROXY_ADDRESS\", \"gateway://traefik-{}-dask-gateway.{}:80\".format(release_name, release_namespace))\n# Relative address for the dashboard link.\nc.KubeSpawner.environment.setdefault(\"DASK_GATEWAY__PUBLIC_ADDRESS\", \"/services/dask-gateway/\")\n# Use JupyterHub to authenticate with Dask Gateway.\nc.KubeSpawner.environment.setdefault(\"DASK_GATEWAY__AUTH__TYPE\", \"jupyterhub\")\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.setdefault(\"url\", service_url)\n break\nelse:\n print(\"dask-gateway service not found, this should not happen!\")\n" | |
jupyterhub.singleuser.image.name | Image to use for singleuser environment. Must include dask-gateway. | "pangeo/base-notebook" |
jupyterhub.singleuser.image.tag | "2024.01.15" | |
jupyterhub.singleuser.defaultUrl | Use jupyterlab by defualt. | "/lab" |
dask-gateway.enabled | Enabling dask-gateway will install Dask Gateway as a dependency. | true |
dask-gateway.gateway.prefix | Users connect to the Gateway through the JupyterHub service. | "/services/dask-gateway" |
dask-gateway.gateway.auth.type | Use JupyterHub to authenticate with Dask Gateway | "jupyterhub" |
dask-gateway.traefik.service.type | Access Dask Gateway through JupyterHub. To access the Gateway from outside JupyterHub, this must be changed to a LoadBalancer. | "ClusterIP" |
dask-kubernetes.enabled | false | |
jupyterhub.fullnameOverride | "" | |
jupyterhub.nameOverride | null | |
jupyterhub.enabled | null | |
jupyterhub.custom | {} | |
jupyterhub.imagePullSecret.create | false | |
jupyterhub.imagePullSecret.automaticReferenceInjection | true | |
jupyterhub.imagePullSecret.registry | null | |
jupyterhub.imagePullSecret.username | null | |
jupyterhub.imagePullSecret.password | null | |
jupyterhub.imagePullSecret.email | null | |
jupyterhub.imagePullSecrets | [] | |
jupyterhub.hub.revisionHistoryLimit | null | |
jupyterhub.hub.config.JupyterHub.admin_access | true | |
jupyterhub.hub.config.JupyterHub.authenticator_class | "dummy" | |
jupyterhub.hub.service.type | "ClusterIP" | |
jupyterhub.hub.service.annotations | {} | |
jupyterhub.hub.service.ports.nodePort | null | |
jupyterhub.hub.service.extraPorts | [] | |
jupyterhub.hub.service.loadBalancerIP | null | |
jupyterhub.hub.baseUrl | "/" | |
jupyterhub.hub.cookieSecret | null | |
jupyterhub.hub.initContainers | [] | |
jupyterhub.hub.nodeSelector | {} | |
jupyterhub.hub.tolerations | [] | |
jupyterhub.hub.concurrentSpawnLimit | 64 | |
jupyterhub.hub.consecutiveFailureLimit | 5 | |
jupyterhub.hub.activeServerLimit | null | |
jupyterhub.hub.deploymentStrategy.type | "Recreate" | |
jupyterhub.hub.db.type | "sqlite-pvc" | |
jupyterhub.hub.db.upgrade | null | |
jupyterhub.hub.db.pvc.annotations | {} | |
jupyterhub.hub.db.pvc.selector | {} | |
jupyterhub.hub.db.pvc.accessModes | ["ReadWriteOnce"] | |
jupyterhub.hub.db.pvc.storage | "1Gi" | |
jupyterhub.hub.db.pvc.subPath | null | |
jupyterhub.hub.db.pvc.storageClassName | null | |
jupyterhub.hub.db.url | null | |
jupyterhub.hub.db.password | null | |
jupyterhub.hub.labels | {} | |
jupyterhub.hub.annotations | {} | |
jupyterhub.hub.command | [] | |
jupyterhub.hub.args | [] | |
jupyterhub.hub.extraConfig | {} | |
jupyterhub.hub.extraFiles | {} | |
jupyterhub.hub.extraEnv | {} | |
jupyterhub.hub.extraContainers | [] | |
jupyterhub.hub.extraVolumes | [] | |
jupyterhub.hub.extraVolumeMounts | [] | |
jupyterhub.hub.image.name | "quay.io/jupyterhub/k8s-hub" | |
jupyterhub.hub.image.tag | "3.2.1" | |
jupyterhub.hub.image.pullPolicy | null | |
jupyterhub.hub.image.pullSecrets | [] | |
jupyterhub.hub.resources | {} | |
jupyterhub.hub.podSecurityContext.fsGroup | 1000 | |
jupyterhub.hub.containerSecurityContext.runAsUser | 1000 | |
jupyterhub.hub.containerSecurityContext.runAsGroup | 1000 | |
jupyterhub.hub.containerSecurityContext.allowPrivilegeEscalation | false | |
jupyterhub.hub.lifecycle | {} | |
jupyterhub.hub.loadRoles | {} | |
jupyterhub.hub.services | {} | |
jupyterhub.hub.pdb.enabled | false | |
jupyterhub.hub.pdb.maxUnavailable | null | |
jupyterhub.hub.pdb.minAvailable | 1 | |
jupyterhub.hub.networkPolicy.enabled | true | |
jupyterhub.hub.networkPolicy.ingress | [] | |
jupyterhub.hub.networkPolicy.egress | [] | |
jupyterhub.hub.networkPolicy.egressAllowRules.cloudMetadataServer | true | |
jupyterhub.hub.networkPolicy.egressAllowRules.dnsPortsCloudMetadataServer | true | |
jupyterhub.hub.networkPolicy.egressAllowRules.dnsPortsKubeSystemNamespace | true | |
jupyterhub.hub.networkPolicy.egressAllowRules.dnsPortsPrivateIPs | true | |
jupyterhub.hub.networkPolicy.egressAllowRules.nonPrivateIPs | true | |
jupyterhub.hub.networkPolicy.egressAllowRules.privateIPs | true | |
jupyterhub.hub.networkPolicy.interNamespaceAccessLabels | "ignore" | |
jupyterhub.hub.networkPolicy.allowedIngressPorts | [] | |
jupyterhub.hub.allowNamedServers | false | |
jupyterhub.hub.namedServerLimitPerUser | null | |
jupyterhub.hub.authenticatePrometheus | null | |
jupyterhub.hub.redirectToServer | null | |
jupyterhub.hub.shutdownOnLogout | null | |
jupyterhub.hub.templatePaths | [] | |
jupyterhub.hub.templateVars | {} | |
jupyterhub.hub.livenessProbe.enabled | true | |
jupyterhub.hub.livenessProbe.initialDelaySeconds | 300 | |
jupyterhub.hub.livenessProbe.periodSeconds | 10 | |
jupyterhub.hub.livenessProbe.failureThreshold | 30 | |
jupyterhub.hub.livenessProbe.timeoutSeconds | 3 | |
jupyterhub.hub.readinessProbe.enabled | true | |
jupyterhub.hub.readinessProbe.initialDelaySeconds | 0 | |
jupyterhub.hub.readinessProbe.periodSeconds | 2 | |
jupyterhub.hub.readinessProbe.failureThreshold | 1000 | |
jupyterhub.hub.readinessProbe.timeoutSeconds | 1 | |
jupyterhub.hub.existingSecret | null | |
jupyterhub.hub.serviceAccount.create | true | |
jupyterhub.hub.serviceAccount.name | null | |
jupyterhub.hub.serviceAccount.annotations | {} | |
jupyterhub.hub.extraPodSpec | {} | |
jupyterhub.rbac.create | true | |
jupyterhub.proxy.secretToken | null | |
jupyterhub.proxy.annotations | {} | |
jupyterhub.proxy.deploymentStrategy.type | "Recreate" | |
jupyterhub.proxy.deploymentStrategy.rollingUpdate | null | |
jupyterhub.proxy.service.type | "LoadBalancer" | |
jupyterhub.proxy.service.labels | {} | |
jupyterhub.proxy.service.annotations | {} | |
jupyterhub.proxy.service.nodePorts.http | null | |
jupyterhub.proxy.service.nodePorts.https | null | |
jupyterhub.proxy.service.disableHttpPort | false | |
jupyterhub.proxy.service.extraPorts | [] | |
jupyterhub.proxy.service.loadBalancerIP | null | |
jupyterhub.proxy.service.loadBalancerSourceRanges | [] | |
jupyterhub.proxy.chp.revisionHistoryLimit | null | |
jupyterhub.proxy.chp.containerSecurityContext.runAsUser | nobody user | 65534 |
jupyterhub.proxy.chp.containerSecurityContext.runAsGroup | nobody group | 65534 |
jupyterhub.proxy.chp.containerSecurityContext.allowPrivilegeEscalation | false | |
jupyterhub.proxy.chp.image.name | "quay.io/jupyterhub/configurable-http-proxy" | |
jupyterhub.proxy.chp.image.tag | https://github.com/jupyterhub/configurable-http-proxy/tags | "4.6.1" |
jupyterhub.proxy.chp.image.pullPolicy | null | |
jupyterhub.proxy.chp.image.pullSecrets | [] | |
| `jupyterhub.prox |
Deploy daskhub with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has daskhub on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartdaskhub is pinned at v2024.1.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply