rancher / local-path-provisioner

Dynamically provisioning persistent local storage with Kubernetes
Apache License 2.0
2.23k stars 453 forks source link

Make folder names configurable #302

Open mossroy opened 1 year ago

mossroy commented 1 year ago

Currently, the folder names are created with a hardcoded pattern: pvname_namespace_pvcname (see https://github.com/rancher/local-path-provisioner/blob/master/provisioner.go#L261).

It would be very useful to be able to use a different folder name pattern, like namespace-pvcname or namespace/pvcname

The goal is to have a predictable and stable directory name, which would have several advantages:

The nfs-subdir-external-provisioner has to do something very similar regarding folders, and has implemented what is necessary to make the pattern configurable. See https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/blob/master/cmd/nfs-subdir-external-provisioner/provisioner.go#L105

derekbit commented 1 year ago

Yeah, there is a similar request https://github.com/rancher/local-path-provisioner/issues/291.

derekbit commented 1 year ago

We still need to handle the existing volume folders.

Possible solutions are

  1. Adding a flag for enabling/disabling the new naming.
  2. Search the folder name using pvname_namespace_pvcname first. If not existing, search folder name using the new naming.

Any feedback is appreciated.

mossroy commented 1 year ago

I suppose you had the same situation when you implemented #77 ?

Maybe you could add an optional pathPattern setting, and use pvname_namespace_pvcname as its default value (if not set by the user of this provisioner). I suppose it's enough to make the feature retro-compatible?

IMHO, if the user sets or changes this pathPattern while already having directories, he is responsible of renaming the directories.

jcpunk commented 1 year ago

I'll confess interest in this - specifically for the ability to quickly lift and shift under disaster recovery.

Skaronator commented 1 year ago

Also looking for this feature to make disaster recovery simpler in my home lab. The suggestion in #291 looks great. Just use subdirs like namespace/pvc-name.

KyleSanderson commented 1 year ago

Any update on this?

KyleSanderson commented 2 months ago

@derekbit Happy Anniversary. Any luck with this one?

derekbit commented 2 months ago

@KyleSanderson Can you check whether https://github.com/rancher/local-path-provisioner/pull/385 is good enough?

KyleSanderson commented 2 months ago

@KyleSanderson Can you check whether #385 is good enough?

I think the author wrecked themselves, they only exposed PVC: opts.PVC.ObjectMeta, which doesn't let you get at ${.PVC.namespace}/${.PVC.name} anymore via the template like NFS and other provisioners (one of those screaming why! moments). Are you seeing the same thing?

If someone's going in there, adding https://github.com/Masterminds/sprig should let anyone do anything once all the necessary keys are exposed.