Manage persistent Volumes
Learn how to configure block storage to back Persistent Volumes.
Kubernetes provides a sophisticated way of providing access to persistent storage via the file system for containers running in Pods. This is part of the wider Kubernetes Volumes functionality. In this section we will focus on how Humanitec can be used to provide running workloads with access to persistent volumes backed by various types of disks or services.

Persistent Volumes in Humanitec

In Humanitec, a persistent volume is represented by a resource with type volume. If a developer defines a dependency on a resource of type volume, Humanitec will ensure that a PersistentVolumeClaim is created. Depending on the driver used, the relevant PersistentVolume object might also be created.
The most common form of block storage available to Kubernetes clusters can only be written to by one client (pod) at a time. Care must be taken that if the workload profile creates a Deployment, that it is limited to a single replica configured for writing.
Some backing storage (e.g. NFS) support multiple simultaneous writers. In this case, Humanitec will create additional PersistentVolume objects for ever PersistentVolumeClaim that is needed.

NFS Volume

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.
You will require a running NFS Server that is accessible from the cluster you are deploying to.

Connect the Volume to Humanitec

UI
CLI
API
  1. 1.
    Start on the Resources Management screen and click on Show all resources. An overlay with all available resource categories and types will be presented to you.
  2. 2.
    Below Data storages click on Persistent Volume, which opens a dialog.
  3. 3.
    Define an ID for your volume and select volume-nfs as a Driver.
  4. 4.
    Provide the path of the filesystem to mount on the NFS server.
  5. 5.
    Provide the IP or DNS name of the NFS server.
  6. 6.
    After hitting Create your NFS volume will be successfully registered in Humanitec and show up at the top of the resources list
Our CLI is currently in closed beta. Please contact us if you want to learn more.
Resource definitions can be created via the Create a Resource Definition endpoint.

PVC Volume

Connect the Volume to Humanitec

UI
CLI
API
  1. 1.
    Start on the Resources Management screen and click on Show all resources. An overlay with all available resource categories and types will be presented to you.
  2. 2.
    Below Data storages click on Persistent Volume, which opens a dialog.
  3. 3.
    Define an ID for your volume and select volume-pvc as a Driver.
  4. 4.
    Fill out the Access Mode, desired Storage Capacity and Storage Class Name for the PVC.
  5. 5.
    After hitting Create your PVC volume will be successfully registered in Humanitec and show up at the top of the resources list
Our CLI is currently in closed beta. Please contact us if you want to learn more.
Resource definitions can be created via the Create a Resource Definition endpoint.

Define Matching for your Persistent Volume

Next, you can configure matching criteria for your Persistent Volume Resource Definition. This enables you to define in for which environments or applications this Resource Definition will be used.
UI
CLI
API
By clicking on your volume in the list of resources, the Matching row will expand and allow you to add or remove Matching Criteria. Each Resource Definition can be matched to specific Environment Types, App IDs, Environment IDs or Resource IDs. Empty fields are automatically resolved to match all values of the given category.
Define Matching
Based on this Resource Definition, during the deployment on any of the matching environments, an Active Resource will be provisioned if required.
Our CLI is currently in closed beta. Please contact us if you want to learn more.
Matching Criteria can be added via the Add new matching criteria endpoint.

Using Persistent Volumes in an Application

Add a Volume as a Resource Dependency

Navigate to the Workload Details Screen for the Workload you want to make the volume available for. Make sure you are in Draft mode.
  1. 1.
    Add a "Persistent Volume" resource by selecting from the dropdown in the Resource Dependencies section of the Container Panel.
  2. 2.
    Choose an ID for the volume. You will use this to identify the volume when you setup volume mounts in your containers.
Add a Volume as a Resource Dependency

Define a Volume Mount for a container

Select the container that you want to configure a mount for.
  1. 1.
    Select the ID you chose in the previous step
  2. 2.
    Choose the path to mount the volume on. The path must be absolute and cannot be in the root of the filesystem.
  3. 3.
    Choose whether the mount should be writable by the container.
  4. 4.
    Optional. Choose a sub-directory in the NFS to mount instead of the root.
  5. 5.
    Click the Create button to add the volume mount to the container.
Add volume mount
Copy link
On this page
Persistent Volumes in Humanitec
NFS Volume
PVC Volume
Define Matching for your Persistent Volume
Using Persistent Volumes in an Application