Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make folder names configurable #302

Open
mossroy opened this issue Feb 28, 2023 · 9 comments
Open

Make folder names configurable #302

mossroy opened this issue Feb 28, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@mossroy
Copy link

mossroy commented Feb 28, 2023

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:

  • it would be possible to create and populate the directory before the corresponding PVC is bound (i.e. before deploying the workload). Very useful when you're not starting from scratch, but need to initialize data. Without that improvement, you currently need to deploy the workload first (so that the PVC is bound), then remove it, remove the content of this directory (if any has been added by this first launch), then copy what you need in it, and redeploy the workload
  • it would really simplify some cases of Disaster Recovery Plan. For example, if your cluster is completely unavailable, but you have a copy of the folders (from a backup, for example), you could easily and quickly run it again on another cluster, just by transferring the folders and deploying the same manifests
  • when using a reclaimPolicy set to Retain, it would be much easier to transfer a stateful workload from one node to another one. You would only have to remove the workload & PVC, then move the directory to the target node, modify your workload to make it run on the target node, and deploy it again. Currently, it's more complicated because you have to move the directory content inside the new directory (and you don't know its name beforehand). It would also cover the case of renaming a node
  • when using a reclaimPolicy set to Retain, it would be possible to delete then recreate the PVC while keeping the data. Useful when the PVC has been deleted/recreated (by mistake or on purpose)

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
Copy link
Member

Yeah, there is a similar request #291.

@derekbit
Copy link
Member

derekbit commented Feb 28, 2023

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.

@derekbit derekbit added the enhancement New feature or request label Feb 28, 2023
@mossroy
Copy link
Author

mossroy commented Feb 28, 2023

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
Copy link

jcpunk commented Apr 18, 2023

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

@Skaronator
Copy link

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.

Skaronator added a commit to Skaronator/homelab that referenced this issue Jun 24, 2023
Since PVC paths are not predictable its unusable for me.

rancher/local-path-provisioner#302
Skaronator added a commit to Skaronator/homelab that referenced this issue Jun 24, 2023
Since PVC paths are not predictable its unusable for me.

rancher/local-path-provisioner#302
Skaronator added a commit to Skaronator/homelab that referenced this issue Jun 24, 2023
Since PVC paths are not predictable its unusable for me.

rancher/local-path-provisioner#302
Skaronator added a commit to Skaronator/homelab that referenced this issue Jun 24, 2023
Since PVC paths are not predictable its unusable for me.

rancher/local-path-provisioner#302
@KyleSanderson
Copy link

Any update on this?

@KyleSanderson
Copy link

@derekbit Happy Anniversary. Any luck with this one?

@derekbit
Copy link
Member

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

@KyleSanderson
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants