Code With Ben Knox

Setting Up A Network File Share in DOKS

Kubernetes

September 20th, 2025

When I was getting started with Kubernetes in DigitalOcean I created a few services that needed persistent storage in my cluster. I quickly ran into a problem though because the default setting for block storage in DigitalOcean is ReadWriteOnce (RWO). This means the volume could only connect to one node, scaling my cluster couldn't happen. The solution: ReadWriteMany with a Network File Share (NFS for short). This article is a simple guide for setting that up in your cluster.


Pre-requisites

- You must have some basic knowledge of Kubernetes and how to use kubectl on the command line

- An understanding of helm

- An understanding of the various types of object in a Kubernetes cluster

- A Kubernetes cluster in DigitalOcean, sign up here and get $200 free to follow along


1. Create An NFS Server

The first step is creating an NFS server, there are are a few different ways you can do this. You can set up a droplet or you can create a stateful set in your cluster, for this article we'll create a stateful set.


Disclaimer: in production it would probably good to use a droplet and set up firewalls so your cluster can connect, there are instructions in the link to the droplet above to set up networking.


In order to create our nfs server we will install this helm chart: kvaps/nfs-server-provisioner.


Create a file named nfs-server-provisioner.yaml somewhere locally, adding this persistence configuration will keep our files from being deleted each time the pod restarts:

Run this command after saving the file above (make sure to update the path so it matches the location of your file):


This helm installation will create a stateful set and a service we can network to within the cluster automatically. In the next step we'll use the NFS server we created here, you'll see that we will be able to use our required ReadWriteMany mode.


If all is done correctly, you should see an NFS server pod running and a new volume should have automatically been create in your DigitalOcean console.


2. Create A ReadWriteMany Persistent Volume Claim

The next part of this is fairly straightforward, we need to create a persistent volume claim for our deployments like we normally would using the NFS server we just created in the cluster.


We'll set our share to 5Gi, although the size doesn't really matter for an NFS persistent volume. You will be able to use up the entire 10Gi so its just metadata:


To test this you can mount this to a pod or deployment, here's a test pod:

If you shell into the container created above, you'll see that the /mnt/nfs directory has your volume mounted to it, and it wouldn't matter which node in your cluster the pod is in, it will still be able to connect and access the files.


Conclusion

And that's actually everything you really need to do to make a ReadWriteMany persistent volume in DigitalOcean Kubernetes Service. Using this method your cluster can scale on to other nodes and share data across pods. 😍


More Kubernetes