<p>I am trying to find a solution to make use of the same Amazon EFS for mounting multiple directories in the Kubernetes deployment. Here is my use case</p>
<ul>
<li>I have an application named <strong>app1</strong> that needs to persist a directory named &quot;/opt/templates&quot; to EFS</li>
<li>I have another application named <strong>app2</strong> that needs to persist a directory named &quot;/var/logs&quot; to EFS</li>
</ul>
<p>We deploy the applications as a Kubernetes Pod in the Amazon EKS cluster. If i am using the same EFS for both the above mounts, i can see all the files from both the directories &quot;/opt/templates&quot; and &quot;/var/logs&quot; as i am using the same EFS.</p>
<p>How can i solve the problem of using same EFS for both the application without seeing <strong>app1</strong> mounted files in <strong>app2</strong> directory ? Is it even possible of using the same EFS ID for multiple applications ?</p>
<p>Here is the Kubernetes manifests i used for for one of the application which includes PersistentVolume, PVC and the Deployment</p>
<pre><code>----
apiVersion: v1
kind: PersistentVolume
metadata:
  name: efs-pv-1
spec:
  capacity:
    storage: 2Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: efs-sc-report
  csi:
    driver: efs.csi.aws.com
    volumeHandle: fs-XXXXX

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: efs-pvc-1
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: efs-sc
  resources:
    requests:
      storage: 2Gi
---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deploy1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: deploy1
  template:
    metadata:
      labels:
        app: deploy1
    spec:
      containers:
      - name: app1
        image: imageXXXX
        ports:
        - containerPort: 6455
        volumeMounts:
          - name: temp-data
            mountPath: /opt/templates/  
      volumes:
      - name: shared-data
        emptyDir: {}
      - name: temp-data
        persistentVolumeClaim:
          claimName: efs-pvc-1 
</code></pre>

<p>It looks like you can do that <a href="https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/volume_path/README.md" rel="nofollow noreferrer">by including the path as part of the volume handle</a>.</p>
<blockquote>
<p>A sub directory of EFS can be mounted inside container. This gives cluster operator the flexibility to restrict the amount of data being accessed from different containers on EFS.</p>
</blockquote>
<p>For example:</p>
<pre><code>volumeHandle: [FileSystemId]:[Path]
</code></pre>
<p>I think you will need to create two separate PVs and PVCs, one for /opt/templates, and the other for /var/logs, each pointing to a different path on your EFS.</p>
