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 Apsara 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" 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
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