Kubernetes Persistent Volumes using NFS

Last modified by matto on 2018/09/03 05:19



Ubuntu 18.04

Enable private networking

First of all, enable private networking on your hosting control panel (I'm using vultr.com)

vi /etc/netplan/10-ens7.yaml

Make sure that it looks like:

  version: 2
  renderer: networkd
      mtu: 1450
      dhcp4: no
      addresses: [{your host private IP}/16]

 Replace the IP address with the one, which is displayed in your control panel in the private network settings

netplan apply

After that, you should see a new network interfacen, when you type:


Do this for each host in your cluster.

Then, you should be able to ping these private IPs between your host in your private network.

Install NFS server

apt install nfs-kernel-server

vi /etc/exports


Replace with your own private networking IP on which you have the server running.
Make sure that path you've specified is accessible and has correct permissions

apt-get install nfs-common

Then, try to mount the NFS folder: 

mkdir /mnt/nfs

mount /mnt/nfs 

(Replace with your own IP)

Voila ! when you access /mnt/nfs, it serves content from /share

This server shall be accessible within your private network. Make sure that you don't have it accessible to the outside world.

For further configuration options, please refer to 

Creating Kubernetes Persistent Volume

This assumes, that you should have your kubernetes cluster up and running.

Create a new file: pv.yaml:

apiVersion: v1
kind: PersistentVolume
  name: pv0001
    storage: 5Gi
  volumeMode: Filesystem
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  storageClassName: slow
    - hard
    - nfsvers=4.1
    path: /share

(Replace with your own IP and /share with the path the NFS server exports)

After that, execute:

kc create -f pv.yaml 

Check, if the Kubernetes persistent volume has been created successfully:

kubectl get pv

You should see something like:


Created by matto on 2018/06/06 04:25
CodeGravity.com ©
Analytics Made Easy - StatCounter