awslabs/mountpoint-s3-csi-driver

Add capability to specify the S3 bucket prefix in 'volumeAttributes'

Closed this issue · 5 comments

/feature

Problem statement
I was attempting to specify an S3 prefix as a 'spec.csi.volumeAttributes'. Either it is not supported or not documented. I used bucketprefix as the parameter. It didn't work

Expected outcome
I checked all the examples and documentation. There is no way for us to use S3 prefix as the mount point for the 'PersistentVolume'. But, the original tool mountpoint-s3 clearly has the capability to do it.

Here is the YAML manifest I attempted,

apiVersion: v1
kind: PersistentVolume
metadata:
  name: s3-pv
spec:
  capacity:
    storage: 1Gi # ignored, required
  accessModes:
    - ReadWriteMany # supported options: ReadWriteMany / ReadOnlyMany
  mountOptions:
    - allow-delete
    - region us-east-1
  csi:
    driver: s3.csi.aws.com # required
    volumeHandle: s3-csi-driver-volume
    volumeAttributes:
      bucketName: s3-csi-driver
      bucketprefix: data/
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: s3-claim
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: "s3"
  resources:
    requests:
      storage: 1Gi
  volumeName: s3-pv
---
apiVersion: v1
kind: Pod
metadata:
  name: s3-app
spec:
  containers:
    - name: app
      image: centos
      command: ["/bin/sh"]
      args: ["-c", "echo 'Hello from the container!' >> /data/$(date -u).txt; tail -f /dev/null"]
      volumeMounts:
        - name: persistent-storage
          mountPath: /data
  volumes:
    - name: persistent-storage
      persistentVolumeClaim:
        claimName: s3-claim

Alternatives considered
I tried different parameter names 'volumeAttributes'. But didn't work. for I had no other alternative.

Additional context
If this is already possible, are you able to provide an example on how to do this?

From the analysis I did last week, my understanding is that the mount options for the PersistentVolume should map to CLI options - have you tried

  mountOptions:
    - prefix myprefix/

That is correct, the Mountpoint configurations are defined in mountOptions (documentation for this is here)

To add to the example mentioned above:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: s3-pv
spec:
  capacity:
    storage: 1200Gi # ignored, required
  accessModes:
    - ReadWriteMany # supported options: ReadWriteMany / ReadOnlyMany
  mountOptions:
    - prefix myprefix/
  csi:
    driver: s3.csi.aws.com # required
    volumeHandle: s3-csi-driver-volume
    volumeAttributes:
      bucketName: s3-csi-driver

Thanks for the support. This worked. Here is the final YAML manifest I used.

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: s3-pv
spec:
  capacity:
    storage: 1200Gi # ignored, required
  accessModes:
    - ReadWriteMany # supported options: ReadWriteMany / ReadOnlyMany
  mountOptions:
    - prefix myfolder/
    - region us-east-1
  csi:
    driver: s3.csi.aws.com # required
    volumeHandle: s3-csi-driver-volume
    volumeAttributes:
      bucketName: app-resources
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: s3-pvc
spec:
  storageClassName: ""
  volumeName: s3-pv
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1200Gi # Adjust the size as needed
---
apiVersion: v1
kind: Pod
metadata:
  name: app
spec:
  containers:
    - name: busybox
      image: busybox
      command: ["sleep", "3600"]
      volumeMounts:
        - name: persistent-storage
          mountPath: /data
  volumes:
    - name: persistent-storage
      persistentVolumeClaim:
        claimName: s3-pvc

The link you provided for mount options. I can't seem to find the mount options in there.

Lastly, here is my final feedback to get it working.

  • The instructions in this page Mountpoint for Amazon S3 CSI driver is very confusing. It has good detail on how to create the IAM role for 'aws-mountpoint-s3-csi-driver'. That's just about it.
  • Need to add more details on how to enable the Add-on attaching the respective IAM role to it. That part is missing.
  • Also, I think link to the s3 k8s examples is very important. That will make it easy for users to use this add-on without having to search the entire internet.
  • Moreover, it would be good to provide some insight somewhere what this add-on creates behind the scene to facilitate this functionality.

Thank you again for the support. we can close this issue.

Thank you for the feedback. We're working to update the docs currently and will update the GitHub page once we do.

The documentation on the EKS page has been updated.