Open topic with navigation

# Configuring the NFS Server

You can configure an NFS server using one of following methods:

- Configure a virtual machine which will be the host NFS server
- Configure the native NetApp service provided by Azure to provision NFS shares

## Configuring a Virtual Machine as the Host NFS Server

To create a VM NFS server using the Azure Portal:

1. Create a resource of type CentOS-based.
2. For Resource group, select your resource group.
3. In Virtual machine name, specify a VM name.
4. For Size, select Change size. In the popup, choose D4s_V3, and click OK to confirm. (You can select a different size according to your expected workload.)

5. Set the Authentication type to your preferences. Specify the Administration account details accordingly. In the examples given here, we use username/password authentication.

6. Click Next: Disks.

   By default, the VM has a small (30GB) disk for the operating system and approximately the same size for the temporary disk. For NFS, you need to attach a new disk with IOPS 1100 or later for better performance.

7. Click Create and attach a new disk.
8. Attach a new disk and select a size that meets your requirements. (IOPS should be 1100 or later.)

9. After you add the disk, change the value in Host Caching to Read/write.

10. Click Next: Networking

11. On the Networking tab, select values as follows:

    - Virtual network: select the virtual network you created earlier (for example, demo-vnet)
    - Subnet: select nfs-subnet
    - NIC network security group: select Basic

    - Public Inbound Ports: select None.

12. Click Review + create.
13. When validation completes, click Create.

To create a VM NFS server using the Azure Cloud Shell:

Required permissions: Create security groups, network interface and CentOS-based virtual machines

1. Set your main resource group name to an environment variable:

       RESOURCE GROUP=<your resource group name>

   For example:

       RESOURCE GROUP=srg-demo

2. Create a network security group for NFS by running this command:

       az network nsg create -g $RESOURCE_GROUP -n nfs-nsg

3. Get the nfs-subnet ID and store it to an environment variable for later usage. (You find subnet `nfs-subnet` in virtual network `demo-vnet` in resource group `srg-demo`.)

       SUBNET_ID=$(az network vnet list -g $RESOURCE_GROUP | jq -r '.[] | select(.name == "<your_virtual_network_name>") | .subnets[] | select(.name == "<your_NFS_subnet>") | .id')

4. Create the network interface `nfs-VMNic` in the subnet from previous command in your resource using network security group nfs-nsg by running the following command:

       az network nic create --name "nfs-VMNic" --resource-group $RESOURCE_GROUP --ip-forwarding  "true" --network-security-group "nfs-nsg" --subnet $SUBNET_ID

5. Create the NFS VM by running this command:

       az vm create --name "nfs" --resource-group $RESOURCE_GROUP --image "OpenLogic:CentOS:7.7:latest" --size "Standard_D4s_v3" --nics "nfs-VMNic" --data-disk-sizes-gb "256" --admin-username nfs  --admin-password myStrongPassword@!123

   Where:

   - `--size` is adjusted according to expected workload. To get a list of supported sizes, run the following command:

         az vm list-sizes -l <LOCATION> | jq ".[] | .name"

   - `--image` can be any supported CentOS. To get a list if CentOS images run the following command:

         az vm image list -l <LOCATION> -f CentOS --all

   - `--data-disk-sizes-gb` is specified according to workload. Use 256, 512, 1024 and so on.

     For example:

         {
           "fqdns":"",
           "id":"/subscriptions/af379ae8-90b3-4368-8fe7-b6a55ab17720/resourceGroups/srg-demo/providers/Microsoft.Compute/virtualMachines/nfs",
           "location":"westeurope",
           "macAddress":"00-0D-3A-AA-E4-F7",
           "powerState":"VM running",
           "privateIpAddress":"10.1.2.4",
           "publicIpAddress":"",
           "resourceGroup":"srg-demo",
           "zones":""
         }

     The private IP will be used to access the NFS VM from the jump host.

Format the Disk on the NFS VM Using the Azure Cloud Shell

To format the disk:

1. When your NFS VM deployment completes, determine its private IP address using the `az` command. Note the value for later usage.

2. From your jump host, SSH to the VM using its private IP address.

   For example:

       ssh nfs@10.1.2.4

3. Log in using the user and password you specified earlier for the NFS VM.
4. Become `root`.

5. Find the device for the data disk by executing the command:

       fdisk -l

   This will give you a list of existing disks. Usually the one added is named `/dev/sdc`.

6. Create a new primary partition on the whole device using `fdisk /dev/sdc`. Set it as type 83 - Linux.

   For example:

       fdisk /dev/sdc
       Welcome to fdisk (util-linux 2.23.2).

       Changes will remain in memory only, until you decide to write them.
       Be careful before using the write command.
       Device does not contain a recognized partition table
       Building a new DOS disklabel with disk identifier 0xc6a2cea5.
       The device presents a logical sector size that is smaller than
       the physical sector size. Aligning to a physical sector (or optimal
       I/O) size boundary is recommended, or performance may be impacted.

       Command (m for help): n
       Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
       elect (default p): p
       S

       Partition number (1-4, default 1):
       First sector (2048-536870911, default 2048):
       Using default value 2048

       Last sector, +sectors or +size{K,M,G} (2048-536870911, default 536870911):
       Using default value 536870911
       Partition 1 of type Linux and of size 256 GiB is set

       Command (m for help): w
       The partition table has been altered!

