简体   繁体   English

使用 EFS csi 驱动程序,我是否为具有相同 volumeHandle 的每个路径创建多个 PV,以及如何为 PVC 指定哪个 PV?

[英]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 中有目录 - datalogs 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.

相关问题 如何将PV和PVC用于“可靠”持久卷? - How do I use PV and PVC for *reliable* persistent volumes? 如何使 PVC 重新获得对动态配置的已发布 PV 的访问权限 - How do I make a PVC to regain access to dynamically provisioned released PV "如何使用 Pulimi 从 https:\/\/kubernetes-sigs.github.io\/aws-efs-csi-driver\/ 部署 AWS EFS CSI Driver Helm 图表" - How do I deploy the AWS EFS CSI Driver Helm chart from https://kubernetes-sigs.github.io/aws-efs-csi-driver/ using Pulimi 不使用 CSI 将 Kubernetes PV/PVC 备份到本地磁盘? - Backup Kubernetes PV/PVC to Local Disk w/o using CSI? 在同一个 kubernetes 命名空间中创建多个 PV 和 PVC - Creating multiple PV and PVC in same kubernetes namespace 如何在本地设置上创建可由 Kubernetes 中的多个 pod 和 cronjobs 访问的 PV 和 PVC - How to create a PV and PVC which is accessible by multiple pods and cronjobs in Kubernetes on a local setup 是否可以为pv创建pvc - Is it possile to create a pvc for a pv pvc 如何决定在 kubernetes 中绑定哪个 pv - how pvc decide which pv to bound in kubernetes Kube.netes:如何以正确的方式删除 PV - Kubernetes: How do I delete PV in the correct manner 当 heketi 端点与 pv 和 PVC 不在同一个命名空间中时,glusterfs 如何创建卷 - How does glusterfs create volume when the heketi endpoint is not in the same namespace as pv and PVC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM