This will depend on what Spawner you use. If it is a shared system as with the default or systemd spawners, to make kernels available for all users, you can install them system- or env-wide. If you want kernels to only be available for one user, you can install the kernels for just that user. Check jupyter kernelspec list to see the paths where kernels are installed. You can move them to other locations on jupyter --paths (the data directories) that are per-user.
If you want to set the default kernel whitelist on a per-user basis, you can do this in jupyter configuration:
# /etc/jupyter/jupyter_config.py
import os
jupyterhub_user = os.environ.get("JUPYTERHUB_USER")
if jupyterhub_user and jupyterhub_user in {'myname', 'othername'}:
# only the 'ir' kernel is allowed for these users:
c.KernelSpecManager.whitelist = {"ir","pyspark"}
The keys in that set should be the keys you see in jupyter kernelspec list.
These are the details i have setup my jupyterhub…
#Create a whitelist of users
c.Authenticator.whitelist = {'demo01', 'demo02', 'zain'}
c.Authenticator.admin_users = {'zain'}
jupyter-kernelspec list
Available kernels:
ir /root/.local/share/jupyter/kernels/ir
pyspark /share/apps/platform/ai/py36/3_6_9/share/jupyter/kernels/pyspark
python3 /share/apps/platform/ai/py36/3_6_9/share/jupyter/kernels/python3
I have added this code on jupyterhub_config.py for setting user specific kernels as you suggested…
import os
jupyterhub_user = os.environ.get("demo01")
if jupyterhub_user and jupyterhub_user in {'demo01', 'demo02'}:
# only the 'ir' kernel is allowed for these users:
c.KernelSpecManager.whitelist = {"ir"}
Still “ir” kernel not getting reflected to user - demo01
please help me out to resolve this.