In the last post, we got Longhorn set up for dynamic config storage. Now it’s time to integrate NFS so our media apps can access and store large files efficiently. I’m using TrueNAS as the NFS server to serve up shared media folders to all my k3s nodes.
🗂️ NFS Server Setup (TrueNAS)
On TrueNAS, I created a dataset called data
under my ZFS pool tank
with the following structure:
/mnt/tank/data
├── tv
├── movies
└── torrents
└── completed
I then created an NFS share:
- Path:
/mnt/tank/data
- Network:
10.0.0.0/24
- Mapall User:
nobody
- Mapall Group:
nogroup
Make sure the NFS service is running and set to start automatically.
⚙️ Installing NFS-Common on Each Node
On each k3s node, install NFS client tools:
sudo apt update
sudo apt install -y nfs-common
📦 Creating a PersistentVolume and PersistentVolumeClaim
We’ll now create a PV and PVC in Kubernetes to map the NFS export.
nfs-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: media-nfs-pv
spec:
capacity:
storage: 500Gi
accessModes:
- ReadWriteMany
nfs:
path: /mnt/tank/data
server: 10.0.0.3
persistentVolumeReclaimPolicy: Retain
nfs-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: media-nfs-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 500Gi
volumeName: media-nfs-pv
*storage is set to 500Gi even though I have more than 2Terabytes of available storage on my NAS. The storage label is not enforced by kubernetes so no need to be concerned.
Apply these:
kubectl apply -f nfs-pv.yaml
kubectl apply -f nfs-pvc.yaml
🔁 Mounting the PVC in an App
When deploying media apps (like Sonarr, Radarr, etc.), you can now use this PVC to mount media storage:
volumeMounts:
- name: media
mountPath: /media
volumes:
- name: media
persistentVolumeClaim:
claimName: media-nfs-pvc
Your apps can now read/write to /media/tv
, /media/movies
, etc.
Next up, we’ll deploy Portainer so we can visually manage our cluster and workloads easily!