A common scenario involves using a Network File System (NFS) Server to provide access to shared data for multiple workloads in an application. Examples include storing files that have been uploaded from users by one service for processing in another or data provided by an external batch processing system running outside of the Kubernetes cluster.
In this tutorial we will create a Static Resource Definition in Humanitec to allow an already running NFS Server to be accessed as a volume from a container running in a Workload.
You will require:
An account with the Administrator role on your organization.
An App set up in Humanitec.
A running NFS Server that is accessible from the cluster you are deploying to.
Navigate to the Static Definitions section of the Organization Settings screen in Humanitec.
Add a new Persistent Volume resource type
Choose an ID to identify this resource definition later.
Select the nfs
driver
Provide the path of the filesystem to mount on the NFS server
Provide the IP or DNS name of the NFS Server
Click the Create button to create the definition.
In order have control over which environments will use the NFS server, you can match it to an environment type.
Click the ➕ button in the Environment Type Column
Choose the Environment Type to match the resource definition to.
Navigate to the Workload Details Screen for the workload you want to make the volume available for. Make sure you are in Draft mode
Add an "Persistent Volume" resource by selecting from the drop down in the External Resources section of the Container Panel.
Choose an ID for the volume. You will use this to identify the volume when you setup volume mounts in your containers.
Select the container that you want to configure a mount for.
Select the ID you chose in the previous step
Choose the path to mount the volume on. The path must be rooted and cannot be in the root of the filesystem.
Choose whether the mount should be writable by the container.
Optional. Choose a sub-directory in the NFS to mount instead of the root.
Click the Create button to add the volume mount to the container.