Manually setup NFS Server for a cluster¶
This guide describes the manual steps required for setting up a NFS server to store users’ home directories on the hub. More information about the NFS Server can be found in User home directory storage.
Deploy the host Virtual Machine¶
We need to first deploy a small virtual machine with a persistent disk that will host the NFS server.
You can use
gcloud commands to achieve this.
To find the values of
--image-project, run the following:
gcloud compute images list
| grep ubuntu to filter for Ubuntu images.
You can then check the image suits your needs by running:
gcloud computer images describe IMAGE_NAME --project=IMAGE_PROJECT
gcloud compute instances create nfs-server-01 \ --image=ubuntu-2004-focal-v20210720 \ --image-project=ubuntu-os-cloud \ --machine-type=g1-small \ --boot-disk-device-name=nfs-server-01 \ --boot-disk-size=100GB \ --boot-disk-type=pd-standard
The boot disk is where users’ home directories and data are stored.
Feel free to increase
--boot-disk-size if 100GB won’t be enough.
If deploying a NFS server for a private cluster, add the
--no-address flag to the
gcloud compute instances create command.
This will prevent the VM trying to claim an external IP address, which will not be allowed within the private configuration.
Setting up the NFS Server¶
Once your VM has been deployed, SSH into it so we can configure the NFS server.
gcloud compute ssh nfs-server-01
If the cluster you are setting up the NFS for is private, you will need to add the
--tunnel-through-iap flag to the above command.
This is because the VM will not have an external IP address and will therefore need to be routed differently.
Install the dependencies
sudo apt update sudo apt install nfs-kernel-server nfs-common
Create the appropriate directory
sudo mkdir -p /export/home-01
Set the appropriate permissions on the directory
sudo chmod -R 0700 /export/ sudo chown -R 1000:1000 /export/
Create the exports rule in the file
sudo nano /etc/exports # Create the file
/export/home-01 10.0.0.0/8(all_squash,anonuid=1000,anongid=1000,no_subtree_check,rw,sync) # Add this line to the bottom of the file
Run the export command
sudo exportfs -ra