awslabs / mountpoint-s3-csi-driver

Built on Mountpoint for Amazon S3, the Mountpoint CSI driver presents an Amazon S3 bucket as a storage volume accessible by containers in your Kubernetes cluster.
Apache License 2.0
151 stars 18 forks source link

Support PVs with object keys instead of buckets #198

Closed nabouzidan-3as closed 3 weeks ago

nabouzidan-3as commented 1 month ago

/feature

Is your feature request related to a problem? Please describe. I would like to use one bucket to provision multiple volumes (PVs), each of which is mapped into a folder in the S3 bucket. Creating a different S3 bucket for each volume is just not feasible

Describe the solution you'd like in detail A clear and concise description of what you want to happen. In the PV specs:

kind: PersistentVolume
metadata:
  name: s3-pv
spec:
  capacity:
    storage: 1200Gi # ignored, required
  accessModes:
    - ReadWriteMany # supported options: ReadWriteMany / ReadOnlyMany
  mountOptions:
    - allow-delete
    - region eu-central-1
  csi:
    driver: s3.csi.aws.com # required
    volumeHandle: my-volume
    volumeAttributes:
      bucketName: my-bucket
      directory: path/to/directory # optional

Describe alternatives you've considered Using EFS, but handling files in the EFS volumes are not as easy.

Additional context Add any other context or screenshots about the feature request here.

passaro commented 1 month ago

Hi @nash-3as. Mountpoint supports specifying a prefix for the bucket you want to mount (under mountOptions). That would look like this:

kind: PersistentVolume
metadata:
  name: s3-pv
spec:
  capacity:
    storage: 1200Gi # ignored, required
  accessModes:
    - ReadWriteMany # supported options: ReadWriteMany / ReadOnlyMany
  mountOptions:
    - allow-delete
    - region eu-central-1
    - prefix: prefix/in/my-bucket/ # must end in "/"
  csi:
    driver: s3.csi.aws.com # required
    volumeHandle: my-volume
    volumeAttributes:
      bucketName: my-bucket

Then you could configure multiple volumes with the same bucket but different prefixes.

Does that cover your use case?

dannycjones commented 3 weeks ago

I hope this covers your use case, @nabouzidan-3as.

We've also added a prefix to the static provisioning example:

https://github.com/awslabs/mountpoint-s3-csi-driver/blob/39c86e04c71d6d23771f34d15e2edc6141e6b89b/examples/kubernetes/static_provisioning/static_provisioning.yaml#L1-L18

Closing this as this is addressed and example added to documentation.