NFS (Network File System) enables file and directory sharing across a network. Here's the guide to set it up.
Update and install:
sudo apt update sudo apt install nfs-kernel-server
Create the directory:
sudo mkdir -p /srv/nfs/share
Set ownership and permissions:
sudo chown nobody:nogroup /srv/nfs/share sudo chmod 777 /srv/nfs/share
Add the following to `/etc/exports` (replace `<client_ip>`):
/srv/nfs/share <client_ip>(rw,sync,no_subtree_check)
Export the changes:
sudo exportfs -a
Enable and start the service:
sudo systemctl enable nfs-kernel-server sudo systemctl start nfs-kernel-server
Allow NFS traffic:
sudo ufw allow from <client_ip> to any port nfs
Enable UFW and check the status:
sudo ufw enable sudo ufw status
The client in this case is the server where Kubernetes is installed and running.
Update and install:
sudo apt update sudo apt install nfs-common
Create the directory:
sudo mkdir -p /mnt/nfs_clientshare
Mount the shared directory (replace `<nfs_server_ip>`):
sudo mount <nfs_server_ip>:/srv/nfs/share /mnt/nfs_clientshare
Check mounted filesystems:
df -h | grep nfs_clientshare
List files in the mounted directory:
ls /mnt/nfs_clientshare
Your NFS server and client setup is complete, enabling efficient file sharing over the network. Ensure regular updates and security checks for optimal performance.