Example 3. Reading and Writing Data on a Persistent Volume
Persistent Volumes can obviate the need for data
ingress and
egress. A persistent volume
may already have the data needed to execute a
workflow when it is
mounted, and data can be written
to the volume that will persist after the workflow has completed. In the following example,
we mount a persistent volume to the
job named new-file. The
volume already has the GitHub repo Hello-World
saved on it. The job copies the README file to a new file and appends text.
This example assumes that an administrator has already configured a storage provisioner with a persistent volume available to your group.
version: v4
volumes:
per_vol_1:
use: my-provisioner
name: my-persistent-volume
jobs:
new-file:
image:
uri: docker://alpine
mounts:
/data: per_vol_1
cwd: /data/Hello-World-master
script: |
#!/bin/sh
cp README README.new && echo "(goodbye dear basement)" >>README.new
resource:
cpu:
cores: 2
affinity: NUMA
memory:
size: 2GB
The example above uses the V4 syntax. The previous (V1) synstax is still supported for backwards compatibility. In V1, the equivalent syntax would have looked like the following:
volumes: per_vol_1: reference: volume://user/<storage-class>See Storage Volumes and Workflows for the full V4 volume syntax.
After the workflow has completed successfully, there is a new file on our persistent volume
located at /Hello-world-master/README.new with the following contents:
Hello World!
(goodbye dear basement)