NFS Server Deployment on OpenShift

 

This document provides a detailed guide for deploying an NFS (Network File System) server on OpenShift. Follow the steps below to set up and configure the NFS server, and ensure it integrates smoothly with your OpenShift environment.
Prerequisites

Before starting with the deployment and configuration of the NFS (Network File System) server on OpenShift, ensure the following prerequisites are met:

  1. OpenShift Cluster: Ensure you have an operational OpenShift cluster with administrative access.

  2. Access to a Server: A server (EC2 instance or similar) that will host the NFS server, with root or sudo privileges.

  3. Network Configuration: Ensure the server and the OpenShift cluster can communicate over the network. Specifically, ensure the NFS server security group allows traffic on TCP port 2049.

  4. Disk for NFS Share: A dedicated disk available on the server for use as the NFS share.

  5. Installed CLI Tools: Ensure the following CLI tools are installed and accessible:

    • oc (OpenShift CLI)

    • yum (or another package manager if using a different OS)

  6. Security Context Constraints (SCC): Ensure you have permissions to edit and apply SCCs in your OpenShift cluster.

  7. Service Account: Ensure the nfs-client-provisioner service account is created in your OpenShift cluster.

  8. NFS Utilities: Ensure NFS utilities can be installed on the server.

Ensure that all these prerequisites are met before proceeding with the deployment steps.

Step 1: Install NFS Utilities

Log in to your server and switch to the root user:

[ec2-user@ip-10-0-14-162 ~]$ sudo -i

Install the necessary NFS utilities:

[root@ip-10-0-14-162 ~]# yum install -y nfs-utils

Ensure the installation was successful:

Last metadata expiration check: 0:14:06 ago on Thu May 30 08:24:15 2024. Package nfs-utils-1:2.5.4-2.rc3.amzn2023.0.3.x86_64 is already installed. Dependencies resolved. Nothing to do. Complete!

Step 2: Enable and Start NFS Services

Enable and start the rpcbind and nfs-server services:

Step 3: Create the NFS Share Directory

Create the directory that will be shared via NFS:

Step 4: Prepare the Disk for NFS

Identify and format the disk to be used for the NFS share:

Example output of formatting:

Step 5: Verify and Repair Filesystem

Check for any hardware errors related to the device:

If necessary, check and repair the filesystem:

Step 6: Configure NFS Exports

Edit the /etc/exports file to export the /nfs-share directory:

Add the following line:

Export the directory:

Verify the export:

Example output:

Step 7: Configure OpenShift Security Context

Edit the Security Context Constraints (SCC) to allow NFS volumes. Open the hostmount-anyuid SCC:

Add "nfs" to the volumes field:

Step 8: Allow Service Account to Use SCC

Add the nfs-client-provisioner service account to the hostmount-anyuid SCC:

Verify the changes:

Step 9: Update NFS Server Security Group

Update the NFS server security group to allow TCP port 2049.

Step 10: Apply NFS Manifest

Apply the NFS manifest to your OpenShift cluster, while applying the manifest, don’t forget to update with the private IP of your NFS sever , at the last section of the manifest

 

This document provides a comprehensive guide for deploying and configuring an NFS server on OpenShift, ensuring proper integration and security configuration for seamless operation.