Another edit: it seemed like singleuser.extraFiles
would work, but it did not, because of the surrounding directories being hardcoded to mode 420
.
extraFiles:
init_spark.py:
mountPath: "/home/jovyan/.ipython/profile_default/startup/init_spark.py"
# Use 664 to make writable by `users` group (owned by root)
mode: 0664
stringData: |
FOO = "bar"
This will result in
/opt/conda/lib/python3.9/site-packages/IPython/paths.py:59: UserWarning: IPython dir ‘/home/jovyan/.ipython’ is not a writable location, using a temp directory.
As this message indicates, this is because the surrounding directories, specifically /home/jovyan/.ipython
, are not writeable by jovyan/users
.
jovyan@jupyter-xxxx:~$ ls -dl /home/jovyan/.ipython
drwxr-sr-x 3 root users 4096 Dec 14 20:27 /home/jovyan/.ipython
jovyan@jupyter-xxxx:~$ ls -la /home/jovyan/.ipython/profile_default/startup/init_spark.py
-rw-rw-r-- 1 root users 612 Dec 14 20:26 /home/jovyan/.ipython/profile_default/startup/init_spark.py
As a result, the startup dir is changed to under /tmp
, which no longer reads init_spark.py, defeating the initial goal:
In [1]: get_ipython().profile_dir.startup_dir
...:
Out[1]: '/tmp/tmpatviwsy_/profile_default/startup'
$ k get po -n xxx jupyter-xxxx -o yaml
- name: files
secret:
defaultMode: 420
items:
- key: init_spark.py
mode: 436
path: init_spark.py
secretName: jupyter-singleuser
Related to `extraFiles` makes folder unwritable? - #5 by consideRatio