Configure NFS

This section describes how to configure Network File System (NFS) for the KubeSphere cluster in a production environment.

Note

NFS is incompatible with some applications (such as Prometheus), which may cause pod creation failure. If you do need to use NFS in a production environment, make sure you understand the risks or consult KubeSphere technical support at support@kubesphere.cloud.

Build NFS Server

Before configuring NFS for KubeSphere, you need to set up an NFS server first. If you already have an NFS server available, you can skip this step. The following uses the Ubuntu operating system and NFS Kernel Server as an example to introduce how to build an NFS server. For specific operations on other NFS servers and other operating systems, see the user guides for the NFS servers and operating systems.

Prerequisites

You need to prepare a Linux server (the Ubuntu operating system is used as an example below), which must be connected to the KubeSphere cluster node network.

Steps

  1. Log in to the server used to build the NFS server and execute the following command to install the NFS Kernel Server:

    1. sudo apt update
    1. sudo apt install nfs-kernel-server
  2. Execute the following command to create a directory for use by KubeSphere (replace <directory> with the actual directory path, such as /mnt/demo):

    1. sudo mkdir -p <directory>
  3. Execute the following command to remove access restrictions on the directory (replace <directory> with the actual directory path, such as /mnt/demo):

    1. sudo chown nobody:nogroup <directory>
    1. sudo chmod 777 <directory>
  4. Execute the following command to edit the configuration file of NFS Kernel Server:

    1. sudo vi /etc/exports
  5. Add the KubeSphere cluster node information to the file to allow the server to access the NFS server, and save the file:

    1. <directory> <IP address>(rw,sync,no_subtree_check)

    Replace the following parameters with actual values:

    ParameterDescription

    <directory>

    The directory used by KubeSphere, for example /mnt/demo.

    <IP address>

    The IP address of the KubeSphere cluster node, for example 192.168.0.2.

    If there are multiple KubeSphere cluster nodes, please set multiple configuration entries. You can also set <IP address> to a network segment so that all servers in the network segment can access the NFS server, for example 192.168.0.0/24.

  6. Execute the following command to enable directory sharing:

    1. sudo exportfs -a
  7. Execute the following command to restart the NFS server to make the configuration take effect:

    1. sudo systemctl restart nfs-kernel-server

Configure Cluster Nodes

After the NFS server is built, you need to install the client tool on the KubeSphere cluster nodes and create a configuration file for subsequent installation of KubeSphere. After KubeSphere is installed, the NFS server specified in the configuration file will be used as persistent storage. The following uses the Ubuntu operating system to install NFS Common as an example to introduce how to install the NFS client and create a configuration file. For specific operations on other NFS clients and other operating systems, see the user guides for the NFS clients and operating systems.

Prerequisites

You should set up an NFS server. For more information, see Build NFS Server.

Steps

  1. Log in to all KubeSphere cluster nodes and execute the following command to install nfs-common:

    1. sudo apt update
    1. sudo apt install nfs-common
  2. Log in to the cluster node used to perform the KubeSphere installation and execute the following command to create the configuration file for NFS storage plugin:

    1. vi nfs-client.yaml
  3. Add the following information to the configuration file and save the file for subsequent installation of KubeSphere:

    1. nfs:
    2. server: "<IP address>"
    3. path: "<directory>"
    4. storageClass:
    5. defaultClass: true

    Replace the following parameters with actual values:

    ParameterDescription

    <IP address>

    IP address of the NFS server.

    <directory>

    The directory of NFS server used by KubeSphere.

    The above configuration file only contains the parameters that must be set. To set other parameters, see NFS Client Configuration.