You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.8 kB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. # CSI rclone mount plugin
  2. Fork of https://github.com/wunderio/csi-rclone that is a bit slow with merging PRs
  3. Differences with that fork:
  4. - Everything is under kube-system namespace
  5. - Allow specifying of secrets for PV
  6. - StorageClass is no longer namespaced
  7. This project implements Container Storage Interface (CSI) plugin that allows using [rclone mount](https://rclone.org/) as storage backend. Rclone mount points and [parameters](https://rclone.org/commands/rclone_mount/) can be configured using Secret or PersistentVolume volumeAttibutes.
  8. ## Kubernetes cluster compatability
  9. Works (tested):
  10. - `deploy/kubernetes/1.19`: K8S>= 1.19.x (due to storage.k8s.io/v1 CSIDriver API)
  11. - `deploy/kubernetes/1.13`: K8S 1.13.x - 1.21.x (storage.k8s.io/v1beta1 CSIDriver API)
  12. Does not work:
  13. - v1.12.7-gke.10, driver name csi-rclone not found in the list of registered CSI drivers
  14. ## Installing CSI driver to kubernetes cluster
  15. TLDR: ` kubectl apply -f deploy/kubernetes/1.19` (or `deploy/kubernetes/1.13` for older version) to get the CSI setup
  16. ### Example: Adding Dropbox through rclone
  17. The easiest way to use this is to specify your rclone configuration inside the PV:
  18. ```yaml
  19. apiVersion: v1
  20. kind: PersistentVolume
  21. metadata:
  22. name: rclone-dropbox
  23. labels:
  24. name: rclone-dropbox
  25. spec:
  26. accessModes:
  27. - ReadWriteMany
  28. capacity:
  29. storage: 10Gi
  30. storageClassName: rclone
  31. csi:
  32. driver: csi-rclone
  33. volumeHandle: rclone-dropbox-data-id
  34. volumeAttributes:
  35. remote: "dropbox"
  36. remotePath: ""
  37. configData: |
  38. [dropbox]
  39. type = dropbox
  40. client_id = xxx
  41. client_secret = xxx
  42. token = {"access_token":"xxx","token_type":"bearer","refresh_token":"xxx","expiry":"xxx"}
  43. ---
  44. apiVersion: v1
  45. kind: PersistentVolumeClaim
  46. metadata:
  47. name: rclone-dropbox
  48. spec:
  49. accessModes:
  50. - ReadWriteMany
  51. resources:
  52. requests:
  53. storage: 10Gi
  54. storageClassName: rclone
  55. selector:
  56. matchLabels:
  57. name: rclone-dropbox
  58. ```
  59. (to get access token, setup Dropbox locally with rclone first, then copy whatever `rclone config show` gives you)
  60. ### Example: S3 storage without direct rclone configuration
  61. ```yaml
  62. apiVersion: v1
  63. kind: PersistentVolume
  64. metadata:
  65. name: rclone-wasabi
  66. labels:
  67. name: rclone-wasabi
  68. spec:
  69. accessModes:
  70. - ReadWriteMany
  71. capacity:
  72. storage: 1000Gi
  73. storageClassName: rclone
  74. csi:
  75. driver: csi-rclone
  76. volumeHandle: data-id
  77. volumeAttributes:
  78. remote: "bucketname"
  79. remotePath: ""
  80. s3-provider: "Wasabi"
  81. s3-endpoint: "https://s3.ap-southeast-1.wasabisys.com"
  82. s3-access-key-id: "xxx"
  83. s3-secret-access-key: "xxx"
  84. ---
  85. <pvc manifest here>
  86. ```
  87. ### Example: Using a secret (thanks to [wunderio/csi-rclone#7](https://github.com/wunderio/csi-rclone/pull/7))
  88. _Note:_ secrets act as defaults, you can still override keys in your PV definitions.
  89. _Note 2_: Use `secret-rclone` as global default for when there are no secrets defined, for example if you always want the same S3 credentials across your PVs
  90. _Note 3_: Secrets need to be in the same namespace as the csi controller, so if you used the default of this repository, add it to `kube-system`
  91. ```yaml
  92. apiVersion: v1
  93. kind: Secret
  94. metadata:
  95. name: my-secret
  96. namespace: kube-system # <-- secret needs to be in kube-system namespace, same as CSI controller
  97. type: Opaque
  98. stringData:
  99. remote: "my-s3"
  100. remotePath: "projectname"
  101. configData: |
  102. [my-s3]
  103. type = s3
  104. provider = Minio
  105. access_key_id = ACCESS_KEY_ID
  106. secret_access_key = SECRET_ACCESS_KEY
  107. endpoint = http://minio-release.default:9000
  108. ```
  109. Then specify it into the PV:
  110. ```yaml
  111. apiVersion: v1
  112. kind: PersistentVolume
  113. metadata:
  114. name: rclone-dropbox
  115. labels:
  116. name: rclone-dropbox
  117. spec:
  118. accessModes:
  119. - ReadWriteMany
  120. capacity:
  121. storage: 10Gi
  122. storageClassName: rclone
  123. csi:
  124. driver: csi-rclone
  125. volumeHandle: rclone-dropbox-data-id
  126. volumeAttributes:
  127. secretName: "my-secret"
  128. ```
  129. ## Debugging & logs
  130. - After creating a pod, if something goes wrong you should be able to see it using `kubectl describe <pod>`
  131. - Check logs of the controller: `kubectl logs -f -l app=csi-nodeplugin-rclone --namespace kube-system -c rclone`
  132. ## Building plugin and creating image
  133. 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).
  134. 1. First push the changed code to remote. The build will use paths from `pkg/` directory.
  135. 2. Build the plugin
  136. ```
  137. make plugin
  138. ```
  139. 3. Build the container and inject the plugin into it.
  140. ```
  141. make container
  142. ```
  143. 4. Change docker.io account in `Makefile` and use `make push` to push the image to remote.
  144. ```
  145. make push
  146. ```
  147. ## Changelog
  148. See [CHANGELOG.txt](CHANGELOG.txt)

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。