@@ -212,6 +212,135 @@ properties:
212
212
the `--values` or `-f` flag. During merging, lists are replaced while
213
213
dictionaries are updated.
214
214
```
215
+ extraFiles : &extraFiles
216
+ type : string
217
+ description : |
218
+ A dictionary with extra files to be injected into the pod's container
219
+ on startup. This can for example be used to inject: configuration
220
+ files, custom user interface templates, images, and more.
221
+
222
+ ```yaml
223
+ hub:
224
+ extraFiles:
225
+ # The file key is just a reference that doesn't influence the
226
+ # actual file name.
227
+ <file key>:
228
+ # mountPath is required and must be the absolute file path.
229
+ mountPath: <full file path>
230
+
231
+ # Choose one out of the three ways to represent the actual file
232
+ # content: data, stringData, or binaryData.
233
+ #
234
+ # data should be set to a mapping (dictionary). It will in the
235
+ # end be rendered to either YAML, JSON, or TOML based on the
236
+ # filename extension that are required to be either .yaml, .yml,
237
+ # .json, or .toml.
238
+ #
239
+ # If your content is YAML, JSON, or TOML, it can make sense to
240
+ # use data to represent it over stringData as data can be merged
241
+ # instead of replaced if set partially from separate Helm
242
+ # configuration files.
243
+ #
244
+ # Both stringData and binaryData should be set to a string
245
+ # representing the content, where binaryData should be the
246
+ # base64 encoding of the actual file content.
247
+ #
248
+ data:
249
+ config:
250
+ map:
251
+ number: 123
252
+ string: "hi"
253
+ list:
254
+ - 1
255
+ - 2
256
+ stringData: |
257
+ hello world!
258
+ binaryData: aGVsbG8gd29ybGQhCg==
259
+
260
+ # mode is by default 0644 and you can optionally override it
261
+ # either by octal notation (example: 0400) or decimal notation
262
+ # (example: 256).
263
+ mode: <file system permissions>
264
+ ```
265
+
266
+ **Using --set-file**
267
+
268
+ To avoid embedding entire files in the Helm chart configuration, you
269
+ can use the `--set-file` flag during `helm upgrade` to set the
270
+ stringData or binaryData field.
271
+
272
+ ```yaml
273
+ hub:
274
+ extraFiles:
275
+ my_image:
276
+ mountPath: /usr/local/share/jupyterhub/static/my_image.png
277
+
278
+ # Files in /usr/local/etc/jupyterhub/jupyterhub_config.d are
279
+ # automatically loaded in alphabetical order of the final file
280
+ # name when JupyterHub starts.
281
+ my_config:
282
+ mountPath: /usr/local/etc/jupyterhub/jupyterhub_config.d/my_jupyterhub_config.py
283
+ ```
284
+
285
+ ```bash
286
+ # --set-file expects a text based file, so you need to base64 encode
287
+ # it manually first.
288
+ base64 my_image.png > my_image.png.b64
289
+
290
+ helm upgrade <...> \
291
+ --set-file hub.extraFiles.my_image.binaryData=./my_image.png.b64 \
292
+ --set-file hub.extraFiles.my_config.stringData=./my_jupyterhub_config.py
293
+ ```
294
+
295
+ **Common uses**
296
+
297
+ 1. **JupyterHub template customization**
298
+
299
+ You can replace the default JupyterHub user interface templates in
300
+ the hub pod by injecting new ones to
301
+ `/usr/local/share/jupyterhub/templates`. These can in turn
302
+ reference custom images injected to
303
+ `/usr/local/share/jupyterhub/static`.
304
+
305
+ 1. **JupyterHub standalone file config**
306
+
307
+ Instead of embedding JupyterHub python configuration as a string
308
+ within a YAML file through
309
+ [`hub.extraConfig`](schema_hub.extraConfig), you can inject a
310
+ standalone .py file into
311
+ `/usr/local/etc/jupyterhub/jupyterhub_config.d` that is
312
+ automatically loaded.
313
+
314
+ 1. **Flexible configuration**
315
+
316
+ By injecting files, you don't have to embed them in a docker image
317
+ that you have to rebuild.
318
+
319
+ If your configuration file is a YAML/JSON/TOML file, you can also
320
+ use `data` instead of `stringData` which allow you to set various
321
+ configuration in separate Helm config files. This can be useful to
322
+ help dependent charts override only some configuration part of the
323
+ file, or to allow for the configuration be set through multiple
324
+ Helm configuration files.
325
+
326
+ **Limitations**
327
+
328
+ 1. File size
329
+
330
+ The files in `hub.extraFiles` and `singleuser.extraFiles` are
331
+ respectively stored in their own k8s Secret resource. As k8s
332
+ Secret's are limited, typically to 1MB, you will be limited to a
333
+ total file size of less than 1MB as there is also base64 encoding
334
+ that takes place reducing available capacity to 75%.
335
+
336
+ 2. File updates
337
+
338
+ The files that are mounted are only set during container startup.
339
+ This is [because we use
340
+ `subPath`](https://kubernetes.io/docs/concepts/storage/volumes/#secret)
341
+ as is required to avoid replacing the content of the entire
342
+ directory we mount in.
343
+
215
344
baseUrl :
216
345
type : string
217
346
description : |
@@ -243,10 +372,10 @@ properties:
243
372
244
373
```{warning}
245
374
By replacing the entire configuration file, which is mounted to
246
- `/etc/jupyterhub/jupyterhub_config.py` by the Helm chart, instead of
247
- appending to it with `hub.extraConfig`, you expose your deployment for
248
- issues stemming from getting out of sync with the Helm chart's config
249
- file.
375
+ `/usr/local/ etc/jupyterhub/jupyterhub_config.py` by the Helm chart,
376
+ instead of appending to it with `hub.extraConfig`, you expose your
377
+ deployment for issues stemming from getting out of sync with the Helm
378
+ chart's config file.
250
379
251
380
These kind of issues will be significantly harder to debug and
252
381
diagnose, and can due to this could cause a lot of time expenditure
@@ -268,7 +397,7 @@ properties:
268
397
args:
269
398
- "jupyterhub"
270
399
- "--config"
271
- - "/etc/jupyterhub/jupyterhub_config.py"
400
+ - "/usr/local/ etc/jupyterhub/jupyterhub_config.py"
272
401
- "--debug"
273
402
- "--upgrade-db"
274
403
```
@@ -1154,6 +1283,7 @@ properties:
1154
1283
description : |
1155
1284
Deprecated and no longer does anything. Use the user-scheduler instead
1156
1285
in order to accomplish a good packing of the user pods.
1286
+ extraFiles : *extraFiles
1157
1287
extraEnv :
1158
1288
type : object
1159
1289
description : |
0 commit comments