diff --git a/README.md b/README.md index 17b21e9..c937c14 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,63 @@ +# S3 CSI Driver (Minio/Huawei cloud OBS/Amazon S3) + +## Overview +The Mountpoint for S3 Container Storage Interface (CSI) Driver allows your Kubernetes applications to access S3 objects through a file system interface. + +## Fatures +* **Static Provisioning** - Associate an existing S3 bucket with a [PersistentVolume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) (PV) for consumption within Kubernetes. +* **Mount Options** - Mount options can be specified in the PersistentVolume (PV) resource to define how the volume should be mounted. For Mountpoint-specific options + +## Support S3 Server + +|S3 Server Type|Supported|Remark| +|:--:|:--:|:--:| +|MinIO|Yes|No| +|Huawei Cloud OBS|Yes|No| +|Amazon S3|Yes|No| + +## Support Mounter type + +* **rclone** - [Rclone Github Link](https://github.com/rclone/rclone.git) +* **mountpoint-s3** [mountpoint-s3 Github Link](https://github.com/awslabs/mountpoint-s3-csi-driver.git) + +## Container Images +| Driver Version | Image(Docker hub)| +|----------------|------------------| +| v1.2.0 | liuxuzxx/csi-s3:v1.2.0| + +Previous Images + +| Driver Version | Image(Docker hub) | +|----------------|-------------------| +| v1.1.0 | liuxuzxx/csi/s3:v1.1.0| + +## Install + +We support install use Helm + +1. [Install Helm](https://helm.sh/docs/intro/install/) +2. Install csi-s3 +```bash +linux> git clone https://github.com/liuxuzxx/csi-s3.git +linux> cd csi-s3/deploy/s3-csi +linux> helm install csi-s3 ./ -n xxx +``` + + +## Self Build + +```bash +linux> git clone https://github.com/liuxuzxx/csi-s3.git +linux> cd csi-s3/cmd/s3csi + +#build image +linux> bash build-nopush.sh + +#go build +linux> go build +``` + + # 概述 支持S3协议的K8S的CSI插件实现 diff --git a/cmd/s3csi/build.sh b/cmd/s3csi/build.sh index c222245..5f3bad6 100644 --- a/cmd/s3csi/build.sh +++ b/cmd/s3csi/build.sh @@ -1,5 +1,5 @@ #!/bin/bash -tag="v1.1.0" +tag="release-v1.2.0.1" go build diff --git a/deploy/s3-csi/templates/mounter-bucket-sc.yaml b/deploy/s3-csi/templates/mounter-bucket-sc.yaml new file mode 100644 index 0000000..cada01f --- /dev/null +++ b/deploy/s3-csi/templates/mounter-bucket-sc.yaml @@ -0,0 +1,12 @@ +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: mounter-bucket-xw-sc +provisioner: minio.s3.csi.xw.com +parameters: + #目前支持两种类型: rclone,mountpoint-s3 + mounter: mountpoint-s3 + bucket: mounter-bucket-sc-dev + access-key: {{ .Values.minio.accessKey }} + secret-key: {{ .Values.minio.accessSecret }} + endpoint: {{ .Values.minio.url }} \ No newline at end of file diff --git a/deploy/s3-csi/templates/storageclass.yaml b/deploy/s3-csi/templates/storageclass.yaml index 6274bb6..a4cce2f 100644 --- a/deploy/s3-csi/templates/storageclass.yaml +++ b/deploy/s3-csi/templates/storageclass.yaml @@ -4,6 +4,7 @@ metadata: name: minio-csi-s3-xw provisioner: minio.s3.csi.xw.com parameters: + #目前支持两种类型: rclone,mountpoint-s3 mounter: mount-s3 bucket: {{ .Values.minio.bucket }} access-key: {{ .Values.minio.accessKey }} diff --git a/deploy/s3-csi/values.yaml b/deploy/s3-csi/values.yaml index b8c929b..649a102 100644 --- a/deploy/s3-csi/values.yaml +++ b/deploy/s3-csi/values.yaml @@ -1,6 +1,6 @@ global: image: xwharbor.wxchina.com/cpaas-dev/component/csi-s3 - tag: v1.1.0 + tag: release-v1.2.0.1 minio: url: 10.20.121.41:30629 diff --git a/deploy/test/pvc.yaml b/deploy/test/pvc.yaml index 2f0e00d..424790d 100644 --- a/deploy/test/pvc.yaml +++ b/deploy/test/pvc.yaml @@ -4,7 +4,7 @@ metadata: name: test-s3-minio namespace: minio spec: - storageClassName: minio-csi-s3-xw + storageClassName: mounter-bucket-xw-sc resources: requests: storage: 10Gi diff --git a/pkg/driver/nodeserver.go b/pkg/driver/nodeserver.go index 2351466..e023fb1 100644 --- a/pkg/driver/nodeserver.go +++ b/pkg/driver/nodeserver.go @@ -55,7 +55,7 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis return &csi.NodePublishVolumeResponse{}, nil } - mnt := s3.NewRclone(req) + mnt := s3.NewMounter(req) err = mnt.Mount(volumeId, target) klog.V(4).Info("Rclone mount command execute finish!") if err != nil { diff --git a/pkg/s3/minio.go b/pkg/s3/minio.go index a735390..3dd336d 100644 --- a/pkg/s3/minio.go +++ b/pkg/s3/minio.go @@ -11,11 +11,12 @@ import ( ) const ( - Bucket string = "bucket" - AccessKey string = "access-key" - SecretKey string = "secret-key" - Endpoint string = "endpoint" - Version string = `S3-Service: Minio + MounterType string = "mounter" + Bucket string = "bucket" + AccessKey string = "access-key" + SecretKey string = "secret-key" + Endpoint string = "endpoint" + Version string = `S3-Service: Minio CSI: K8S Company: Xuanwu Technolojy ` diff --git a/pkg/s3/mounter.go b/pkg/s3/mounter.go index d712698..cf78e97 100644 --- a/pkg/s3/mounter.go +++ b/pkg/s3/mounter.go @@ -1,9 +1,17 @@ package s3 +import ( + "github.com/container-storage-interface/spec/lib/go/csi" +) + const ( AwsAccessKeyId = "AWS_ACCESS_KEY_ID" AwsSecretAccessKey = "AWS_SECRET_ACCESS_KEY" MountConfig = "MOUNT_CONFIG" + + //定义Mounter挂载器类型 + RcloneMounter = "rclone" + MountpointS3Mounter = "mountpoint-s3" ) // 定义Mounter接口,定义好对接S3的挂载的接口 @@ -17,3 +25,16 @@ type Mounter interface { //执行mount的挂载操作 Mount(source string, target string) error } + +func NewMounter(req *csi.NodePublishVolumeRequest) Mounter { + param := req.GetVolumeContext() + mounter := param[MounterType] + switch mounter { + case RcloneMounter: + return NewRclone(req) + case MountpointS3Mounter: + return NewMountpointS3(req) + default: + return NewRclone(req) + } +}