PersistentVolumeClaim
container
services, tasks and tests can all mount volumes using this module type. To mount a volume, you need to define a volume module, and reference it using the volumes
key on your services, tasks and/or tests.
Example:
This will mount the my-volume
PVC at /volume
in the my-service
service when it is run. The my-volume
module creates a PersistentVolumeClaim
resource in your project namespace, and the spec
field is passed directly to the same field on the PVC resource.
Notice the accessModes
field in the volume module above. The default storage classes in Kubernetes generally don't support being mounted by multiple Pods at the same time. If your volume module doesn't support the ReadWriteMany
access mode, you must take care not to use the same volume in multiple services, tasks or tests, or multiple replicas. See Shared volumes below for how to share a single volume with multiple Pods.
You can do the same for tests and tasks using the tests.volumes
and tasks.volumes
fields. persistentvolumeclaim
volumes can of course also be referenced in kubernetes
and helm
modules, since they are deployed as standard PersistentVolumeClaim resources.
Take a look at the persistentvolumeclaim
and container
module reference docs for more details.
Shared volumes
For a volume to be shared between multiple replicas, or multiple services, tasks and/or tests, it needs to be configured with a storage class (using the storageClassName
field) that supports the ReadWriteMany
(RWX) access mode. The available storage classes that support RWX vary by cloud providers and cluster setups, and in many cases you need to define a StorageClass
or deploy a storage class provisioner to your cluster.
You can find a list of storage options and their supported access modes here. Here are a few commonly used RWX provisioners and storage classes:
Once any of those is set up you can create a persistentvolumeclaim
module that uses the configured storage class. Here, for example, is how you might use a shared volume with a configured azurefile
storage class:
Here the same volume is used across a service, task and a test in the same module. You could similarly use the same volume across multiple container modules.
Last updated