Skip to content

Commit c9f228b

Browse files
Montes-LLilian Montes
andauthored
Add instructions for accessing Dask Scheduler Dashboard from JupyterHub (#953)
* docs: add instructions for accessing Dask Scheduler dashboard from JupyterHub * Add warning note to docs about using `c.ServerProxy.host_allowlist = lambda app, host: True` for accessing Dask Scheduler Dashboard from Jupyter notebook --------- Co-authored-by: Lilian Montes <[email protected]>
1 parent 547c911 commit c9f228b

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

docs/source/installing.rst

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,88 @@ If you prefer to install the operator from static manifests with ``kubectl`` and
157157
$ helm template --include-crds --repo https://helm.dask.org release dask-kubernetes-operator | kubectl apply -f -
158158

159159

160+
Working with JupyterHub
161+
^^^^^^^^^^^^^^^^^^^^^^^^
162+
163+
In order to access the Dask Operator’s dashboard with `JupyterHub <https://z2jh.jupyter.org/en/stable/>`_, some additional configuration is needed.
164+
165+
Configuring JupyterHub Network Policy
166+
"""""""""""""""""""""""""""""""""""""
167+
168+
The default JupyterHub configuration doesn’t allow communication between notebook pods and the Kubernetes API.
169+
Consider that `kubeconfig` is already `configured for your notebook pods <https://kubernetes.dask.org/en/stable/operator_kubecluster.html#role-based-access-control-rbac>`_, and in order to enable the creation of ``DaskCluster`` resources directly from a notebook, you should add the following section to your JupyterHub ``values.yaml``:
170+
171+
.. code-block:: yaml
172+
173+
singleuser:
174+
serviceAccountName: my-serviceaccount
175+
networkPolicy:
176+
enabled: True
177+
ingress: []
178+
egress:
179+
- ports:
180+
- port: 443
181+
protocol: TCP
182+
to:
183+
- namespaceSelector:
184+
matchLabels:
185+
name: kube-system
186+
egressAllowRules:
187+
cloudMetadataServer: false
188+
dnsPortsCloudMetadataServer: true
189+
dnsPortsKubeSystemNamespace: true
190+
dnsPortsPrivateIPs: true
191+
nonPrivateIPs: true
192+
privateIPs: true
193+
194+
Then apply your updated configuration:
195+
196+
.. code-block:: console
197+
198+
$ helm upgrade --cleanup-on-fail --install <your-jupyterhub-name> jupyterhub/jupyterhub --namespace <your-namespace> -f values.yaml
199+
200+
And restart your notebook pod:
201+
202+
.. code-block:: console
203+
204+
$ kubectl delete po -n <your-namespace> jupyter-<your-user-name>
205+
206+
Creating Dask clusters is now possible directly from your notebook. See `KubeCluster <https://kubernetes.dask.org/en/latest/operator_kubecluster.html>`_ for more details.
207+
208+
Accessing Dask Scheduler Dashboard from JupyterLab
209+
""""""""""""""""""""""""""""""""""""""""""""""""""
210+
211+
In order for your notebook pod to reach its own Dask Scheduler’s dashboard, you should add the following files to your JupyterHub configuration:
212+
213+
.. code-block:: yaml
214+
215+
singleuser:
216+
extraFiles:
217+
# Allow proxy requests to the Dask Scheduler’s dashboard
218+
jupyter-server-config:
219+
mountPath: /etc/jupyter/jupyter_server_config.py
220+
stringData: |
221+
# WARNING: This setting is inherently insecure and should be used with care.
222+
# Ideally, restrict this to only allow your Dask Scheduler’s domain instead of allowing everything.
223+
c.ServerProxy.host_allowlist = lambda app, host: True
224+
225+
# Configure the default path to reach Dask Scheduler’s dashboard
226+
dask-dashboard-config:
227+
mountPath: /home/jovyan/.config/dask/distributed.yaml
228+
stringData: |
229+
distributed:
230+
dashboard:
231+
link: "/user/{JUPYTERHUB_USER}/proxy/{host}:{port}/status"
232+
233+
Then, apply your updated configuration and restart your notebook pod as previously described.
234+
235+
236+
237+
.. warning::
238+
239+
Setting `c.ServerProxy.host_allowlist = lambda app, host: True` is inherently insecure and may enable unintended access to other services within your network.
240+
Ideally, you should modify this condition to restrict the host to your Dask Scheduler’s domain or service name (for instance, dask-cluster-name.default.svc.cluster.local) instead of allowing everything.
241+
160242
Kubeflow
161243
^^^^^^^^
162244

0 commit comments

Comments
 (0)