请参阅下面的EFS-data
和logs
中的目录。如果我需要使用子路径,是否需要创建不同的PV?如果我这样做了,我该如何指定PVC使用的PV?
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: efs-pv-data
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: efs-sc
csi:
driver: efs.csi.aws.com
{{/* same EFS ID*/}}
volumeHandle: fs-ABC1234
volumeAttributes:
path: /data
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: efs-pv-logs
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: efs-sc
csi:
driver: efs.csi.aws.com
{{/* same EFS ID*/}}
volumeHandle: fs-ABC1234
volumeAttributes:
path: /logs
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: efs-claim-data
namespace: my-app
spec:
accessModes:
- ReadWriteMany
storageClassName: "efs-sc"
resources:
requests:
storage: 5Gi
我已经确认它可以使用几乎相同的设置。看起来您缺少的是pvc的volumeName
属性,它将它绑定到特定的pv。
例如:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: testpvc
namespace: apis
spec:
resources:
requests:
storage: 5Gi
volumeMode: Filesystem
storageClassName: efs-sc
accessModes:
- ReadWriteMany
volumeName: example-pv
此外,我使用EFS访问点,这样,如果EFS文件系统上不存在路径,就可以自动创建该路径(此处提供更多信息(。
然后可以像在pv中那样使用它,而不是使用路径:
kind: PersistentVolume
metadata:
name: example-pv
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: efs-sc
csi:
driver: efs.csi.aws.com
volumeHandle: fs-xxxxxxxxxx::fsap:xxxxxxxxx
我希望人们觉得这很有用,因为我一直在努力提供大量与相同efs相关的pv和pvc。