<p>I have a 3 nodes cluster running in VirtualBox and I'm trying to create a NFS storage using PV and PVC, but it seems that I'm doing something wrong.</p>

<p>I have the following:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: redis-pv
  labels:
    type: nfs
spec:
  capacity:
    storage: 100Mi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: slow
  mountOptions:
    - hard
    - nfsvers=4.1
  nfs:
    path: /redis/data
    server: 192.168.56.2 #ip of my master-node
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redis-pvc
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 100Mi
  storageClassName: slow
  selector:
    matchLabels:
      type: nfs
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-master
  labels:
    app: redis
spec:
  selector:
    matchLabels:
      app: redis
      role: master
      tier: backend
  replicas: 1
  template:
    metadata:
      labels:
        app: redis
        role: master
        tier: backend
    spec:
      containers:
      - name: master
        image: redis
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - name: data
          mountPath: "/redis/data"
        ports:
        - containerPort: 6379
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: redis-pvc
</code></pre>

<p>I've already installed <code>nfs-common</code> in all my nodes.</p>

<p>Whenever creating the PV, PVC and POD the pod does not start and I get the following:</p>

<pre><code>Warning  FailedMount  30s    kubelet, kubenode02  MountVolume.SetUp failed for volume "redis-pv" : mount failed: exit status 32
Mounting command: systemd-run
Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/9326d818-b78a-42cc-bcff-c487fc8840a4/volumes/kubernetes.io~nfs/redis-pv --scope -- mount -t nfs -o hard,nfsvers=4.1 192.168.56.2:/redis/data /var/lib/kubelet/pods/9326d818-b78a-42cc-bcff-c487fc8840a4/volumes/kubernetes.io~nfs/redis-pv
Output: Running scope as unit run-rc316990c37b14a3ba24d5aedf66a3f6a.scope.
mount.nfs: Connection timed out
</code></pre>

<p>Here is the status of <code>kubectl get pv, pvc</code></p>

<pre><code>NAME                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM               STORAGECLASS   REASON   AGE
persistentvolume/redis-pv   100Mi      RWO            Retain           Bound    default/redis-pvc   slow                    8s

NAME                              STATUS   VOLUME     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/redis-pvc   Bound    redis-pv   100Mi      RWO            slow           8s
</code></pre>

<p>Any ideas of what am I missing?</p>

Juliano Costa
<p>1 - you need to install your NFS Server: Follow the instructions in this link: </p>

<p><a href="https://vitux.com/install-nfs-server-and-client-on-ubuntu/" rel="nofollow noreferrer">https://vitux.com/install-nfs-server-and-client-on-ubuntu/</a></p>

<p>2- Create your sharedfolder where you want to persist your data&lt;</p>

<pre><code>mount 192.168.56.2:/mnt/sharedfolder /mnt/shared/folder_client
</code></pre>

<p>3- Change in PV.yaml the following instructions:</p>

<pre><code>apiVersion: v1

    kind: PersistentVolume
    metadata:
      name: redis-pv
      labels:
        type: nfs
    spec:
      capacity:
        storage: 100Mi
      volumeMode: Filesystem
      accessModes:
        - ReadWriteOnce
      persistentVolumeReclaimPolicy: Retain
      storageClassName: slow
      mountOptions:
        - hard
        - nfsvers=4.1
      nfs:
        path: /mnt/sharedfolder
        server: 192.168.56.2 #ip of my master-node
</code></pre>
