csi-rclone

module
v0.0.0-...-99ff02c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2023 License: Apache-2.0

README

CSI rclone mount plugin

This project implements Container Storage Interface (CSI) plugin that allows using rclone mount as storage backend. Rclone mount points and parameters can be configured using Secret or PersistentVolume volumeAttibutes.

Warning

VFS cache can cause DATA LOSS!!! Do not use VFS cache unless you know what you are doing!

rClone VFS are not designed to be used on kubernetes clusters. When write cache is enabled, data is writen to local machine and later commit to remote. If the machine fails or remote reports error in the period of time, the changes will be lost and applications will get no notifications.

Kubernetes cluster compatability

Works (tested): K8S>= 1.19.x (due to storage.k8s.io/v1 CSIDriver API)

Does not work:

  • v1.12.7-gke.10, driver name csi-rclone not found in the list of registered CSI drivers

Installing CSI driver to kubernetes cluster w/o dynamic provisioner

TLDR: kubectl apply -f deploy/kubernetes/no-provisioner

  1. Set up storage backend. You can use Minio, Amazon S3 compatible cloud storage service. i.e.
helm upgrade --install --create-namespace --namespace minio minio minio/minio --version 6.0.5 --set resources.requests.memory=512Mi --set secretKey=SECRET_ACCESS_KEY --set accessKey=ACCESS_KEY_ID
  1. Configure defaults by pushing secret. This is optional if you will always define volumeAttributes in PersistentVolume.
apiVersion: v1
kind: Secret
metadata:
  name: rclone-secret
  namespace: csi-rclone
type: Opaque
stringData:
  remote: "s3"
  remotePath: "projectname"
  s3-provider: "Minio"
  s3-endpoint: "http://minio.minio:9000"
  s3-access-key-id: "ACCESS_KEY_ID"
  s3-secret-access-key: "SECRET_ACCESS_KEY"

Alternatively, you may specify rclone configuration file directly in the secret under configData field.

apiVersion: v1
kind: Secret
metadata:
  name: rclone-secret
  namespace: csi-rclone
type: Opaque
stringData:
  remote: "my-s3"
  remotePath: "projectname"
  configData: |
    [my-s3]
    type = s3
    provider = Minio
    access_key_id = ACCESS_KEY_ID
    secret_access_key = SECRET_ACCESS_KEY
    endpoint = http://minio-release.default:9000

Deploy example secret

kubectl apply -f example/kubernetes/rclone-secret-example.yaml

  1. You can override configuration via PersistentStorage resource definition. Leave volumeAttributes empty if you don't want to. Keys in volumeAttributes will be merged with predefined parameters.
apiVersion: v1
kind: PersistentVolume
metadata:
  name: data-rclone-example
  labels:
    name: data-rclone-example
spec:
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 10Gi
  storageClassName: rclone
  csi:
    driver: csi-rclone
    nodePublishSecretRef:
      name: rclone-secret
      namespace: csi-rclone
    volumeHandle: data-id
    volumeAttributes:
      remote: "s3"
      remotePath: "projectname/pvname"
      s3-provider: "Minio"
      s3-endpoint: "http://minio.minio:9000"
      s3-access-key-id: "ACCESS_KEY_ID"
      s3-secret-access-key: "SECRET_ACCESS_KEY"

Deploy example definition

kubectl apply -f example/kubernetes/nginx-example.yaml

Installing CSI driver to kubernetes cluster w/ dynamic provisioner

TLDR: Edit deploy/kubernetes/dynamic-provisioner/csi-rclone-secret.yaml. Then run kubectl apply -f deploy/kubernetes/dynamic-provisioner.

Noted that if you install dynamic provisioner. The volumes mapping to PVs are OWNED by the provisioner. When PV get deleted, the volume will be purged. If you want to protect the volume, make backups and set reclaimPolicy to retain in deploy/kubernetes/dynamic-provisioner/csi-rclone-storageclass.yaml.

  1. Set up storage backend. You can use Minio, Amazon S3 compatible cloud storage service. i.e.
helm upgrade --install --create-namespace --namespace minio minio minio/minio --version 6.0.5 --set resources.requests.memory=512Mi --set secretKey=SECRET_ACCESS_KEY --set accessKey=ACCESS_KEY_ID
  1. Configure the backend in csi-rclone-storageclass.yaml and csi-rclone-secret.yaml.

Alternatively, you may specify rclone configuration file directly in the secret under configData field.

apiVersion: v1
kind: Secret
metadata:
  name: rclone-secret
  namespace: csi-rclone
type: Opaque
stringData:
  remote: "my-s3"
  remotePath: "projectname"
  configData: |
    [my-s3]
    type = s3
    provider = Minio
    access_key_id = ACCESS_KEY_ID
    secret_access_key = SECRET_ACCESS_KEY
    endpoint = http://minio-release.default:9000
  1. Deploy by kubectl apply -f deploy/kubernetes/dynamic-provisioner

Optionally, you can configure more than 1 dynamic provisioner by editing and pushing csi-rclone-storageclass.yaml and its secrets.

Deploy example definition

kubectl apply -f example/kubernetes/nginx-example-dynamic.yaml

Building plugin and creating image

Current code is referencing projects repository on github.com. If you fork the repository, you have to change go includes in several places (use search and replace).

  1. First push the changed code to remote. The build will use paths from pkg/ directory.

  2. Build the plugin

make plugin
  1. Build the container and inject the plugin into it.
make container
  1. Change docker.io account in Makefile and use make push to push the image to remote.
make push

Changelog

See CHANGELOG.txt

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL