Skip to content

Commit

Permalink
Merge pull request #107 from leakingtapan/mult-volume-path
Browse files Browse the repository at this point in the history
Update volume path example for accessing multiple volumes within the same EFS filesystem
  • Loading branch information
Cheng Pan committed Nov 28, 2019
2 parents 867eee4 + be78403 commit ff6ee94
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 20 deletions.
1 change: 1 addition & 0 deletions deploy/kubernetes/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ bases:
images:
- name: amazon/aws-efs-csi-driver
newTag: latest
newName: chengpan/aws-efs-csi-driver
2 changes: 1 addition & 1 deletion examples/kubernetes/static_provisioning/specs/pv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ spec:
storageClassName: efs-sc
csi:
driver: efs.csi.aws.com
volumeHandle: fs-4af69aab
volumeHandle: fs-e8a95a42
13 changes: 6 additions & 7 deletions examples/kubernetes/volume_path/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
```
55 changes: 43 additions & 12 deletions examples/kubernetes/volume_path/specs/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

0 comments on commit ff6ee94

Please sign in to comment.