From be7840355e64f20b1060319a0eee0cbbd520e909 Mon Sep 17 00:00:00 2001 From: Cheng Pan Date: Thu, 7 Nov 2019 11:13:03 -0800 Subject: [PATCH] Update volume path example for accessing multiple volumes within the same EFS filesystem --- .../overlays/dev/kustomization.yaml | 1 + .../static_provisioning/specs/pv.yaml | 2 +- examples/kubernetes/volume_path/README.md | 13 ++--- .../kubernetes/volume_path/specs/example.yaml | 55 +++++++++++++++---- 4 files changed, 51 insertions(+), 20 deletions(-) diff --git a/deploy/kubernetes/overlays/dev/kustomization.yaml b/deploy/kubernetes/overlays/dev/kustomization.yaml index dd944db3d..7001aabf8 100644 --- a/deploy/kubernetes/overlays/dev/kustomization.yaml +++ b/deploy/kubernetes/overlays/dev/kustomization.yaml @@ -5,3 +5,4 @@ bases: images: - name: amazon/aws-efs-csi-driver newTag: latest + newName: chengpan/aws-efs-csi-driver diff --git a/examples/kubernetes/static_provisioning/specs/pv.yaml b/examples/kubernetes/static_provisioning/specs/pv.yaml index d2273bc52..e331216e1 100644 --- a/examples/kubernetes/static_provisioning/specs/pv.yaml +++ b/examples/kubernetes/static_provisioning/specs/pv.yaml @@ -12,4 +12,4 @@ spec: storageClassName: efs-sc csi: driver: efs.csi.aws.com - volumeHandle: fs-4af69aab + volumeHandle: fs-e8a95a42 diff --git a/examples/kubernetes/volume_path/README.md b/examples/kubernetes/volume_path/README.md index 0acb7a0da..d08e5ddde 100644 --- a/examples/kubernetes/volume_path/README.md +++ b/examples/kubernetes/volume_path/README.md @@ -3,12 +3,12 @@ Similar to [static provisioning example](../static_provisioning). A sub director **Note**: this feature requires the sub directory to mount precreated on EFS before consuming the volume from pod. -### Edit [Persistence Volume Spec](./specs/pv.yaml) +### Edit [Persistence Volume Spec](./specs/example.yaml) ``` apiVersion: v1 kind: PersistentVolume metadata: - name: efs-pv + name: efs-pv1 spec: capacity: storage: 5Gi @@ -19,11 +19,9 @@ spec: storageClassName: efs-sc csi: driver: efs.csi.aws.com - volumeHandle: [FileSystemId] - volumeAttriburtes: - path: /a/b/c/ + volumeHandle: [FileSystemId]:[Path] ``` -Replace `VolumeHandle` value with `FileSystemId` of the EFS filesystem that needs to be mounted. Note that the path under `volumeAttriburtes` is used as the path from the root of EFS filesystem. +Replace `FileSystemId` of the EFS filesystem ID that needs to be mounted. And replace `Path` with a existing path on the filesystem. You can find it using AWS CLI: ```sh @@ -46,5 +44,6 @@ After the objects are created, verify that pod is running: Also you can verify that data is written onto EFS filesystem: ```sh ->> kubectl exec -ti efs-app -- tail -f /data/out.txt +>> kubectl exec -ti efs-app -- tail -f /data-dir1/out.txt +>> kubectl exec -ti efs-app -- ls /data-dir2 ``` diff --git a/examples/kubernetes/volume_path/specs/example.yaml b/examples/kubernetes/volume_path/specs/example.yaml index 805a9ed5c..16396d3fd 100644 --- a/examples/kubernetes/volume_path/specs/example.yaml +++ b/examples/kubernetes/volume_path/specs/example.yaml @@ -7,28 +7,54 @@ provisioner: efs.csi.aws.com apiVersion: v1 kind: PersistentVolume metadata: - name: efs-pv + name: efs-pv1 spec: capacity: storage: 5Gi volumeMode: Filesystem accessModes: - - ReadWriteOnce + - ReadWriteMany persistentVolumeReclaimPolicy: Retain storageClassName: efs-sc csi: driver: efs.csi.aws.com - volumeHandle: fs-0434d1e6 - volumeAttributes: - path: /a/b/c/ + volumeHandle: fs-e8a95a42:/dir1 --- apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: efs-claim + name: efs-claim1 spec: accessModes: - - ReadWriteOnce + - ReadWriteMany + storageClassName: efs-sc + resources: + requests: + storage: 5Gi +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: efs-pv2 +spec: + capacity: + storage: 5Gi + volumeMode: Filesystem + accessModes: + - ReadWriteMany + persistentVolumeReclaimPolicy: Retain + storageClassName: efs-sc + csi: + driver: efs.csi.aws.com + volumeHandle: fs-e8a95a42:/dir2 +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: efs-claim2 +spec: + accessModes: + - ReadWriteMany storageClassName: efs-sc resources: requests: @@ -43,11 +69,16 @@ spec: - name: app image: centos command: ["/bin/sh"] - args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"] + args: ["-c", "while true; do echo $(date -u) >> /data-dir1/out.txt; sleep 5; done"] volumeMounts: - - name: persistent-storage - mountPath: /data + - name: efs-volume-1 + mountPath: /data-dir1 + - name: efs-volume-2 + mountPath: /data-dir2 volumes: - - name: persistent-storage + - name: efs-volume-1 + persistentVolumeClaim: + claimName: efs-claim1 + - name: efs-volume-2 persistentVolumeClaim: - claimName: efs-claim + claimName: efs-claim2