Getting error when using same EFS for two PVs

29 Views Asked by At

I want to use same efs as two static volumes.

For that, I have created the below two PersistentVolume Yamls:

# Persistent Volume 1
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: efs-pv-1
spec:
  storageClassName: efs-sc
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  csi:
    driver: efs.csi.aws.com
    volumeHandle: fs-0fd788366150f3067  # Replace with your EFS FileSystem ID
    volumeAttributes:
      path: "/path1"  # Subpath within your EFS
...
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: efs-pv-2
spec:
  storageClassName: efs-sc
  capacity:
    storage: 6Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  csi:
    driver: efs.csi.aws.com
    volumeHandle: fs-0fd788366150f3067  # Replace with your EFS FileSystem ID
    volumeAttributes:
      path: "/path2"  # Another subpath within your EFS
...

---
# Persistent Volume Claim 1
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: efs-pvc-1
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 5Gi
...
---
# Persistent Volume Claim 2
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: efs-pvc-2
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 6Gi
...

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-container
        image: nginx
        volumeMounts:
        - name: efs-volume-1
          mountPath: /usr/share/nginx/html
        - name: efs-volume-2
          mountPath: /var/www/html
      volumes:
      - name: efs-volume-1
        persistentVolumeClaim:
          claimName: efs-pvc-1
      - name: efs-volume-2
        persistentVolumeClaim:
          claimName: efs-pvc-2

However, this is throwing below error:

mount failed: exit status 32
0

There are 0 best solutions below