Skip to content

Commit

Permalink
Merge pull request #3217 from manfuin/prepuller_profile_options
Browse files Browse the repository at this point in the history
Pull images from `singleuser.profileList` found in `profile_options.choices`
  • Loading branch information
consideRatio authored Nov 23, 2023
2 parents 174f540 + fe43c02 commit 3cf91ca
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def parse_schema(d, md=[], depth=0, pre=""):
intersphinx_mapping = {
"jupyterhub": ("https://jupyterhub.readthedocs.io/en/stable/", None),
"oauthenticator": ("https://oauthenticator.readthedocs.io/en/stable/", None),
"kubespawner": ("https://jupyterhub-kubespawner.readthedocs.io/en/stable/", None),
}

# intersphinx_disabled_reftypes set based on recommendation in
Expand Down
28 changes: 28 additions & 0 deletions jupyterhub/templates/image-puller/_helpers-daemonset.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ spec:
{{- /* --- Conditionally pull profileList images --- */}}
{{- if .Values.prePuller.pullProfileListImages }}
{{- range $k, $container := .Values.singleuser.profileList }}
{{- /* profile's kubespawner_override */}}
{{- if $container.kubespawner_override }}
{{- if $container.kubespawner_override.image }}
- name: image-pull-singleuser-profilelist-{{ $k }}
Expand All @@ -152,6 +153,33 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- /* kubespawner_override in profile's profile_options */}}
{{- if $container.profile_options }}
{{- range $option, $option_spec := $container.profile_options }}
{{- if $option_spec.choices }}
{{- range $choice, $choice_spec := $option_spec.choices }}
{{- if $choice_spec.kubespawner_override }}
{{- if $choice_spec.kubespawner_override.image }}
- name: image-pull-profile-{{ $k }}-option-{{ $option }}-{{ $choice }}
image: {{ $choice_spec.kubespawner_override.image }}
command:
- /bin/sh
- -c
- echo "Pulling complete"
{{- with $.Values.prePuller.resources }}
resources:
{{- . | toYaml | nindent 12 }}
{{- end }}
{{- with $.Values.prePuller.containerSecurityContext }}
securityContext:
{{- . | toYaml | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
9 changes: 6 additions & 3 deletions jupyterhub/values.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2850,9 +2850,12 @@ properties:
pullProfileListImages:
type: boolean
description: |
The singleuser.profileList configuration can let the user choose an
image through the selection of a profile. This option determines if
those images will be pulled, both by the hook and continuous pullers.
The singleuser.profileList configuration can provide a selection of
images. This option determines if all images identified there should
be pulled, both by the hook and continuous pullers.
Images are looked for under `kubespawner_override`, and also
`profile_options.choices.kubespawner_override` since version 3.2.0.
The reason to disable this, is that if you have for example 10 images
which start pulling in order from 1 to 10, a user that arrives and
Expand Down
20 changes: 20 additions & 0 deletions tools/templates/lint-and-validate-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,26 @@ singleuser:
mock description 2
kubespawner_override:
image: XYZ:XYZ
- display_name: "mock display name 3"
description: |
mock description 3
profile_options:
image:
display_name: Image
choices:
image1:
display_name: "image 1"
kubespawner_override:
image: XXX:XXX
image2:
display_name: "image 2"
kubespawner_override:
image: YYY:YYY
unlisted_choice:
enabled: true
display_name: "image ZZZ tag"
kubespawner_override:
image: "ZZZ:{value}"
nodeSelector:
mock-node-selector: mock
extraTolerations:
Expand Down

0 comments on commit 3cf91ca

Please sign in to comment.