jupyterhub / kubespawner

Kubernetes spawner for JupyterHub
https://jupyterhub-kubespawner.readthedocs.io
BSD 3-Clause "New" or "Revised" License
546 stars 304 forks source link

Add support for storage_selector through configuration. #336

Open GrahamDumpleton opened 5 years ago

GrahamDumpleton commented 5 years ago

There should be a way of configuring a selector for a persistent volume claim.

$ kubectl explain pvc.spec.selector
KIND:     PersistentVolumeClaim
VERSION:  v1

RESOURCE: selector <Object>

DESCRIPTION:
     A label query over volumes to consider for binding.

     A label selector is a label query over a set of resources. The result of
     matchLabels and matchExpressions are ANDed. An empty label selector matches
     all objects. A null label selector matches no objects.

FIELDS:
   matchExpressions <[]Object>
     matchExpressions is a list of label selector requirements. The requirements
     are ANDed.

   matchLabels  <map[string]string>
     matchLabels is a map of {key,value} pairs. A single {key,value} in the
     matchLabels map is equivalent to an element of matchExpressions, whose key
     field is "key", the operator is "In", and the values array contains only
     "value". The requirements are ANDed.

This will allow for a pool of persistent volumes setup in a certain way, including with existing content loaded in the volume, to be pre-created and for the persistent volume claim to match them via the storage label selector.

consideRatio commented 4 years ago

A note about the implementation, it should be made as closely mapped to the k8s naming as possible. So, if it is a specification of matchLabels, it should reflect that.