Dynamically Provisioned PV’s Using Amazon EFS in a MultiAZ Kubernetes setup

William Broach
2 min readJun 15, 2017

--

Warning: Dynamically Provisioned PersistentVolumes have a default persistentVolumeReclaimPolicy of DELETE, which means if the PersistentVolumeClaim ever gets unbound from the PV, it will delete all the data. If you want to change this you need to change the persistentVolumeReclaimPolicy of the created PV’s to “Retain”.

In this guide we’re going to setup a PersistentVolume (PV) using Amazon’s EFS that will give pods the ability to get rescheduled across Availability Zones (AZ’s) and still maintain access to the data in that PV.

Prerequisites: An existing EFS volume and volume mounts in the same VPC as your Kubernetes cluster.

Step 1: Make a directory in your EFS called /pvs(how you do this is up to you)

Step 2: Create a ConfigMap that contains your EFS filesystem ID / AWS Region

Step 3: Edit the efs-provisioner deployment to add your EFS filesystem ID and mount point from Step 1. (lines 39 / 40 below)

Step 4: Launch the deployment of the efs-provisioner: kubectl apply -f efs-provisioner-deployment.yml

Step 5: Create a StorageClass called ‘aws-efs’ that uses the above provisioner

Step 6: kubectl create -f aws-efs-sc.yml

Step 7: Create a PersistentVolumeClaim that uses the ‘aws-efs’ StorageClass you just created in the previous step.

Note: You can make the storage size anything you’d like up to Amazon’s maximum of 8 Exabytes.

Note: For every PersistentVolumeClaim you make, it will make a subdirectory in EFS under ‘/pvs/pvc-<claim_id>’

Step 8: kubectl create -f aws-efs-pvc.yml

Your Done!

You can now add the following to any podspec / deployment / etc…

Full example in a deployment:

--

--

William Broach

DevOps Janitor | Recovering SysAdmin | Kubernetes | Docker | Distributed Computing | (@while1eq1)