Use JuiceFS in Kubernetes
JuiceFS can be mounted as a volume, and used as persistent storage for Kubernetes Pod.
Compared to other cloud storage services (like AWS EBS), JuiceFS comes with more features that better suit cloud environment:
- JuiceFS supports
ReadOnlyManyaccess mode, a JuiceFS volume can be mounted into multiple Pods, achieving concurrent reading / writing.
- Mount is not limited by availability zones, JuiceFS can be mounted in both cloud and local hosts.
- JuiceFS metadata service is by default deployed across two AZs, achieving high availability.
- Virtually unlimited storage capacity (10Pi), no need to plan ahead for scaling.
You can use JuiceFS in Kubernetes with the following methods:
- hostPath, for all Kubernetes versions.
- CSI, for Kubernetes v1.13 and above (CSI support is promoted to GA in v1.13).
- FlexVolume, for Kubernetes v1.2 and above, deprecated in favor of CSI.
This is the most simple and straightforward way to use JuiceFS in Kubernetes, just mount JuiceFS to all Kubernetes worker nodes, and then mount a JuiceFS directory into Kubernetes Pod, as a hostPath volume.
- name: test-volume
This method comes with some caveats:
- Obviously, all Pods in a single node will share a same JuiceFS Client (and its file system cache), thus you can't use JuiceFS in each Kubernetes application with different settings.
- Lifecycle for JuiceFS mount is essentially bind to node's uptime, umount is not an easy option because the one JuiceFS mountpoint is used in multiple Kubernetes Pods, you'll have to evict all Pods using JuiceFS in order to carry out a remount. For this reason, we recommend using Upgrade & Seamless remount to adjust JuiceFS mount options in runtime.
If flexibility and observability is a must for your scenario, we recommend using CSI Volume to integrate JuiceFS into Kubernetes. JuiceFS CSI comes with its own documentation, see JuiceFS CSI Driver.