No description
Find a file
2022-11-16 23:30:10 +03:00
.github/workflows Fix test pipeline 2021-10-27 21:54:26 +03:00
cmd/s3driver Move Dockerfile to / 2022-08-05 15:20:40 +03:00
deploy Delete taint for provisioner 2022-11-16 23:30:10 +03:00
pkg Fix bucket/path split for volume names 2022-04-15 19:03:20 +03:00
test Fix test pipeline 2021-10-27 21:54:26 +03:00
.gitignore Initial commit 2018-07-14 10:48:22 +02:00
.gitlab-ci.yml Rename repository to k8s-csi-s3 2021-08-24 13:33:26 +03:00
Apache-2.0.txt Update LICENSE and AUTHORS 2021-08-24 12:53:47 +03:00
AUTHORS Rename repository to k8s-csi-s3 2021-08-24 13:33:26 +03:00
Dockerfile Temporarily disable s3fs-fuse build 2022-08-05 15:21:35 +03:00
go.mod Rename repository to k8s-csi-s3 2021-08-24 13:33:26 +03:00
go.sum Remove extra dependencies 2021-07-19 15:41:45 +03:00
LICENSE Update LICENSE and AUTHORS 2021-08-24 12:53:47 +03:00
Makefile Bump version to 0.34.0, following GeeseFS 2022-11-16 14:23:08 +03:00
README.md Include s3fs and rclone in Docker image, use Alpine base 2022-06-22 16:29:33 +03:00

CSI for S3

This is a Container Storage Interface (CSI) for S3 (or S3 compatible) storage. This can dynamically allocate buckets and mount them via a fuse mount into any container.

Kubernetes installation

Requirements

  • Kubernetes 1.17+
  • Kubernetes has to allow privileged containers
  • Docker daemon must allow shared mounts (systemd flag MountFlags=shared)

1. Create a secret with your S3 credentials

apiVersion: v1
kind: Secret
metadata:
  name: csi-s3-secret
  # Namespace depends on the configuration in the storageclass.yaml
  namespace: kube-system
stringData:
  accessKeyID: <YOUR_ACCESS_KEY_ID>
  secretAccessKey: <YOUR_SECRET_ACCESS_KEY>
  # For AWS set it to "https://s3.<region>.amazonaws.com", for example https://s3.eu-central-1.amazonaws.com
  endpoint: https://storage.yandexcloud.net
  # For AWS set it to AWS region
  #region: ""

The region can be empty if you are using some other S3 compatible storage.

2. Deploy the driver

cd deploy/kubernetes
kubectl create -f provisioner.yaml
kubectl create -f attacher.yaml
kubectl create -f csi-s3.yaml

3. Create the storage class

kubectl create -f examples/storageclass.yaml

4. Test the S3 driver

  1. Create a pvc using the new storage class:

    kubectl create -f examples/pvc.yaml
    
  2. Check if the PVC has been bound:

    $ kubectl get pvc csi-s3-pvc
    NAME         STATUS    VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    csi-s3-pvc   Bound     pvc-c5d4634f-8507-11e8-9f33-0e243832354b   5Gi        RWO            csi-s3         9s
    
  3. Create a test pod which mounts your volume:

    kubectl create -f examples/pod.yaml
    

    If the pod can start, everything should be working.

  4. Test the mount

    $ kubectl exec -ti csi-s3-test-nginx bash
    $ mount | grep fuse
    s3fs on /var/lib/www/html type fuse.s3fs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
    $ touch /var/lib/www/html/hello_world
    

If something does not work as expected, check the troubleshooting section below.

Additional configuration

Bucket

By default, csi-s3 will create a new bucket per volume. The bucket name will match that of the volume ID. If you want your volumes to live in a precreated bucket, you can simply specify the bucket in the storage class parameters:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: csi-s3-existing-bucket
provisioner: ru.yandex.s3.csi
parameters:
  mounter: geesefs
  bucket: some-existing-bucket-name

If the bucket is specified, it will still be created if it does not exist on the backend. Every volume will get its own prefix within the bucket which matches the volume ID. When deleting a volume, also just the prefix will be deleted.

Mounter

We strongly recommend to use the default mounter which is GeeseFS.

However there is also support for two other backends: s3fs and rclone.

The mounter can be set as a parameter in the storage class. You can also create multiple storage classes for each mounter if you like.

As S3 is not a real file system there are some limitations to consider here. Depending on what mounter you are using, you will have different levels of POSIX compability. Also depending on what S3 storage backend you are using there are not always consistency guarantees.

You can check POSIX compatibility matrix here: https://github.com/yandex-cloud/geesefs#posix-compatibility-matrix.

GeeseFS

  • Almost full POSIX compatibility
  • Good performance for both small and big files
  • Does not store file permissions and custom modification times

s3fs

  • Almost full POSIX compatibility
  • Good performance for big files, poor performance for small files
  • Very slow for directories with a large number of files

rclone

  • Poor POSIX compatibility
  • Bad performance for big files, okayish performance for small files
  • Doesn't create directory objects like s3fs or GeeseFS
  • May hang :-)

Troubleshooting

Issues while creating PVC

Check the logs of the provisioner:

kubectl logs -l app=csi-provisioner-s3 -c csi-s3

Issues creating containers

  1. Ensure feature gate MountPropagation is not set to false
  2. Check the logs of the s3-driver:
kubectl logs -l app=csi-s3 -c csi-s3

Development

This project can be built like any other go application.

go get -u github.com/yandex-cloud/k8s-csi-s3

Build executable

make build

Tests

Currently the driver is tested by the CSI Sanity Tester. As end-to-end tests require S3 storage and a mounter like s3fs, this is best done in a docker container. A Dockerfile and the test script are in the test directory. The easiest way to run the tests is to just use the make command:

make test