AWS EFS Create a folder via AWS UI or CLI

3/11/2020

I have a kubernetes PersistentVolume resource defined which uses the efs.csi.aws.com driver. My question is, I want to specify the target path for this volume (/app_data). But this folder needs to exists first before I can start mounting them to the container with PersistentVolumeClaims otherwise it will get error that the target path does not exists. I thought that the folder can be created in the AWS UI or CLI when provisioning the EFS. Something like an S3 where you can create a bucket in the AWS web UI.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: app-pv
  namespace: my-app
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  storageClassName: app-efs-sc
  csi:
    driver: efs.csi.aws.com
    volumeHandle: fs-1234567
    volumeAttributes:
      path: "/app_data"
-- alltej
aws-efs
kubernetes
kubernetes-helm

1 Answer

3/11/2020

It is not a production like sollution but may work as workaround. I would suggest to use initContainer for this task. You can mount whole fs in init container and create directory + assign access right there. Here are example answer

-- user2986553
Source: StackOverflow