Volumes

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

  1. 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.
  2. From the dropdown select emptyDir
  3. In the dialog box enter a Resource ID, select whether you want it to be in-memory, and set a size limit.
  4. Click Done

Now that you have a dependency defined:

  1. Click Add Volume Mount in the Volume mounts section for the Container you wish to mount it to
  2. Select the Volume ID (the unique Resource ID you defined earlier) from the dropdown
  3. Choose a Mount-Point in the Container’s filesystem
  4. 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.

  1. Starting on the App Settings screen of the Application to which you want to add a Shared Volume.
  2. Click Add shared resource
  3. Then select Persistent Volume
  4. Provide a unique Resource ID, and click Done

Now that it is available across the app it can be mounted in Workloads

  1. 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
  2. Click Add Volume Mount
  3. Select the Volume ID (the unique Resource ID you defined earlier) from the dropdown
  4. Choose a Mount-Point in the Container’s filesystem, and whether it should be read-only
  5. Then Click Save

Private volumes

Adding a Volume to a Workload as a Resource dependency makes the Volume available exclusively to that Workload.

  1. Starting on the Workload details screen for the Workload that you want to add the Volume to
  2. In the Resource dependencies section click Add resource
  3. From the dropdown select Persistent Volume
  4. Provide a unique Resource ID, and click Done

Now that you have a dependency defined

  1. Click Add Volume Mount in the Volume mounts section for the Container you wish to mount it to
  2. Select the Volume ID (the unique Resource ID you defined earlier) from the dropdown
  3. Choose a Mount-Point in the Container’s filesystem, and whether it should be read-only
  4. Then Click Save
Top