This topic describes how to mount volumes to workflow clusters and then use the volumes.
Usage notes
You can use Object Storage Service (OSS) volumes and File Storage NAS (NAS) volumes in workflow clusters.
Use OSS volumes
Use the following sample code to create an OSS volume.
For more information, see Mount a statically provisioned OSS volume. To create other types of volumes, replace the corresponding parameters.
Click to view YAML content
apiVersion: v1 kind: Secret metadata: name: oss-secret namespace: default stringData: akId: <yourAccessKey ID> # Replace with your AccessKey ID. akSecret: <yourAccessKey Secret> # Replace with your AccessKey secret. --- apiVersion: v1 kind: PersistentVolume metadata: name: pv-oss 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: default volumeAttributes: bucket: <your bucket name> # Replace with your bucket name. url: "oss-<your region id>-internal.aliyuncs.com" # Replace <your region id> with the region ID of your OSS bucket. For example, if your OSS bucket is created in the China (Beijing) region, the region ID 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: "/" # The root directory of the OSS bucket. You can also specify a subdirectory of the OSS bucket. Example: testdir/testdir1. --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-oss namespace: default spec: accessModes: - ReadWriteMany resources: requests: storage: 5Gi selector: matchLabels: alicloud-pvname: pv-oss
Optional parameters:
You can configure custom parameters in the
-o *** -o ***
format for the OSS volume, such as-o umask=022 -o max_stat_cache_size=0 -o allow_other
.umask: Modify the permission mask of files in OSSFS. For example, if you set umask=022, the permission mask of files in OSSFS changes to 755. By default, the permission mask of files uploaded by using the OSS SDK or console is 640 in OSSFS. Therefore, we recommend that you use the umask command when you want to split reads and writes.
max_stat_cache_size: Specify the maximum number of objects whose metadata can be cached. Metadata caching can accelerate List operations. However, if you modify files by using methods other than OSSFS, such as the OSS console, SDK, or ossutil, the metadata of the files may not be updated in real time.
allow_other: Allow 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 sample code to create a workflow to use the OSS volume:
Click to view YAML content
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: volumes-existing- namespace: default spec: entrypoint: volumes-existing-example volumes: # Pass my-existing-volume as an argument to the volumes-existing-example template. # Same syntax as k8s Pod spec. - 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: docker/whalesay:latest command: [sh, -c] args: ["echo generating message in volume; cowsay hello world | tee /mnt/vol/hello_world.txt"] volumeMounts: - name: workdir mountPath: /mnt/vol - name: print-message container: image: 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 sample code to create a statically provisioned NAS volume:
Click to view YAML content
apiVersion: v1 kind: PersistentVolume metadata: name: pv-nas 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 spec: accessModes: - ReadWriteMany resources: requests: storage: 100Gi selector: matchLabels: alicloud-pvname: pv-nas
Use the following sample code to create a workflow to use the NAS volume.
Click to view YAML content
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: volumes-existing- namespace: default spec: entrypoint: volumes-existing-example volumes: # Pass my-existing-volume as an argument to the volumes-existing-example template. # Same syntax as k8s Pod spec. - 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: docker/whalesay:latest command: [sh, -c] args: ["echo generating message in volume; cowsay hello world | tee /mnt/vol/hello_world.txt"] volumeMounts: - name: workdir mountPath: /mnt/vol - name: print-message container: image: 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