-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Cheng Pan
committed
Jul 31, 2019
1 parent
4be290e
commit 41424fe
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## EFS Volume Path | ||
Similar to [static provisioning example](../static_provisioning). A sub directory of EFS can be mounted inside container. This gives cluster operator the flexibility to restrict the amount of data being accessed from different containers on EFS. | ||
|
||
**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) | ||
``` | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: efs-pv | ||
spec: | ||
capacity: | ||
storage: 5Gi | ||
volumeMode: Filesystem | ||
accessModes: | ||
- ReadWriteOnce | ||
persistentVolumeReclaimPolicy: Retain | ||
storageClassName: efs-sc | ||
csi: | ||
driver: efs.csi.aws.com | ||
volumeHandle: [FileSystemId] | ||
volumeAttriburtes: | ||
path: /a/b/c/ | ||
``` | ||
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. | ||
|
||
You can find it using AWS CLI: | ||
```sh | ||
>> aws efs describe-file-systems --query "FileSystems[*].FileSystemId" | ||
``` | ||
|
||
### Deploy the Example Application | ||
Create PV, persistence volume claim (PVC) and storage class: | ||
```sh | ||
>> kubectl apply -f examples/kubernetes/volume_path/specs/example.yaml | ||
``` | ||
|
||
### Check EFS filesystem is used | ||
After the objects are created, verify that pod is running: | ||
|
||
```sh | ||
>> kubectl get pods | ||
``` | ||
|
||
Also you can verify that data is written onto EFS filesystem: | ||
|
||
```sh | ||
>> kubectl exec -ti efs-app -- tail -f /data/out.txt | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
kind: StorageClass | ||
apiVersion: storage.k8s.io/v1 | ||
metadata: | ||
name: efs-sc | ||
provisioner: efs.csi.aws.com | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: efs-pv | ||
spec: | ||
capacity: | ||
storage: 5Gi | ||
volumeMode: Filesystem | ||
accessModes: | ||
- ReadWriteOnce | ||
persistentVolumeReclaimPolicy: Retain | ||
storageClassName: efs-sc | ||
csi: | ||
driver: efs.csi.aws.com | ||
volumeHandle: fs-0434d1e6 | ||
volumeAttributes: | ||
path: /a/b/c/ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: efs-claim | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: efs-sc | ||
resources: | ||
requests: | ||
storage: 5Gi | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: efs-app | ||
spec: | ||
containers: | ||
- name: app | ||
image: centos | ||
command: ["/bin/sh"] | ||
args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"] | ||
volumeMounts: | ||
- name: persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: persistent-storage | ||
persistentVolumeClaim: | ||
claimName: efs-claim |