Skip to content

NFS Service Deployment

Note

The NFS service is not deployed within the Kubernetes cluster; it requires a separate machine.

Overview

NFS (Network File System) allows different machines and operating systems to share files over a network.

Prerequisites

  • Access to the public internet

Basic Information and Compatibility

Name Description
Path /nfsdata (ensure sufficient capacity and this is a data disk)
Offline Install Supported No
Supported Architectures amd64/arm64
Deployment Machine IP 192.168.100.105

Installation Steps

1. Preparation

1.1 Disable the Firewall Service

systemctl stop firewalld
systemctl disable firewalld

2. Installation

2.1 Install NFS Service

Run the following commands to install the required packages for the NFS server and create the mount directory (use a data disk; here /nfsdata is used as the data directory):

yum install -y rpcbind nfs-utils
mkdir /nfsdata

2.2 Configure NFS Shared Path

Run vim /etc/exports to create the exports file with the following content:

#/nfsdata *(insecure,rw,async,no_root_squash)
/nfsdata *(rw,no_root_squash,no_all_squash,insecure) 

2.3 Start NFS Service

Run the following commands to start the NFS service:

systemctl enable rpcbind
systemctl enable nfs-server
systemctl restart rpcbind
systemctl restart nfs-server

2.4 Verify Configuration

Check if the configuration is effective:

exportfs

Query the local NFS shared directories:

showmount -e localhost

3. Verify Deployment

3.1 Install Client

Run the following commands to install the required packages for the NFS client:

yum install -y nfs-utils

3.2 View Shared Directories

Note

192.168.100.105 is the test IP used in this guide; replace it with your NFS server address.

Run the following command to check if the NFS server has shared directories set up:

# showmount -e $(NFS server IP)
showmount -e 192.168.100.105
# Example output:
Export list for 192.168.100.105:
/nfsdata *

3.3 Remote Mount Test

Note

192.168.100.105 is the test IP used in this guide; replace it with your NFS server address.

Run the following commands to mount the shared directory from the NFS server to the local path /data:

mkdir /data
# mount -t nfs $(NFS server IP):/nfsdata /data
mount -t nfs 192.168.100.105:/nfsdata /data
# Write a test file
echo "hello nfs server" > /data/test.txt

3.4 Check Test Results

On the NFS server, run the following command to verify that the file was written successfully:

cat /nfsdata/test.txt

Successful test output:

hello nfs server

Feedback

Is this page helpful?