-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from kbasv/controller-doc
Add documentation and examples for dynamic provisioning
- Loading branch information
Showing
5 changed files
with
150 additions
and
2 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
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,35 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"elasticfilesystem:DescribeAccessPoints", | ||
"elasticfilesystem:DescribeFileSystems" | ||
], | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"elasticfilesystem:CreateAccessPoint" | ||
], | ||
"Resource": "*", | ||
"Condition": { | ||
"StringLike": { | ||
"aws:RequestTag/efs.csi.aws.com/cluster": "true" | ||
} | ||
} | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": "elasticfilesystem:DeleteAccessPoint", | ||
"Resource": "*", | ||
"Condition": { | ||
"StringEquals": { | ||
"aws:ResourceTag/efs.csi.aws.com/cluster": "true" | ||
} | ||
} | ||
} | ||
] | ||
} |
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,49 @@ | ||
## Dynamic Provisioning | ||
This example shows how to create a dynamically provisioned volume created through [EFS access points](https://docs.aws.amazon.com/efs/latest/ug/efs-access-points.html) and Persistent Volume Claim (PVC) and consume it from a pod. | ||
|
||
**Note**: this example requires Kubernetes v1.17+ and driver version >= 1.2.0. | ||
|
||
### Edit [StorageClass](./specs/storageclass.yaml) | ||
|
||
``` | ||
kind: StorageClass | ||
apiVersion: storage.k8s.io/v1 | ||
metadata: | ||
name: efs-sc | ||
provisioner: efs.csi.aws.com | ||
mountOptions: | ||
- tls | ||
parameters: | ||
provisioningMode: efs-ap | ||
fileSystemId: fs-92107410 | ||
directoryPerms: "700" | ||
gidRangeStart: "1000" | ||
gidRangeEnd: "2000" | ||
basePath: "/dynamic_provisioning" | ||
``` | ||
* provisioningMode - The type of volume to be provisioned by efs. Currently, only access point based provisioning is supported `efs-ap`. | ||
* fileSystemId - The file system under which Access Point is created. | ||
* directoryPerms - Directory Permissions of the root directory created by Access Point. | ||
* gidRangeStart (Optional) - Starting range of Posix Group ID to be applied onto the root directory of the access point. Default value is 50000. | ||
* gidRangeEnd (Optional) - Ending range of Posix Group ID. Default value is 7000000. | ||
* basePath (Optional) - Path on the file system under which access point root directory is created. If path is not provided, access points root directory are created under the root of the file system. | ||
|
||
### Deploy the Example | ||
Create storage class, persistent volume claim (PVC) and the pod which consumes PV: | ||
```sh | ||
>> kubectl apply -f examples/kubernetes/dynamic_provisioning/specs/storageclass.yaml | ||
>> kubectl apply -f examples/kubernetes/dynamic_provisioning/specs/pod.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,30 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: efs-claim | ||
spec: | ||
accessModes: | ||
- ReadWriteMany | ||
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; sleep 5; done"] | ||
volumeMounts: | ||
- name: persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: persistent-storage | ||
persistentVolumeClaim: | ||
claimName: efs-claim |
12 changes: 12 additions & 0 deletions
12
examples/kubernetes/dynamic_provisioning/specs/storageclass.yaml
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,12 @@ | ||
kind: StorageClass | ||
apiVersion: storage.k8s.io/v1 | ||
metadata: | ||
name: efs-sc | ||
provisioner: efs.csi.aws.com | ||
parameters: | ||
provisioningMode: efs-ap | ||
fileSystemId: fs-92107410 | ||
directoryPerms: "700" | ||
gidRangeStart: "1000" # optional | ||
gidRangeEnd: "2000" # optional | ||
basePath: "/dynamic_provisioning" # optional |