NFS Persistent Volume Claim

This is a Kubernettes question, I have an RKE cluster and created on my rancher instance. I am trying to create some PVCs which will be NFS served from my FreeNAS server, and I am struggling to get this work, or event to find an example of it.

Can NFS only be defined as a volume directly in a POD?

What am I missing?

Hi,

you need to install the “Nfs-Client-Provisioner” in your cluster.
This creates a storage class “nfs-client” which you can use like
any other storage provider (except few NFS limits like storage size etc.).

At least the following answers have to be provided to access your server.

Volume

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-database-backup
  labels:
    tier: backend
    app: database-backup
spec:
  capacity:
    storage: 10Gi
  storageClassName: "nfs-client"
  accessModes:
    - ReadWriteMany
  nfs:
    server: nfs.example.com
    path: "/var/nfs/cluster-share/volumes/database-backup"

Volume Claim

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  namespace: yournamespace
  name: pvc-database-backup
  labels:
    tier: backend
    app: database-backup
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: "nfs-client"
  resources:
    requests:
      storage: 10Gi
  selector:
    matchLabels:
      tier: backend
      app: database-backup

Give it a try :slight_smile:

Edit: Perhaps, the provisioner seems to be really stable. We use it now for longer than two years
for different purposes (mostly backups) and never had any issues. Version upgrades worked
without any problems too in the past.

1 Like