- Home
- Integration and extensions
- Storage
- Volumes
Volumes
On this page
On-Disk files in a container share the lifecycle of the container, meaning when the container is destroyed so are the files. Furthermore, there are limits to the size of a containers root volume, making storage of large amounts of data in the container impossible.
To tackle this Kubernetes defines 3 categories for external storage that can be attached to containers at runtime:
- Ephemeral:
emptyDir
- Useful for caching, buffering, and temporary storage, which generally follows the container’s lifecycle. - Persistent:
persistentVolumeClaims
- Useful for file uploads, or more generally anything that might require long-term storage (like a database), which are typically independent of the container’s lifecycle. - Projected:
configMaps
- Useful for configuration files, secrets, and TLS certificates and keys, which are always independent of the container’s lifecycle.
As in Kubernetes, Humanitec supports Projected volumes. Projected volumes in both Kubernetes are (generally) non-editable secrets, files and configMaps. In Humanitec, the only supported Projected volumes are Files.
Ephemeral volumes #
Ephemeral volumes in Humanitec are synonymous with
emptyDir
in Kubernetes
, they can only be attached to an individual Workload.
An Ephemeral volume is either:
- an in-memory
tempfs
: great for high-speed caches, but limited by RAM capacity. - a mapped directory on-disk: slower than RAM (but still faster than persistent disks via remote-block-storage) and considerably higher capacity than RAM.
Creating and mounting an empty directory #
- Starting from the Workload details screen of the Workload that you want to add the Ephemeral volume to Click Add resource from the Resource dependencies section.
- From the dropdown select emptyDir
- In the dialog box enter a Resource ID, select whether you want it to be in-memory, and set a size limit.
- Click Done
Now that you have a dependency defined:
- Click Add Volume Mount in the Volume mounts section for the Container you wish to mount it to
- Select the Volume ID (the unique Resource ID you defined earlier) from the dropdown
- Choose a Mount-Point in the Container’s filesystem
- Click Save
Persistent volumes #
Persistent volumes in Humanitec are synonymous with Persistent Volume Claims in Kubernetes, with one key difference. As with other resource types Humanitec separates the definition (in this case a template) from the dependency. To learn more about this read the section on Resource Definitions.
As a Developer you may want to add a persistent volume to either an App or to an individual Workload.
Shared volumes #
Adding a Volume to an App as a Shared Resource makes the Volume available to be mounted every Workload in the App.
- Starting on the App Settings screen of the Application to which you want to add a Shared Volume.
- Click Add shared resource
- Then select Persistent Volume
- Provide a unique Resource ID, and click Done
Now that it is available across the app it can be mounted in Workloads
- Navigate to the Workload details screen for the Workload that you wish to mount it in and scroll to the Volume mounts section for the Container you wish to mount it to
- Click Add Volume Mount
- Select the Volume ID (the unique Resource ID you defined earlier) from the dropdown
- Choose a Mount-Point in the Container’s filesystem, and whether it should be read-only
- Then Click Save
Private volumes #
Adding a Volume to a Workload as a Resource dependency makes the Volume available exclusively to that Workload.
- Starting on the Workload details screen for the Workload that you want to add the Volume to
- In the Resource dependencies section click Add resource
- From the dropdown select Persistent Volume
- Provide a unique Resource ID, and click Done
Now that you have a dependency defined
- Click Add Volume Mount in the Volume mounts section for the Container you wish to mount it to
- Select the Volume ID (the unique Resource ID you defined earlier) from the dropdown
- Choose a Mount-Point in the Container’s filesystem, and whether it should be read-only
- Then Click Save