We should set the PVC's volumeName, i think
See original GitHub issue@hans-permana found the z2jh setting singleuser.storage.dynamic.volumeNameTemplate
. We both thought that this could influence the naming of the dynamically created PersistantVolume
objects. Our investigation led us to conclude that this is only the spawned pods volume reference under the pods spec.volumes
that is named in this manner, while the actual PersistantVolume
k8s object, which is to be provisioned by the cloud provider looking at the PVC object in turn created by KubeSpawner, is not getting a similar name. This is because the PVC kubespawner creates does not set the spec.volumeName
field (see reference documentation).
I think we should allow optionally setting the volumeName
field of the PVC’s spec through the make_pvc
function in kubespawner. The Z2JH project can then later decide to utilize this option or not.
Suggested action - Add config of volumeName
here
Reference only, related code
Z2JH configuration (inspect in the source code):
singleuser:
storage:
dynamic:
storageClass:
pvcNameTemplate: claim-{username}{servername}
volumeNameTemplate: volume-{username}{servername}
storageAccessModes: [ReadWriteOnce]
Z2JH config of kubespawner based on Z2JH config:
if storage_type == 'dynamic':
pvc_name_template = get_config('singleuser.storage.dynamic.pvcNameTemplate')
c.KubeSpawner.pvc_name_template = pvc_name_template
volume_name_template = get_config('singleuser.storage.dynamic.volumeNameTemplate')
c.KubeSpawner.storage_pvc_ensure = True
set_config_if_not_none(c.KubeSpawner, 'storage_class', 'singleuser.storage.dynamic.storageClass')
set_config_if_not_none(c.KubeSpawner, 'storage_access_modes', 'singleuser.storage.dynamic.storageAccessModes')
set_config_if_not_none(c.KubeSpawner, 'storage_capacity', 'singleuser.storage.capacity')
# Add volumes to singleuser pods
c.KubeSpawner.volumes = [
{
'name': volume_name_template,
'persistentVolumeClaim': {
'claimName': pvc_name_template
}
}
]
c.KubeSpawner.volume_mounts = [
{
'mountPath': get_config('singleuser.storage.homeMountPath'),
'name': volume_name_template
}
]
A spawned user pods specs
spec:
# ...
volumes:
- name: volume-erik-2esundell
persistentVolumeClaim:
claimName: claim-erik-2esundell
Docs about the volumes
configurable on kubespawner
Kubespawners actual usage of the volumes
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top GitHub Comments
I just tried to create a PVC with
volumeName
set:But the creation of PVC not completed because I think it searches for a PV with this name and it doesn’t exist. I commented the line with
volumeName
and this time PVC is created with PV with a random name. I am not completely sure but ifvolumeName
config is set, in the code we first should create a PV withclaimRef
to the PVC and when PVC is created, it will be bound it.Hmmm, I’m not confident about what happens if you create the full cluster itself, but if you delete the namespace and the helm release etc, then I know the PVs created by the PVCs can be undeleted and things will can be fine. For that, see:
I’m curious to learn more about how a PV is coupled to a cluster, and if you could transfer it to another cluster, etc. I’ve only been using GKE, and never done such thing.