Hi, I have a Jupyter hub instance with multiple profiles for separate things, at the moment when spawning into a profile it use the default user pvc, however I want each profile to use a separate PVC with no shared storage between profiles. I have included a snippet of how i’ve configured the profile in the helm chart, but this just doesn’t work -
profileList:
- display_name: "profile1"
description: "desc"
kubespawner_override:
start_timeout: 600
image: image_url_2
storage_pvc_ensure: true
pvc_name_template: claim-{username}-profile1
storage_capacity: 10Gi
storage_access_modes:
- ReadWriteOnce
lifecycle_hooks:
postStart:
exec:
command:
- "/tmp/startup/start.sh"
- display_name: "profile2"
description: "desc"
kubespawner_override:
start_timeout: 600
image: image_url_2
storage_pvc_ensure: true
pvc_name_template: claim-{username}-profile2
storage_capacity: 10Gi
storage_access_modes:
- ReadWriteOnce
lifecycle_hooks:
postStart:
exec:
command:
- "/tmp/startup/start.sh"
What am i doing wrong?
manics
January 17, 2025, 3:10pm
2
It looks like you’ve found a bug! I’ve opened
opened 03:10PM - 17 Jan 25 UTC
bug
### Bug description
`pvc_name` is expanded in `__init__`, which means `pvc_name… _template` can't be overridden in `kubespawner_overrides`:
https://github.com/jupyterhub/kubespawner/blob/5ac45e946ae39a2949c50a0b1a2bee79077b1351/kubespawner/spawner.py#L208
### How to reproduce
Reported in https://discourse.jupyter.org/t/creating-1-pvc-per-profile-and-per-user/31755
With Z2JH 4.1.0:
```yaml
hub:
db:
type: sqlite-pvc
proxy:
service:
type: NodePort
nodePorts:
http: 31080
singleuser:
profileList:
- display_name: "profile1"
description: "desc1"
kubespawner_override:
pvc_name_template: claim-{username}-profile1
- display_name: "profile2"
description: "desc2"
kubespawner_override:
pvc_name_template: claim-{username}-profile2
debug:
enabled: true
```
#### Expected behaviour
`pvc_name` follows the template `pvc_name_template` if it is overriden in `kubespawner_overrides`.
#### Actual behaviour
The overridden template is ignored, `claim-{username}` is used for all profiles.
### Your personal set up
https://killercoda.com/manics/scenario/jupyterhub-kubernetes
Thanks for raising the github issue, i’ll follow the issue on github
Quick question, would there be a workaround for this in the meantime until this is properly fixed and released?
manics
January 22, 2025, 8:50pm
5
Overriding get_pvc_manifest
seems to work:
hub:
db:
type: sqlite-pvc
extraConfig:
customkubespawner: |
from kubespawner import KubeSpawner
class CustomKubeSpawner(KubeSpawner):
def get_pvc_manifest(self):
self.pvc_name = self._expand_user_properties(self.pvc_name_template)
return super().get_pvc_manifest()
c.JupyterHub.spawner_class = CustomKubeSpawner
proxy:
service:
type: NodePort
nodePorts:
http: 31080
singleuser:
profileList:
- display_name: "profile1"
description: "desc1"
kubespawner_override:
pvc_name_template: claim-{username}-profile1
- display_name: "profile2"
description: "desc2"
kubespawner_override:
pvc_name_template: claim-{username}-profile2
debug:
enabled: true
but I haven’t checked it in depth. Also be aware of the comment on
opened 03:10PM - 17 Jan 25 UTC
bug
### Bug description
`pvc_name` is expanded in `__init__`, which means `pvc_name… _template` can't be overridden in `kubespawner_overrides`:
https://github.com/jupyterhub/kubespawner/blob/5ac45e946ae39a2949c50a0b1a2bee79077b1351/kubespawner/spawner.py#L208
### How to reproduce
Reported in https://discourse.jupyter.org/t/creating-1-pvc-per-profile-and-per-user/31755
With Z2JH 4.1.0:
```yaml
hub:
db:
type: sqlite-pvc
proxy:
service:
type: NodePort
nodePorts:
http: 31080
singleuser:
profileList:
- display_name: "profile1"
description: "desc1"
kubespawner_override:
pvc_name_template: claim-{username}-profile1
- display_name: "profile2"
description: "desc2"
kubespawner_override:
pvc_name_template: claim-{username}-profile2
debug:
enabled: true
```
#### Expected behaviour
`pvc_name` follows the template `pvc_name_template` if it is overriden in `kubespawner_overrides`.
#### Actual behaviour
The overridden template is ignored, `claim-{username}` is used for all profiles.
### Your personal set up
https://killercoda.com/manics/scenario/jupyterhub-kubernetes
I think you should be OK if you don’t have existing PVCs created under the old naming scheme but please review the code and check carefully!