Closed dsonck92 closed 4 years ago
@dsonck92 I didn't really consider it because:
Of course usecases are not limited to kubernetes providers, so it may also be useful to allow ZFS to be used as NFS exports. But there is probably less demand for this and at this moment. I don't think that feature is worth the work involved. However if you would like to try I can take a look for sure :)
Yes I noticed that it was more or less a separate part inside nfs.py and fs.py. The kubernetes-zfs-provisioner looks interesting however I cannot currently tell if it's possible to have it externally as targetd currently allows. I keep my storage separate from kubernetes (as a good practice) and I intend to keep it that way.
Indeed the iscsi-provisioner currently only handles iscsi but I imagine it should not be too difficult to actually let it create NFS shares based on the configuration it receives from the StorageClass. In my case I need to use NFS for some WriteMany volumes I also want to access externally.
On the other hand, adapting the iscsi-provisioner to an nfs-provisioner with targetd backend should not be too difficult either and might be cleaner in a sense.
I will look into how much effort it takes to add it, Python (and go in case of iscsi-provisioner) is not unknown to me and from an initial look, NFS seems to be written with multiple backends in mind, just btrfs being the only implementation of it.
-- EDIT: that comment and close is way too close
I've started on this over at https://github.com/dsonck92/targetd/tree/zfs-nfs-exports and currently at a stage where fs is forwarding information to backends.btrfs in a filesystem agnostic way. The special subvolumes for snapshots and subvolumes don't work on zfs and as such have been included in the backend. Instead, the fs package relies solely on uuids and resolves the actual names behind them which are then forwarded to the backends.
This results in the btrfs backend being able to map them to pool/targetd_fs/subvol and pool/targetd_ss/snapshot, while ZFS can resolve this to pool/subvol and pool/subvol@snapshot, with the ability to map readonly views from pool/subvol/.zfs/snapshots/snapshot
Meanwhile after implementing it I find https://github.com/democratic-csi/democratic-csi which actually handles remote zfs on linux for both iSCSI and NFS for kubernetes, which would exactly fit my use case. However, I prefer the targetd version as it's eventually less kubernetes centric and I would just need to monitor the targetd daemon instead of some pod that needs some elevated ssh access to setup pools and exports.
In addition, it seems to leverage the native ZFS NFS export function which could clash with my handwritten /etc/exports and had some caveats last time I used it so I still consider this issue and my pull request not obsolete.
I was recently looking into persistent volume provisioning for kubernetes and came across the iSCSI provisioner which uses targetd as backend which recently got ZFS support for iSCSI targets. After installing this on my storage host (and patching setup.py with #53) I managed to get it to work which is great.
I realized soon after configuring the ZFS options that targetd also supports NFS exports. But as I looked deeper, this is tied to btrfs. It might be useful to provide the same kind of solution to export ZFS datasets over NFS.
I'm actually willing to see if I can add support for this in a similar way as ZFS zvols are supported now. Although I think probing the target directory for its filesystem instead of providing a configuration option like "zfs_fs_pools" might be preferred.
@triluch considering you added ZFS zvol support, did you consider this already? If you did, any reasons for not (yet) including it?