Why Use Volumes?
By default, data written inside a container is ephemeral—it’s lost when the container restarts. Volumes solve this by providing:- Persistence: Data survives container restarts and redeployments
- Shared storage: Multiple containers can access the same data
- Data integrity: Critical data like databases is protected
Volume Types
Orchard supports three types of volumes:PersistentVolumeClaim (PVC)
The most common volume type. PVCs request storage from the cluster’s storage provider. Use cases:- Database storage (PostgreSQL, MySQL, MongoDB)
- File uploads and media storage
- Application state that must persist
| Field | Description |
|---|---|
| Name | Unique volume name |
| PVC Name | Name of the PersistentVolumeClaim |
| Mount Path | Path inside the container |
| Read Only | Whether the volume is read-only |
HostPath
Mounts a directory from the host node’s filesystem. Use cases:- Accessing host-specific files
- Development and debugging
- Node-level logs or metrics
EmptyDir
Temporary storage that’s created when a pod starts and deleted when the pod ends. Use cases:- Scratch space for computations
- Sharing data between containers in the same pod
- Caching temporary files
EmptyDir data is lost when the pod terminates. Don’t use it for data that needs to persist.
Adding Volumes to a Deployment
During Deployment Creation
1
Create a new deployment
Start creating a deployment from image or GitHub.
2
Scroll to Volumes
Find the Volumes section.
3
Click 'Add Volume'
Configure your volume:
| Field | Description | Example |
|---|---|---|
| Name | Unique volume name | data-volume |
| Type | Volume type | pvc |
| Mount Path | Container path | /var/lib/data |
| PVC Name | (for PVC type) | my-pvc |
4
Create
The volume will be attached when the deployment starts.
Adding to Existing Deployments
1
Open your deployment
Navigate to the deployment.
2
Go to Volumes tab
Click on the Volumes tab.
3
Add volume
Click Add Volume and configure the settings.
4
Save
The deployment will restart with the new volume attached.
Common Configurations
PostgreSQL Database
Redis Persistence
File Uploads
Shared Cache (EmptyDir)
Volume Permissions
Some applications require specific user permissions on volume directories. Common issues:- PostgreSQL requires ownership by user
postgres(UID 999) - Redis may need write permissions
- Some apps need specific directory structures
Fixing permission issues
Fixing permission issues
If your application fails to write to a volume, you may need to:
- Run an init container to set permissions
- Configure security context in your deployment
- Use a Dockerfile that sets up the correct permissions
Updating Volumes
To modify volume configuration:1
Open Volumes tab
Go to your deployment’s Volumes tab.
2
Edit the volume
Click on the volume to modify.
3
Make changes
Update the mount path or read-only setting.
4
Save
The deployment will restart with the updated configuration.
Removing Volumes
To remove a volume from a deployment:1
Open Volumes tab
Go to your deployment’s Volumes tab.
2
Find the volume
Locate the volume you want to remove.
3
Delete
Click the delete button and confirm.
Removing a volume from a deployment doesn’t delete the underlying PVC or data. The data remains and can be reattached later.
Best Practices
Use PVCs for production data
Use PVCs for production data
Always use PersistentVolumeClaims for any data that needs to survive restarts. EmptyDir is only for temporary data.
Name volumes descriptively
Name volumes descriptively
Use clear names like
postgres-data or uploads-storage so it’s obvious what each volume contains.Choose appropriate mount paths
Choose appropriate mount paths
Mount volumes at the paths your application expects. Check documentation for database-specific paths.
Use read-only when possible
Use read-only when possible
If your application only reads from a volume (like configuration), mount it as read-only for security.
Back up critical data
Back up critical data
Volumes provide persistence, not backup. Implement regular backups for critical data.
Storage Classes
PVCs can use different storage classes that provide different performance characteristics:| Class | Characteristics | Use Case |
|---|---|---|
| Standard | General purpose | Most applications |
| SSD | High IOPS | Databases |
| Replicated | Multi-zone redundancy | Critical data |
Available storage classes depend on your cluster configuration. Contact your administrator for available options.
Troubleshooting
Volume not mounting
Volume not mounting
If your volume doesn’t mount:
- Check that the PVC exists and is bound
- Verify the PVC name is spelled correctly
- Check pod events for mounting errors
- Ensure the storage class supports the requested access mode
Permission denied
Permission denied
If your application can’t write to the volume:
- Check that read-only is not enabled
- Verify your application user has write permissions
- Check security context settings
- Try running an init container to set permissions
Data not persisting
Data not persisting
If data disappears after restart:
- Verify you’re using a PVC, not emptyDir
- Check that the mount path matches where your app writes
- Ensure the PVC is not being deleted
- Check for multiple volume mounts at the same path
Pod stuck in pending
Pod stuck in pending
If the pod won’t start due to volume issues:
- Check if the PVC is bound
- Verify available storage in the cluster
- Check for scheduling conflicts (node affinity vs. volume location)