Set up an NFS Server
KubeSphere supports NFS-client Provisioner as a storage plugin. In order to use it, you must configure the NFS server in advance. With the NFS server in place, an NFS client mounts a directory on the server machine so that files residing on the NFS server are accessible to the NFS client. Namely, you need to create and export a directory that your client machine can access.
Once your NFS server machine is ready, you can use KubeKey to install NFS-client Provisioner by Helm charts together with Kubernetes and KubeSphere. The exported directory of your NFS server must be provided in your Chart configurations used by KubeKey during installation.
Note
- You can also create the storage class of NFS-client after you install a KubeSphere cluster.
- NFS is incompatible with some applications, for example, Prometheus, which may result in pod creation failures. If you need to use NFS in the production environment, ensure that you have understood the risks. For more information, contact support@kubesphere.cloud.
This tutorial demonstrates how to install the NFS server on Ubuntu 16.04 as an example.
Install and Configure an NFS Server
Step 1: Install the NFS kernel server
To set up your server machine, you must install the NFS kernel server on it.
Run the following command so that you will be using the latest package on Ubuntu for installation.
sudo apt-get update
Install the NFS kernel server.
sudo apt install nfs-kernel-server
Step 2: Create an export directory
Your NFS client will mount a directory on the server machine which has been exported by the NFS server.
Run the following command to specify a mount folder name (for example,
/mnt/demo
).sudo mkdir -p /mnt/demo
For demonstration purposes, remove restrictive permissions of the folder so that all your clients can access the directory.
sudo chown nobody:nogroup /mnt/demo
sudo chmod 777 /mnt/demo
Step 3: Grant your client machine access to the NFS server
Run the following command:
sudo nano /etc/exports
Add your client information to the file.
/mnt/demo clientIP(rw,sync,no_subtree_check)
If you have multiple client machines, you can add them all in the file. Alternatively, specify a subnet in the file so that all the clients within it can access the NFS server. For example:
/mnt/demo 192.168.0.0/24(rw,sync,no_subtree_check)
Note
rw
: Read and write operations. The client machine will have both read and write access to the volume.sync
: Changes will be written to disk and memory.no_subtree_check
: Prevent subtree checking. It disables the security verification required for a client to mount permitted subdirectories.
Save the file when you finish editing it.
Step 4: Apply the configuration
Run the following command to export your shared directory.
sudo exportfs -a
Restart the NFS kernel server.
sudo systemctl restart nfs-kernel-server
Feedback
Was this page Helpful?
Receive the latest news, articles and updates from KubeSphere
Thanks for the feedback. If you have a specific question about how to use KubeSphere, ask it on Slack. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.