Skip to content

Commit 5554fec

Browse files
authored
Merge pull request #2820 from minrk/null-opt-in
Restore jupyterhub-singleuser as the default command
2 parents 9653da6 + 73a1f57 commit 5554fec

File tree

5 files changed

+39
-33
lines changed

5 files changed

+39
-33
lines changed

docs/source/administrator/upgrading/upgrade-1-to-2.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,6 @@ singleuser:
8181
allowPrivilegeEscalation: true
8282
```
8383

84-
## Default to using the container image's command instead of `jupyterhub-singleuser` [#2449](https://github.com/jupyterhub/zero-to-jupyterhub-k8s/pull/2449)
85-
86-
Z2JH now launches the container's default command (equivalent to setting `CMD` in a `Dockerfile`) instead of overriding it.
87-
This ensures that containers that use a custom start command to configure their environment, such as some
88-
[Jupyter Docker Stacks](https://jupyter-docker-stacks.readthedocs.io/en/latest/)
89-
images, will work without any changes.
90-
To restore the old behaviour set:
91-
92-
```yaml
93-
singleuser:
94-
cmd: jupyterhub-singleuser
95-
```
96-
9784
## Configuration in `jupyterhub_config.d` has a higher priority than `hub.config` [#2457](https://github.com/jupyterhub/zero-to-jupyterhub-k8s/pull/2457)
9885

9986
Previously if `hub.config` was used to configure some JupyterHub traitlets it would override any custom configuration files mounted into `jupyterhub_config.d` in the hub container.

docs/source/jupyterhub/customizing/user-environment.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ image containing useful tools and libraries for data science, complete these ste
4444
# https://github.com/jupyter/docker-stacks/tree/HEAD/datascience-notebook/Dockerfile
4545
name: jupyter/datascience-notebook
4646
tag: latest
47+
# `cmd: null` allows the custom CMD of the Jupyter docker-stacks to be used
48+
# which performs further customization on startup.
49+
cmd: null
4750
```
4851
4952
```{note}
@@ -244,10 +247,9 @@ FROM jupyter/minimal-notebook:latest
244247
RUN pip install --no-cache-dir astropy
245248

246249
# set the default command of the image,
247-
# if the parent image will not launch a jupyterhub singleuser server.
248-
# The JupyterHub "Docker stacks" do not need to be overridden.
249-
# Set either here or in `singleuser.cmd` in your values.yaml
250-
# CMD ["jupyterhub-singleuser"]
250+
# if you want to launch more complex startup than the default `juptyerhub-singleuser`.
251+
# To launch an image's custom CMD instead of the default `jupyterhub-singleuser`
252+
# set `singleuser.cmd: null` in your config.yaml.
251253
```
252254

253255
```{note}
@@ -529,25 +531,33 @@ this is best done in the ENTRYPOINT of the image,
529531
and not in the CMD, so that overriding the command does not skip your preparation.
530532
```
531533

532-
By default, zero-to-jupyterhub will launch the default CMD that is specified in your chosen image,
533-
respecting any startup customization that image may have.
534-
If the image doesn't launch `jupyterhub-singleuser` by default,
535-
you will additionally need to specify `singleuser.cmd`
536-
in your `values.yaml` as the command to launch,
537-
so that it ultimately launches `jupyterhub-singleuser`.
538-
The simplest version:
534+
By default, zero-to-jupyterhub will launch the command `jupyterhub-singleuser`.
535+
If you have an image (such as `jupyter/scipy-notebook` and other Jupyter Docker stacks)
536+
that defines a CMD with startup customization and ultimately launches `jupyterhub-singleuser`,
537+
you can chose to launch the image's default CMD instead by setting:
539538

540539
```yaml
541540
singleuser:
542-
cmd: jupyterhub-singleuser
541+
cmd: null
543542
```
544543
545-
```{versionchanged} 2.0
546-
Prior to 2.0, the default behavior of zero-to-jupyterhub was to launch `jupyterhub-singleuser` explicitly,
547-
ignoring what was in the image.
548-
The default command is now whatever the image runs by default.
544+
Alternately, you can specify an explicit custom command as a string or list of strings:
545+
546+
```yaml
547+
singleuser:
548+
cmd:
549+
- /usr/local/bin/custom-command
550+
- "--flag"
551+
- "--other-flag"
549552
```
550553
554+
:::{note}
555+
Docker has `ENTRYPOINT` and `CMD`,
556+
which k8s calls `command` and `args`.
557+
zero-to-jupyterhub always respects the ENTRYPOINT of the image,
558+
and setting `singleuser.cmd` only overrides the CMD.
559+
:::
560+
551561
## Disable specific JupyterLab extensions
552562

553563
Sometimes you want to temporarily disable a JupyterLab extension on a JupyterHub

jupyterhub/files/hub/jupyterhub_config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,13 @@ def camelCaseify(s):
408408

409409
c.JupyterHub.load_roles.append(role)
410410

411+
# respect explicit null command (distinct from unspecified)
412+
# this avoids relying on KubeSpawner.cmd's default being None
413+
_unspecified = object()
414+
specified_cmd = get_config("singleuser.cmd", _unspecified)
415+
if specified_cmd is not _unspecified:
416+
c.Spawner.cmd = specified_cmd
411417

412-
set_config_if_not_none(c.Spawner, "cmd", "singleuser.cmd")
413418
set_config_if_not_none(c.Spawner, "default_url", "singleuser.defaultUrl")
414419

415420
cloud_metadata = get_config("singleuser.cloudMetadata", {})

jupyterhub/schema.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ properties:
10191019
extraPorts:
10201020
type: array
10211021
description: |
1022-
Extra ports to add to the Hub Service object besides `hub` / `8081`.
1022+
Extra ports to add to the Hub Service object besides `hub` / `8081`.
10231023
This should be an array that includes `name`, `port`, and `targetPort`.
10241024
See [Multi-port Services](https://kubernetes.io/docs/concepts/services-networking/service/#multi-port-services) for more details.
10251025
loadBalancerIP:
@@ -2124,6 +2124,10 @@ properties:
21242124
description: |
21252125
Passthrough configuration for
21262126
[KubeSpawner.cmd](https://jupyterhub-kubespawner.readthedocs.io/en/latest/spawner.html#kubespawner.KubeSpawner.cmd).
2127+
The default is "jupyterhub-singleuser".
2128+
Use `cmd: null` to launch a custom CMD from the image,
2129+
which must launch jupyterhub-singleuser or an equivalent process eventually.
2130+
For example: Jupyter's docker-stacks images.
21272131
defaultUrl:
21282132
type: [string, "null"]
21292133
description: |
@@ -2636,7 +2640,7 @@ properties:
26362640
description: |
26372641
The path type to use. The default value is 'Prefix'.
26382642
2639-
See [the Kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types)
2643+
See [the Kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types)
26402644
for more details about path types.
26412645
tls:
26422646
type: array

jupyterhub/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ singleuser:
394394
extraResource:
395395
limits: {}
396396
guarantees: {}
397-
cmd:
397+
cmd: jupyterhub-singleuser
398398
defaultUrl:
399399
extraPodConfig: {}
400400
profileList: []

0 commit comments

Comments
 (0)