-
Notifications
You must be signed in to change notification settings - Fork 102
feat: Add DaemonSet mount mode for shared StorageClass mount pods #1407
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
base: master
Are you sure you want to change the base?
feat: Add DaemonSet mount mode for shared StorageClass mount pods #1407
Conversation
|
@elijah-rou Hi, please fix the conflicts, thanks! |
c5579c6 to
f3fe857
Compare
Introduces a new DaemonSet deployment mode for JuiceFS mount pods when
using StorageClass with mount sharing enabled. This feature provides
better resource management by deploying mount pods as DaemonSets instead
of individual shared pods, with configurable node affinity control
through ConfigMaps.
- **Three mount modes**: per-pvc (default), shared-pod, and daemonset
- **ConfigMap-based configuration**: Control mount mode and node
affinity via `juicefs-mount-config` ConfigMap
- **Node affinity support**: Restrict DaemonSet deployment to specific
nodes using standard Kubernetes node affinity
- **Automatic fallback**: Falls back to shared-pod mode if DaemonSet
cannot schedule on a node
- **Seamless transition**: Works with existing StorageClasses without
modification
- `pkg/juicefs/mount/mount_selector.go`: Dynamic mount type selection
based on configuration
- `pkg/juicefs/mount/daemonset_mount.go`: DaemonSet mount implementation
with scheduling error handling
- `pkg/config/mount_config.go`: ConfigMap parsing for mount mode and
node affinity
- `pkg/config/mount_config_helper.go`: Helper functions for DaemonSet
configuration
- `pkg/juicefs/mount/builder/daemonset.go`: DaemonSet resource builder
Mount modes are configured via ConfigMap in kube-system namespace:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: juicefs-mount-config
namespace: kube-system
data:
default: |
mode: shared-pod # Options: per-pvc, shared-pod, daemonset
my-storageclass: |
mode: daemonset
nodeAffinity: # Required for daemonset mode
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node.kubernetes.io/workload
operator: In
values: ["compute"]
```
- **pod_driver.go**: Skip DaemonSet pods in deletion/recreation handlers
- **juicefs.go**: Add MountSelector for dynamic mount type selection and
AuthFs serialization
- **k8sclient**: Add DaemonSet CRUD operations
- **RBAC**: Add DaemonSet permissions to CSI node service account
- `docs/en/guide/daemonset-mount.md`: Comprehensive usage documentation
- `docs/en/guide/mount-pod-configuration.md`: Mount pod configuration
guide
- `deploy/kubernetes/csi-daemonset-mount/`: Example DaemonSet
configurations
- `deploy/kubernetes/mount-config/`: Example ConfigMap configurations
- Unit tests for mount selector logic
- Unit tests for DaemonSet mount implementation
- ConfigMap parsing and validation tests
1. **Better resource utilization**: One mount pod per node instead of
per PVC
2. **Improved control**: Node affinity ensures mount pods only run where
needed
3. **Simplified operations**: Easier to manage and monitor as DaemonSets
4. **Automatic lifecycle**: DaemonSet controller handles pod
creation/deletion
5. **Backward compatible**: Works with existing StorageClasses and mount
sharing
1. Enable `STORAGE_CLASS_SHARE_MOUNT` in CSI Controller and Node
2. Grant DaemonSet RBAC permissions (included in updated manifests)
3. Create ConfigMap with desired mount mode configuration
4. New PVCs will automatically use configured mount mode
- Updated `deploy/k8s.yaml` and `deploy/k8s_before_v1_18.yaml` with
DaemonSet RBAC
- Added DaemonSet resource configurations
- Updated Docker build process for consistency
This feature enhances the JuiceFS CSI Driver's flexibility in managing
mount pods, particularly beneficial for large-scale deployments where
mount pod proliferation can become a resource management challenge.
f3fe857 to
025e12d
Compare
|
@zwwhdls I based this off the latest release version, has |
|
@elijah-rou Thanks a lot. It seems like this the whole process, please correct me if I say something wrong. When mount:
When umount:
Here are some issues that may not be considered:
And the most important thing I want to know is: What is the biggest benefit of daemonset mode compared by mount pod? In other words, what problem did it solve? |
|
Besides, CSI already has a global configmap where users can put configurations of mount pod. There is no need to introduce a new one, please use the global one. Thanks! |
|
I cannot test this mode in my clusters because it always falls back to per-pvc mode I0912 03:28:53.521652 7 mount_config.go:170] "Loaded mount configuration" logger="mount-config" storageClass="juicefs-local-fs-sc" deploymentMode="daemonset" hasNodeAffinity=true
I0912 03:28:53.521686 7 mount_selector.go:89] "Using per-PVC pod mount" logger="NodePublishVolume" appName="busybox-default-6d884fb446-wpgg9" volumeId="pvc-47cbeefe-6c18-4dee-ba80-f9ec4076e7ee"config: This PR will introduce breaking changes, I updated to this version, which broke my exist service, this is unacceptable. |
This mount mode has 2 main benefits:
I can put this in the global configmap
This is likely due to the rebase onto master. Based off the 0.29.2 branch (latest |
Version 0.30.0 introduces a new mode similar to shareStorage that reuses mount points for the same file system. docs are here https://juicefs.com/docs/csi/guide/resource-optimization/#share-mount-pod-for-the-same-file-system. The breaking change might be here, you shouldn't return the unique id of storage class for all modes. |
Introduces a new DaemonSet deployment mode for JuiceFS mount pods when using StorageClass with mount sharing enabled. This feature provides better resource management by deploying mount pods as DaemonSets instead of individual shared pods, with configurable node affinity control through ConfigMaps.
Three mount modes: per-pvc (default), shared-pod, and daemonset
ConfigMap-based configuration: Control mount mode and node affinity via
juicefs-mount-configConfigMapNode affinity support: Restrict DaemonSet deployment to specific nodes using standard Kubernetes node affinity
Automatic fallback: Falls back to shared-pod mode if DaemonSet cannot schedule on a node
Seamless transition: Works with existing StorageClasses without modification
pkg/juicefs/mount/mount_selector.go: Dynamic mount type selection based on configurationpkg/juicefs/mount/daemonset_mount.go: DaemonSet mount implementation with scheduling error handlingpkg/config/mount_config.go: ConfigMap parsing for mount mode and node affinitypkg/config/mount_config_helper.go: Helper functions for DaemonSet configurationpkg/juicefs/mount/builder/daemonset.go: DaemonSet resource builderMount modes are configured via ConfigMap in kube-system namespace:
pod_driver.go: Skip DaemonSet pods in deletion/recreation handlers
juicefs.go: Add MountSelector for dynamic mount type selection and AuthFs serialization
k8sclient: Add DaemonSet CRUD operations
RBAC: Add DaemonSet permissions to CSI node service account
docs/en/guide/daemonset-mount.md: Comprehensive usage documentationdocs/en/guide/mount-pod-configuration.md: Mount pod configuration guidedeploy/kubernetes/csi-daemonset-mount/: Example DaemonSet configurationsdeploy/kubernetes/mount-config/: Example ConfigMap configurationsUnit tests for mount selector logic
Unit tests for DaemonSet mount implementation
ConfigMap parsing and validation tests
Better resource utilization: One mount pod per node instead of per PVC
Improved control: Node affinity ensures mount pods only run where needed
Simplified operations: Easier to manage and monitor as DaemonSets
Automatic lifecycle: DaemonSet controller handles pod creation/deletion
Backward compatible: Works with existing StorageClasses and mount sharing
Enable
STORAGE_CLASS_SHARE_MOUNTin CSI Controller and NodeGrant DaemonSet RBAC permissions (included in updated manifests)
Create ConfigMap with desired mount mode configuration
New PVCs will automatically use configured mount mode
deploy/k8s.yamlanddeploy/k8s_before_v1_18.yamlwith DaemonSet RBACThis feature enhances the JuiceFS CSI Driver's flexibility in managing mount pods, particularly beneficial for large-scale deployments where mount pod proliferation can become a resource management challenge.