create NFS volume for kubernetes simulating physical machine as a server

Опубликовано: 12 Февраль 2026
на канале: Ahmed Salah El-Din
64
like

Commands to run on the host:

sudo apt update
sudo apt install -y nfs-kernel-server
sudo mkdir -p /mnt/sharedfolder # Export directory
sudo chown nobody:nogroup /mnt/sharedfolder
sudo chmod 777 -R /mnt/

Allow Client Access:

The access to this folder should be given to the clients, this can be done by editting /etc/exports file

vi /etc/exports

Add this line at the end of the file

/mnt/sharedfolder clientIP(rw,sync,no_subtree_check)

replace the clientIP with worker node IP or the IP range

Export the shared directory:

sudo exportfs -a
sudo systemctl restart nfs-kernel-server

---

Commans to run on the client:

sudo apt update
sudo apt install -y nfs-common

Mount point:

Mount point should be set up to synchronize the contents of the NFS server on the client

sudo mkdir -p /mnt/sharedfolder_client
sudo mount serverIP:/mnt/sharedfolder /mnt/sharedfolder_client

Note: Replace serverIP with NFS host IP

Test the connection:

Create a directory on the server under this path /mnt/sharedfolder, it should be reflected on the client.