DEV Community

Cover image for EKS Persistent Storage With EFS Amazon Service
πŸš€ Vu Dao πŸš€
πŸš€ Vu Dao πŸš€

Posted on • Updated on

EKS Persistent Storage With EFS Amazon Service

How to configure EKS Persistent Storage with EFS Amazon service for your Kubernetes cluster to use

1. Create EFS Volume

Alt Text

Alt Text

Alt Text

Alt Text

Get important elements after creating EFS

  • File System ID: fs-5cc93c7c
  • DNS Name: fs-5cc93c7c.efs.us-east-1.amazonaws.com

2. Create k8s resources to consume the EFS volume

Source: https://github.com/vumdao/efs-eks

2.1 Create EFS provisioner

root@ctl:~/efs-eks-demo# kubectl apply -f efs-provisioner-deployment.yaml 
namespace/demo created
serviceaccount/efs-provisioner created
clusterrole.rbac.authorization.k8s.io/efs-provisioner created
clusterrolebinding.rbac.authorization.k8s.io/efs-provisioner created
role.rbac.authorization.k8s.io/leader-locking-efs-provisioner created
rolebinding.rbac.authorization.k8s.io/leader-locking-efs-provisioner created
deployment.apps/efs-provisioner created
configmap/efs-provisioner-config created

root@ctl:~/efs-eks-demo# kubectl get pod -n demo
NAME                               READY   STATUS    RESTARTS   AGE
efs-provisioner-84bbf9b5fc-zx5hs   1/1     Running   0          30s

root@ctl:~/efs-eks-demo# kubectl get configmap -n demo
NAME                     DATA   AGE
efs-provisioner-config   4      62s
Enter fullscreen mode Exit fullscreen mode

2.2 Create PVC

root@ctl:~/efs-eks-demo# kubectl apply -f efs-pvc.yaml 
storageclass.storage.k8s.io/efs-sc created
persistentvolumeclaim/efs-demo-claim created

root@ctl:~/efs-eks-demo# kubectl get pvc -n demo
NAME             STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
efs-demo-claim   Bound    pvc-e00f83c9-4168-41ba-ae8b-08bc57f466e4   100Mi      RWX            aws-efs        10s

root@ctl:~/efs-eks-demo# kubectl get storageclass
NAME            PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
efs-sc          aws-efs                 Delete          Immediate           false                  27s
Enter fullscreen mode Exit fullscreen mode

2.3 Deploying the stateful services writer and reader the EFS volume

root@ctl:~/efs-eks-demo# kubectl apply -f efs-writer.yaml 
pod/efs-writer created

root@ctl:~/efs-eks-demo# kubectl apply -f efs-reader.yaml 
pod/efs-reader created

root@ctl:~/efs-eks-demo# kubectl get pod -n demo
NAME                               READY   STATUS    RESTARTS   AGE
efs-provisioner-84bbf9b5fc-zx5hs   1/1     Running   0          3m6s
efs-reader                         1/1     Running   0          7s
efs-writer                         1/1     Running   0          14s
Enter fullscreen mode Exit fullscreen mode

2.4 Verify that the efs-reader pod is able to successfully read the same data from the shared persistent volume

root@ctl:~/efs-eks-demo# kubectl exec -it efs-writer -n demo -- tail /shared/out.txt
efs-writer.demo - Sun Dec 13 16:59:04 UTC 2020
efs-writer.demo - Sun Dec 13 16:59:09 UTC 2020
efs-writer.demo - Sun Dec 13 16:59:14 UTC 2020
efs-writer.demo - Sun Dec 13 16:59:19 UTC 2020
efs-writer.demo - Sun Dec 13 16:59:24 UTC 2020

root@ctl:~/efs-eks-demo# kubectl exec -it efs-reader -n demo -- tail /shared/out.txt
efs-writer.demo - Sun Dec 13 16:59:04 UTC 2020
efs-writer.demo - Sun Dec 13 16:59:09 UTC 2020
efs-writer.demo - Sun Dec 13 16:59:14 UTC 2020
efs-writer.demo - Sun Dec 13 16:59:19 UTC 2020
efs-writer.demo - Sun Dec 13 16:59:24 UTC 2020
efs-writer.demo - Sun Dec 13 16:59:29 UTC 2020
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
pilgrim2go profile image
iapilgrim

Great Post.
Thanks for sharing