rancher / local-path-provisioner

Dynamically provisioning persistent local storage with Kubernetes
Apache License 2.0
2.17k stars 449 forks source link

Btrfs subvolume #21

Open runningman84 opened 5 years ago

runningman84 commented 5 years ago

It would be great if the provisioner could create a btrfs subvolume with quota for each PVC.

This would also give us snapshot and backup functionality using btrfs tools.

haslersn commented 3 years ago

I think this feature would be really great.

dvonessen commented 3 years ago

Hello, I think this is possible. You can use the setup and teardown bash scripts to create subvolumes. Requirements: local-path-provisioner version >= v0.0.15 Steps:

  1. kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml to get the local-path-provisioner into you kubernetes cluster.
  2. If you want to use btrfs tools, make sure you are using a helper image which has those tools available. By default local-path-provisioner uses busybox docker image. To change this kubectl edit deployments.apps -n local-path-storage local-path-provisioner and edit the container templates command. Append it with e.g. alpine linux image.
  3. kubectl edit configmaps local-path-config -n local-path-storage in the data object there edit setup and teardown as wished. eg.
    setup: |-                                                                                        
    #!/bin/sh                                                                                      
    path=$1                                                                                        
    echo "$@"                                                                                      
    apk add btrfs-progs
    btrfs subvolume create ${path}                                                                                                                                                 
    teardown: |-                                                                                     
    #!/bin/sh                                                                                     
    path=$1                                                                                        
    rm -rf ${path}                                                           

    For now it seems not possible to get btrfs subvolume delete ${path} working. I think the helper image hast to run as privileged or need some capabilities.

I hope that helps.

haslersn commented 3 years ago

Is there also an environment variable for the quota in the setup script?

I think btrfs subvolumes still need to be supported directly in local-path-provisioner (or similar project) in order to integrate it with the volume snapshot API, right?

nikolaishields commented 3 years ago

I'm glad to see there is some interest on this topic.

haslersn commented 3 years ago

@dvonessen What needs to be done in order to integrate this with the volume snapshot API?

nikolaishields commented 3 years ago

@dvonessen I can look into the permissions problems, As I've started to look into this issue it appears that there is a btrfs storage driver for docker. I plan on diving into the volume snapshot api later this week, but in the interim I came across the ember-csi which appears to have btrfs support in some capacity. Not sure if either of these will be of use, but they may provide context to solve the problem.

haslersn commented 3 years ago

The btrfs storage driver for docker is about storing images, not volumes.

MAFLO321 commented 2 years ago

Any updates on this? What needs to be done?

dylode commented 1 year ago

Any update/plans?

timoschwarzer commented 1 year ago

I have been working on a simple btrfs provisioner: https://github.com/timoschwarzer/btrfs-provisioner I eventually want to add support for automatic node selection, moving volumes between nodes (using btrfs send/receive) and more in the future.