[英]Using EFS csi driver, do I create multiple PV for each path with the same volumeHandle and how do I specify which PV for the PVC?
See below I have directories in EFS - data
and logs
.请参阅下文,我在 EFS 中有目录 -
data
和logs
。 Do I need to create a different PV if I need to use a subpath?如果我需要使用子路径,是否需要创建不同的 PV? And if I do, how do I specify the PV to use for the PVC?
如果我这样做,我如何指定 PV 用于 PVC?
---
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
I've confirmed that it works with an almost identical setup.我已经确认它适用于几乎相同的设置。 It looks like what you're missing is the
volumeName
attribute of the pvc, which binds it to a specific pv.看起来你缺少的是 pvc 的
volumeName
属性,它将它绑定到特定的 pv。
eg:例如:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: testpvc
namespace: apis
spec:
resources:
requests:
storage: 5Gi
volumeMode: Filesystem
storageClassName: efs-sc
accessModes:
- ReadWriteMany
volumeName: example-pv
Also, I'm using EFS AccessPoints so that if the path does not exist on the EFS filesystem it can be created automatically (more info here ).此外,我正在使用 EFS AccessPoints,这样如果 EFS 文件系统上不存在该路径,它可以自动创建(更多信息在这里)。
It can be then used like that in the pv, instead of using path:然后可以像在 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
I hope people find this useful because I've struggled with provisioning a big amount of pvs and pvcs relating to the same efs.我希望人们觉得这很有用,因为我一直在努力配置与相同 ef 相关的大量 pvs 和 pvc。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.