Volumes in TrueFoundry offer a robust way to connect persistent data storage to your deployments.
Here, we'll explore three different methods for attaching volumes to a deployment:
- Through the user interface (UI)
- Using the Python SDK
- Via YAML configuration file
When working with deployments, the TrueFoundry UI provides an intuitive way to attach volumes. Follow these steps to add a volume to your deployment:
- Show Advanced Fields:
- Begin by navigating to the deployment form of the deployment you want to create/modify.
- Enable the "Show Advanced Fields" toggle. This reveals advanced configuration options for your deployment.
- Enable Mounts:
- Scroll down to the bottom of the deployment configuration form.
- Locate the "Mounts" field and click on the toggle to enable it. This enables the ability to add mount paths and attach volumes.
- Add Mount Path:
- Click on the "+ Add Mount Path" button. This allows you to define where you want to mount a volume within your deployment.
- Configure Mount Path:
In the configurations for the mount path, you will need to provide the following information:
- Mount Path: Enter the file path at which the volume will be mounted within your deployment.
- Data Type Dropdown: From the dropdown menu, select "Volume." This indicates that you are attaching a volume to the mount path.
- Volume FQN: Once you select "Volume" as the data type, the "Volume FQN" field will appear. Enter the Fully Qualified Name (FQN) of the volume that you want to attach to the specified mount path.
By following these steps, you can seamlessly connect volumes to your deployment using the TrueFoundry UI. This enables your deployment to access and utilize persistent data storage provided by the attached volume.
The Python SDK for TrueFoundry provides a programmatic way to attach volumes to your deployments. Here's how you can achieve it using the Python SDK:
from servicefoundry import VolumeMount # ... Other import and configuration ... # Define your deployment deployment = Job( # ... Other deployment configurations ... mounts=[ VolumeMount( mount_path="/models (or desired path)", volume_fqn="your-volume-fqn" ), # ... Additional VolumeMount instances ... ], # ... Other deployment configurations ... )
In the code above, the VolumeMount class is used to specify the details of the volume attachment. You need to provide the mount_path where you want to mount the volume within your deployment and the volume_fqn which represents the Fully Qualified Name (FQN) of the volume you want to attach.
You can also attach volumes to your deployment using YAML configuration. Here's an example of how you can do it:
# ... Other deployment configurations ... mounts: - type: volume mount_path: /models (or your desired path) volume_fqn: your-volume-fqn # ... Additional mounts ... # ... Other deployment configurations ...
In the YAML configuration above, within the mounts section, you define an array of mount configurations. Each mount configuration specifies the type (which should be set as "volume"), the mount_path where you want to attach the volume, and the volume_fqn representing the Fully Qualified Name (FQN) of the volume you want to attach.
Using these methods, you can effectively attach volumes to your deployments in TrueFoundry, enabling your applications to access and utilize persistent data storage provided by the attached volume.
Updated about 1 month ago