To facilitate data or status sharing across multiple workflow steps, you can mount volumes in the cluster. Supported volume types include Object Storage Service (OSS) and Apsara File Storage NAS (NAS). This topic describes how to create statically provisioned volumes and specifies a sample workflow to use it.
Usage notes
OSS and NAS volumes are suitable for different use scenarios. The following table describes the details:
Volume | Scenarios |
OSS volumes |
Note OSS volumes are mounted by using ossfs, which is implemented as a file system in user space (FUSE). The write performance is limited when you use OSS volumes. We recommend that you use other volumes in scenarios that require high write performance. For more information, see OSS volumes. |
NAS volumes |
For more information, see NAS volumes. |
Each volume type has specific limitations and guidelines, and they may also incur associated resource costs. For more information, see the following topics:
OSS volumes: OSS volumes, Mount a statically provisioned OSS volume
NAS volumes: NAS volumes, Mount a statically provisioned NAS volume
Use OSS volumes
Use the following sample code to create an OSS volume.
For more information, see Mount a statically provisioned OSS volume.
apiVersion: v1 kind: Secret metadata: name: oss-secret namespace: argo stringData: akId: <yourAccessKey ID> # Replace with the actual AccessKey ID. akSecret: <yourAccessKey Secret> # Replace with the actual AccessKey Secret. --- apiVersion: v1 kind: PersistentVolume metadata: name: pv-oss namespace: argo labels: alicloud-pvname: pv-oss spec: capacity: storage: 5Gi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain csi: driver: ossplugin.csi.alibabacloud.com volumeHandle: pv-oss # Specify the name of the persistent volume (PV). nodePublishSecretRef: name: oss-secret namespace: argo volumeAttributes: bucket: <your bucket name> # Replace with the actual bucket name. url: "oss-<your region id>-internal.aliyuncs.com" # Replace <your region id> with the region ID of OSS. For example, the region ID of China (Beijing) is oss-cn-beijing-internal.aliyuncs.com. otherOpts: "-o max_stat_cache_size=0 -o allow_other -o multipart_size=30 -o parallel_count=20" # -o max_stat_cache_size=0 path: "/" # Mount the root directory of the bucket. You can also set this parameter to mount a subdirectory under the bucket, such as path: "testdir/testdir1". --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-oss namespace: argo spec: accessModes: - ReadWriteMany resources: requests: storage: 5Gi selector: matchLabels: alicloud-pvname: pv-ossOptional parameter
You can configure custom parameters in the
-o *** -o ***format for the OSS volume. Example:-o umask=022 -o max_stat_cache_size=0 -o allow_other.Parameter
Description
umask
Modifies the permissions for ossfs accessing files. For example, if you set
umask=022, the permissions for ossfs files will change to 755. Files uploaded through OSS SDK or console have a default permission of 640 in ossfs. Therefore, we recommend that you specify the umask parameter if you want to split the read and write permissions.max_stat_cache_size
The maximum number of files whose metadata can be cached. Metadata caching can accelerate
lsoperations. However, if you modify files by using methods such as OSS SDKs, console, and ossutil, the cached metadata of the files is not synchronously updated. As a result, the cached metadata becomes outdated, and the results oflsoperations may be inaccurate.allow_other
Allows other users to access the mounted directory. However, these users cannot access the files in the directory.
For more information about other parameters, see Options supported by ossfs.
Use the following YAML template to create a workflow that uses a volume:
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: volumes-existing- namespace: argo spec: entrypoint: volumes-existing-example volumes: # Pass the existing volume workdir to the volumes-existing-example template. # The syntax follows the same structure as Kubernetes pod specifications. - name: workdir persistentVolumeClaim: claimName: pvc-oss templates: - name: volumes-existing-example steps: - - name: generate template: whalesay - - name: print template: print-message - name: whalesay container: image: mirrors-ssl.aliyuncs.com/busybox:latest command: [sh, -c] args: ["echo generating message in volume; echo hello world | tee /mnt/vol/hello_world.txt"] volumeMounts: - name: workdir mountPath: /mnt/vol - name: print-message container: image: mirrors-ssl.aliyuncs.com/alpine:latest command: [sh, -c] args: ["echo getting message from volume; find /mnt/vol; cat /mnt/vol/hello_world.txt"] volumeMounts: - name: workdir mountPath: /mnt/vol
Use NAS volumes
Use the following YAML template to create a NAS volume.
For more information, see Mount a statically provisioned NAS volume.
apiVersion: v1 kind: PersistentVolume metadata: name: pv-nas namespace: argo labels: alicloud-pvname: pv-nas spec: capacity: storage: 100Gi accessModes: - ReadWriteMany csi: driver: nasplugin.csi.alibabacloud.com volumeHandle: pv-nas # Specify the name of the PV. volumeAttributes: server: "<your nas filesystem id>.cn-beijing.nas.aliyuncs.com" path: "/" mountOptions: - nolock,tcp,noresvport - vers=3 --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: pvc-nas namespace: argo spec: accessModes: - ReadWriteMany resources: requests: storage: 100Gi selector: matchLabels: alicloud-pvname: pv-nasUse the following YAML template to mount and use a NAS volume in the workflow:
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: volumes-existing- namespace: argo spec: entrypoint: volumes-existing-example volumes: # Pass the existing volume workdir to the volumes-existing-example template. # The syntax follows the same structure as Kubernetes pod specifications. - name: workdir persistentVolumeClaim: claimName: pvc-nas templates: - name: volumes-existing-example steps: - - name: generate template: whalesay - - name: print template: print-message - name: whalesay container: image: mirrors-ssl.aliyuncs.com/busybox:latest command: [sh, -c] args: ["echo generating message in volume; echo hello world | tee /mnt/vol/hello_world.txt"] volumeMounts: - name: workdir mountPath: /mnt/vol - name: print-message container: image: mirrors-ssl.aliyuncs.com/alpine:latest command: [sh, -c] args: ["echo getting message from volume; find /mnt/vol; cat /mnt/vol/hello_world.txt"] volumeMounts: - name: workdir mountPath: /mnt/vol