7. After saving the new partition table, run the command:

       mkfs.xfs /dev/sdc1

8. Create a mount point. Run the command:

       mkdir /nfs

9. Get the partition UUID. Run the command:

       blkid /dev/sdc1

   For example:

       /dev/sdc1: UUID="3696c212-1778-43d5-9d27-d9164686c327" TYPE="xfs"

10. In a text editor, open the file `/etc/fstab`, and add an entry to have this new partition mounted after restart. For example:

        UUID=3696c212-1778-43d5-9d27-d9164686c327 /nfs xfs defaults 0 0

11. Mount a new disk partition. Run the command:

        mount -a

12. Verify that it is properly mounted. Run the command:

        df -h

    For example:

        Filesystem      Size  Used Avail Use% Mounted on
        /dev/sda2        30G  1.3G   29G   5% /
        devtmpfs        7.9G     0  7.9G   0% /dev
        tmpfs           7.9G     0  7.9G   0% /dev/shm
        tmpfs           7.9G  9.0M  7.9G   1% /run
        tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
        /dev/sda1       497M   65M  433M  13% /boot
        /dev/sdb1        99G   61M   94G   1% /mnt/resource <- Azure temporary drive
        tmpfs           1.6G     0  1.6G   0% /run/user/0
        /dev/sdc1       264G   33M  264G   1% /nfs          <- your new partition for suite installation

Prepare the NFS Server and Export Mount Points

To prepare the server:

1. Check if `nfs-utils` is installed.

       rpm -qa | grep nfs-utils

   Sample ouput: `nfs-utils-1.3.0-0.61.el7.x86_64`. The version shown might vary depending on your operating system.

2. If `nfs-utils` is not installed, install it by running the following command:

       yum install -y nfs-utils

3. Configure NFS. Below is the suggested structure of the NFS volumes.

       /nfs/itom-vol
       /nfs/db-single-vol
       /nfs/db-backup-vol
       /nfs/itom-logging-vol
       /nfs/arcsight-volume

4. For every NFS volume, run the following set of commands on the VM for NFS.

       mkdir -p /nfs/volume_name
       chown -R <uid>:<gid> /nfs/volume_name
       echo "/nfs/volume_name *(rw,sync,anonuid=<uid>,anongid=<gid>,all_squash)">>/etc/exports

   For example:

       mkdir -p /nfs/itom-vol
       chown -R 1999:1999 /nfs/itom-vol
       echo "/nfs/itom-vol *(rw,sync,anonuid=1999,anongid=1999,all_squash)">>/etc/exports

   If you use a UID/GID different than 1999/1999, then provide it during the OMT installation in the install script arguments `--system-group-id` and --system-user-id. In addition, if you are using NetApp with NFSv4 configuration, consider applying stickybits to all <NFS_root_directory> shares with:

   `chmod g+w #chmod g+s`

5. (Conditional) If Intelligence is part of the deployment, run the following commands only for arcsight-volume so that the Logstash and Elasticsearch pods do not fail because of permission issues:

       cd /nfs/arcsight-volume
       chown -R 1999:1999 /nfs/arcsight-volume
       echo "/nfs/arcsight-volume *(rw,sync,anonuid=1999,anongid=1999,all_squash)">>/etc/exports

6. After configuring all five required volumes, run the following commands.

       exportfs -ra
       systemctl restart rpcbind
       systemctl enable rpcbind
       systemctl restart nfs-server
       systemctl enable nfs-server

The NFS configuration is now complete.

## Using NetApp as an NFS Server

You can use Azure's NetApp service as an NFS server. To request access to the service, see the Azure NetApp Files waitlist submission page. You must wait for an official confirmation email from the Azure NetApp Files team before continuing.

Create the NetApp Account

To create your NetApp account using the Azure Portal:

1. Create a resource of type Azure NetApp Files.
2. Choose a name and your subscription for the resource.
3. For Resource group, select your Kubernetes resource group where you have your virtual network and subnet for NFS.
4. For Location, select your resource group as in Step 3.
5. Click Create and wait for account creation.

To create your NetApp account using the Azure Cloud Shell:

1. Set your main resource group name to an environment variable:

       RESOURCE_GROUP=<your resource group name>

   For example:

       RESOURCE_GROUP=srg-demo

2. Create the NetApp account by running the following command:

       az netappfiles account create -g $RESOURCE_GROUP --name <ACCOUNT_NAME> -l <LOCATION>

   For example:

       az netappfiles account create -g $RESOURCE_GROUP --name SrgDemoNetAppAdmin -l westeurope

   Where:

   - `<ACCOUNT NAME>` is your NetApp account name.

   - `<LOCATION>` is the same as for AKS.

