daskhub

by Dask

Helm chartv2024.1.1App jh3.2.1-dg2024.1.0

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.

ParameterDescriptionDefault
rbac.enabledCreate and use roles and service accounts on an RBAC-enabled cluster.true
jupyterhub.hub.services.dask-gateway.displayfalse
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.nameImage to use for singleuser environment. Must include dask-gateway."pangeo/base-notebook"
jupyterhub.singleuser.image.tag"2024.01.15"
jupyterhub.singleuser.defaultUrlUse jupyterlab by defualt."/lab"
dask-gateway.enabledEnabling dask-gateway will install Dask Gateway as a dependency.true
dask-gateway.gateway.prefixUsers connect to the Gateway through the JupyterHub service."/services/dask-gateway"
dask-gateway.gateway.auth.typeUse JupyterHub to authenticate with Dask Gateway"jupyterhub"
dask-gateway.traefik.service.typeAccess Dask Gateway through JupyterHub. To access the Gateway from outside JupyterHub, this must be changed to a LoadBalancer."ClusterIP"
dask-kubernetes.enabledfalse
jupyterhub.fullnameOverride""
jupyterhub.nameOverridenull
jupyterhub.enablednull
jupyterhub.custom{}
jupyterhub.imagePullSecret.createfalse
jupyterhub.imagePullSecret.automaticReferenceInjectiontrue
jupyterhub.imagePullSecret.registrynull
jupyterhub.imagePullSecret.usernamenull
jupyterhub.imagePullSecret.passwordnull
jupyterhub.imagePullSecret.emailnull
jupyterhub.imagePullSecrets[]
jupyterhub.hub.revisionHistoryLimitnull
jupyterhub.hub.config.JupyterHub.admin_accesstrue
jupyterhub.hub.config.JupyterHub.authenticator_class"dummy"
jupyterhub.hub.service.type"ClusterIP"
jupyterhub.hub.service.annotations{}
jupyterhub.hub.service.ports.nodePortnull
jupyterhub.hub.service.extraPorts[]
jupyterhub.hub.service.loadBalancerIPnull
jupyterhub.hub.baseUrl"/"
jupyterhub.hub.cookieSecretnull
jupyterhub.hub.initContainers[]
jupyterhub.hub.nodeSelector{}
jupyterhub.hub.tolerations[]
jupyterhub.hub.concurrentSpawnLimit64
jupyterhub.hub.consecutiveFailureLimit5
jupyterhub.hub.activeServerLimitnull
jupyterhub.hub.deploymentStrategy.type"Recreate"
jupyterhub.hub.db.type"sqlite-pvc"
jupyterhub.hub.db.upgradenull
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.subPathnull
jupyterhub.hub.db.pvc.storageClassNamenull
jupyterhub.hub.db.urlnull
jupyterhub.hub.db.passwordnull
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.pullPolicynull
jupyterhub.hub.image.pullSecrets[]
jupyterhub.hub.resources{}
jupyterhub.hub.podSecurityContext.fsGroup1000
jupyterhub.hub.containerSecurityContext.runAsUser1000
jupyterhub.hub.containerSecurityContext.runAsGroup1000
jupyterhub.hub.containerSecurityContext.allowPrivilegeEscalationfalse
jupyterhub.hub.lifecycle{}
jupyterhub.hub.loadRoles{}
jupyterhub.hub.services{}
jupyterhub.hub.pdb.enabledfalse
jupyterhub.hub.pdb.maxUnavailablenull
jupyterhub.hub.pdb.minAvailable1
jupyterhub.hub.networkPolicy.enabledtrue
jupyterhub.hub.networkPolicy.ingress[]
jupyterhub.hub.networkPolicy.egress[]
jupyterhub.hub.networkPolicy.egressAllowRules.cloudMetadataServertrue
jupyterhub.hub.networkPolicy.egressAllowRules.dnsPortsCloudMetadataServertrue
jupyterhub.hub.networkPolicy.egressAllowRules.dnsPortsKubeSystemNamespacetrue
jupyterhub.hub.networkPolicy.egressAllowRules.dnsPortsPrivateIPstrue
jupyterhub.hub.networkPolicy.egressAllowRules.nonPrivateIPstrue
jupyterhub.hub.networkPolicy.egressAllowRules.privateIPstrue
jupyterhub.hub.networkPolicy.interNamespaceAccessLabels"ignore"
jupyterhub.hub.networkPolicy.allowedIngressPorts[]
jupyterhub.hub.allowNamedServersfalse
jupyterhub.hub.namedServerLimitPerUsernull
jupyterhub.hub.authenticatePrometheusnull
jupyterhub.hub.redirectToServernull
jupyterhub.hub.shutdownOnLogoutnull
jupyterhub.hub.templatePaths[]
jupyterhub.hub.templateVars{}
jupyterhub.hub.livenessProbe.enabledtrue
jupyterhub.hub.livenessProbe.initialDelaySeconds300
jupyterhub.hub.livenessProbe.periodSeconds10
jupyterhub.hub.livenessProbe.failureThreshold30
jupyterhub.hub.livenessProbe.timeoutSeconds3
jupyterhub.hub.readinessProbe.enabledtrue
jupyterhub.hub.readinessProbe.initialDelaySeconds0
jupyterhub.hub.readinessProbe.periodSeconds2
jupyterhub.hub.readinessProbe.failureThreshold1000
jupyterhub.hub.readinessProbe.timeoutSeconds1
jupyterhub.hub.existingSecretnull
jupyterhub.hub.serviceAccount.createtrue
jupyterhub.hub.serviceAccount.namenull
jupyterhub.hub.serviceAccount.annotations{}
jupyterhub.hub.extraPodSpec{}
jupyterhub.rbac.createtrue
jupyterhub.proxy.secretTokennull
jupyterhub.proxy.annotations{}
jupyterhub.proxy.deploymentStrategy.type"Recreate"
jupyterhub.proxy.deploymentStrategy.rollingUpdatenull
jupyterhub.proxy.service.type"LoadBalancer"
jupyterhub.proxy.service.labels{}
jupyterhub.proxy.service.annotations{}
jupyterhub.proxy.service.nodePorts.httpnull
jupyterhub.proxy.service.nodePorts.httpsnull
jupyterhub.proxy.service.disableHttpPortfalse
jupyterhub.proxy.service.extraPorts[]
jupyterhub.proxy.service.loadBalancerIPnull
jupyterhub.proxy.service.loadBalancerSourceRanges[]
jupyterhub.proxy.chp.revisionHistoryLimitnull
jupyterhub.proxy.chp.containerSecurityContext.runAsUsernobody user65534
jupyterhub.proxy.chp.containerSecurityContext.runAsGroupnobody group65534
jupyterhub.proxy.chp.containerSecurityContext.allowPrivilegeEscalationfalse
jupyterhub.proxy.chp.image.name"quay.io/jupyterhub/configurable-http-proxy"
jupyterhub.proxy.chp.image.taghttps://github.com/jupyterhub/configurable-http-proxy/tags"4.6.1"
jupyterhub.proxy.chp.image.pullPolicynull
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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartdaskhub is pinned at v2024.1.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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