|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * storage/container_storage_interface/persistent-storage-csi-aws-efs.adoc |
| 4 | + |
| 5 | +[id="csi-dynamic-provisioning-aws-efs_{context}"] |
| 6 | += Dynamic provisioning for AWS EFS |
| 7 | + |
| 8 | +The AWS EFS CSI Driver supports a different form of dynamic provisioning than other CSI drivers. It provisions new PVs as subdirectories of a pre-existing EFS volume. The PVs are independent of each other. However, they all share the same EFS volume. When the volume is deleted, all PVs provisioned out of it are deleted too. |
| 9 | +The EFS CSI driver creates an AWS Access Point for each such subdirectory. Due to AWS AccessPoint limits, you can only dynamically provision 120 PVs from a single `StorageClass`/EFS volume. |
| 10 | + |
| 11 | +[IMPORTANT] |
| 12 | +==== |
| 13 | +Note that `PVC.spec.resources` is not enforced by EFS. |
| 14 | +
|
| 15 | +In the example below, you request 5 GiB of space. However, the created PV is limitless and can store any amount of data (like petabytes). A broken application, or even a rogue application, can cause significant expenses when it stores too much data on the volume. |
| 16 | +
|
| 17 | +Using monitoring of EFS volume sizes in AWS is strongly recommended. |
| 18 | +==== |
| 19 | + |
| 20 | +.Prerequisites |
| 21 | + |
| 22 | +* xref:../../storage/container_storage_interface/persistent-storage-csi-aws-efs.adoc#efs-create-volume_persistent-storage-csi-aws-efs[Created AWS EFS volume(s).] |
| 23 | + |
| 24 | +.Procedure |
| 25 | + |
| 26 | +To enable dynamic provisioning: |
| 27 | + |
| 28 | +. Create a `StorageClass` as follows: |
| 29 | ++ |
| 30 | +[source,yaml] |
| 31 | +---- |
| 32 | +kind: StorageClass |
| 33 | +apiVersion: storage.k8s.io/v1 |
| 34 | +metadata: |
| 35 | + name: efs-sc |
| 36 | +provisioner: efs.csi.aws.com |
| 37 | +parameters: |
| 38 | + provisioningMode: efs-ap <1> |
| 39 | + fileSystemId: fs-a5324911 <2> |
| 40 | + directoryPerms: "700" <3> |
| 41 | + gidRangeStart: "1000" <4> |
| 42 | + gidRangeEnd: "2000" <4> |
| 43 | + basePath: "/dynamic_provisioning" <5> |
| 44 | +---- |
| 45 | +<1> `provisioningMode` must be `efs-ap` to enable dynamic provisioning. |
| 46 | +<2> `fileSystemId` must be the ID of the EFS volume created manually above. |
| 47 | +<3> `directoryPerms` is the default permission of the root directory of the volume. In this case, the volume is accessible only by the owner. |
| 48 | +<4> `gidRangeStart` and `gidRangeEnd` set the range of POSIX Group IDs (GIDs) that are used to set the GID of the AWS access point. If not specified, the default range is 50000-7000000. Each provisioned volume, and thus AWS access point, is assigned a unique GID from this range. |
| 49 | +<5> `basePath` is the directory on the EFS volume that is used to create dynamically provisioned volumes. In this case, a PV is provisioned as “/dynamic_provisioning/<random uuid>” on the EFS volume. Only the subdirectory is mounted to pods that use the PV. |
| 50 | ++ |
| 51 | +[NOTE] |
| 52 | +==== |
| 53 | +A cluster admin can create several `StorageClasses`, each using a different EFS volume. |
| 54 | +==== |
| 55 | ++ |
| 56 | +. Create a PVC (or StatefulSet or Template) as usual, referring to the `StorageClass` created above. |
| 57 | ++ |
| 58 | +[source,yaml] |
| 59 | +---- |
| 60 | +apiVersion: v1 |
| 61 | +kind: PersistentVolumeClaim |
| 62 | +metadata: |
| 63 | + name: test |
| 64 | +spec: |
| 65 | + storageClassName: efs-sc |
| 66 | + accessModes: |
| 67 | + - ReadWriteMany |
| 68 | + resources: |
| 69 | + requests: |
| 70 | + storage: 5Gi |
| 71 | +---- |
0 commit comments