Set Up the NetApp Capacity Pool

To set up the capacity pool using the Azure Portal:

1. In the Azure NetApp Files tab, browse to your NetApp account.

2. In Storage Services, select Capacity Pools.

3. Click + and specify values for the following:

   - Name: specify a name for the pool.
   - Service Level: select a service level.
   - Pool Size: specify 4 (TB) for the pool size. (This is a service minimum.)

To set up the capacity pool using the Azure Cloud Shell:

1. Set your main resource group name to an environment variable:

       RESOURCE_GROUP=<your resource group name>

   For example:

       RESOURCE_GROUP=srg-demo

2. Run the command:

       az netappfiles pool create -g $RESOURCE_GROUP --account-name <ACCOUNT_NAME> --name <POOL_NAME> -l <LOCATION> --size 4 --service-level premium

   Where:

   - `<POOL_NAME>` is your new pool name

   - `<ACCOUNT_NAME>` is the NetApp account name specified in previous step

   For example:

       az netappfiles pool create -g $RESOURCE_GROUP --account-name SrgDemoNetAppAdmin --name srg-demo-pool-name -l westeurope --size 4 --service-level premium

Create and Prepare the Volume

To create and prepare the volume using the Azure Portal:

1. In your NetApp account resource, browse to Storage service.
2. Select Volumes.
3. Press + Add volume.
4. Specify a name for the volume
5. Ensure that your volume is in the same virtual network as `aks-virtual-network` and `nfs-subnet.`

6. For Subnet, select nfs-subnet.

   Under Subnet delegation, the subnet must be delegated to `Microsoft.NetApp/volumes.`
7. Click Next:Protocol
8. Ensure that the Protocol type is NFS and Version is NFSv4.1.
9. In the Export policy section, select the check box for 0.0.0.0/0 Read & Write.
10. Specify the file path that will be used to create the export path for the volume.
11. Click Review + Create at the bottom of the page. If you are satisfied with your settings, click Create.

To create and prepare the volume using the Azure Cloud Shell:

1. Set your main resource group name to an environment variable:

       RESOURCE GROUP=<your resource group name>

   For example:

       RESOURCE GROUP=srg-demo

2. Run the command:

       az netappfiles volume create \
       -g $RESOURCE_GROUP \
       --account-name <ACCOUNT_NAME> \
       --pool-name <POOL_NAME> \
       --name <VOLUME_ROOT> -l <LOCATION> \
       --service-level premium \
       --usage-threshold <VOLUME_SIZE> \
       --file-path <FILE_PATH> \
       --vnet <VIRTUAL_NETWORK> \
       --subnet <NFS_SUBNET_NAME> \
       --protocol-types NFSv4.1 \
       --rule-index <INDEX> \
       --allowed-clients <CLIENT_LIST>

   Where:

   - `<INDEX>` integer number of nfs creation rule.

   - `<ACCOUNT_NAME>` is your netApp account name.

   - `<POOL_NAME>` is the capacity pool created previously.

   - `<VOLUME_ROOT>` is your volume root name.

   - `<LOCATION>` is location of your NetApp.

   - `<VOLUME_SIZE>` size for NFS volume in GB.

   - `<FILE_PATH>` is the path to your volumes. This must be set to `nfs`.

   - `<VIRTUAL_NETWORK>` the virtual network to which your subnets belong.

   - `<NFS_SUBNET_NAME>` is your subnet for NFS.

   - `<CLIENT_LIST>` is specified as comma-separated value (CSV) string with IPv4 CIDRs, IPv4 host addresses, and host names to access the NFS share. Make sure to include either the range of subnets or separate IPs/hostnames, including the jumphost.

     For example:

         az netappfiles volume create \
         -g $RESOURCE_GROUP \
         --account-name SrgDemoNetAppAdmin \
         --pool-name srg-demo-pool-name \
         --name volumename -l westeurope \
         --service-level premium \
         --usage-threshold 100 \
         --file-path "nfs" \
         --vnet demo-vnet \
         --subnet nfs-subnet \
         --protocol-types NFSv4.1 \
         --allowed-clients 20.120.3.0/24 \
         --rule-index 1

Configure and Create the Volumes

To configure and create the volumes:

1. Find your `<mount_path_ip>` and `<mount_path_file_name>` by navigating to your volume page. These parameters were confirmed in the previous step after successful creation of the prepared volume. Note both of these parameters for later use.

2. Log in to the jump host.

3. If not already present, install the NFS client by sudo:

       # yum install nfs-utils if not present

4. Get and unzip the file `cdf-deployer.zip.`

5. In the `scripts` folder, run the following command:

       sudo ./createFileStore.sh <mount_path_ip> <mount_path_file_name> <NFS_version>

   Where the <mount_path_file_name> is `/nfs.`

   For example:

       sudo ./createFileStore.sh "10.1.2.4" "/nfs" "4.1"

Next Step: Creating and Attaching the Data Disk to Nodes