I have a user_info.json
file containing user information, structured as follows:
[
{ "name": "martin", "additional_storage": false, "server": []},
{ "name": "joe", "additional_storage": { "storage_account_name": "<storage_account_name>", "container_name": "<container_image>" }, "server": [{"default": true, "display_name": "server1"}, {"display_name": "server2"}]}
]
This file is mounted in the user’s pod at /etc/jupyterhub
.
Upon user login, I aim to provision additional storage (PV) dynamically. This involves creating PV, PVC, and mounting them to the user pod.
I’ve successfully implemented dynamic provisioning for profile/server
by integrating the following logic into the hub’s values.yaml
:
extraConfig:
options_form: |
import json
async def dynamic_options_form(self):
username = self.user.name
with open("/etc/jupyterhub/users_info.json") as f:
users = json.load(f)
for user in users:
if username == user['name']:
self.profile_list += user.get("server") if user.get("server") else self.profile_list
break
return self._options_form_default()
c.KubeSpawner.options_form = dynamic_options_form
However, I’m encountering difficulties replicating the same dynamic provisioning for PV.