Skip to content

Commit 69d5596

Browse files
authored
Merge pull request #2 from liuxuzxx/feature/support-mountpoint-s3
Feature/support mountpoint s3
2 parents 5ccd3c1 + 6fefda1 commit 69d5596

File tree

9 files changed

+104
-9
lines changed

9 files changed

+104
-9
lines changed

README.md

+60
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
# S3 CSI Driver (Minio/Huawei cloud OBS/Amazon S3)
2+
3+
## Overview
4+
The Mountpoint for S3 Container Storage Interface (CSI) Driver allows your Kubernetes applications to access S3 objects through a file system interface.
5+
6+
## Fatures
7+
* **Static Provisioning** - Associate an existing S3 bucket with a [PersistentVolume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) (PV) for consumption within Kubernetes.
8+
* **Mount Options** - Mount options can be specified in the PersistentVolume (PV) resource to define how the volume should be mounted. For Mountpoint-specific options
9+
10+
## Support S3 Server
11+
12+
|S3 Server Type|Supported|Remark|
13+
|:--:|:--:|:--:|
14+
|MinIO|Yes|No|
15+
|Huawei Cloud OBS|Yes|No|
16+
|Amazon S3|Yes|No|
17+
18+
## Support Mounter type
19+
20+
* **rclone** - [Rclone Github Link](https://github.com/rclone/rclone.git)
21+
* **mountpoint-s3** [mountpoint-s3 Github Link](https://github.com/awslabs/mountpoint-s3-csi-driver.git)
22+
23+
## Container Images
24+
| Driver Version | Image(Docker hub)|
25+
|----------------|------------------|
26+
| v1.2.0 | liuxuzxx/csi-s3:v1.2.0|
27+
28+
<summary>Previous Images</summary>
29+
30+
| Driver Version | Image(Docker hub) |
31+
|----------------|-------------------|
32+
| v1.1.0 | liuxuzxx/csi/s3:v1.1.0|
33+
34+
## Install
35+
36+
We support install use Helm
37+
38+
1. [Install Helm](https://helm.sh/docs/intro/install/)
39+
2. Install csi-s3
40+
```bash
41+
linux> git clone https://github.com/liuxuzxx/csi-s3.git
42+
linux> cd csi-s3/deploy/s3-csi
43+
linux> helm install csi-s3 ./ -n xxx
44+
```
45+
46+
47+
## Self Build
48+
49+
```bash
50+
linux> git clone https://github.com/liuxuzxx/csi-s3.git
51+
linux> cd csi-s3/cmd/s3csi
52+
53+
#build image
54+
linux> bash build-nopush.sh
55+
56+
#go build
57+
linux> go build
58+
```
59+
60+
161
# 概述
262
支持S3协议的K8S的CSI插件实现
363

cmd/s3csi/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
tag="v1.1.0"
2+
tag="release-v1.2.0.1"
33

44
go build
55

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: storage.k8s.io/v1
2+
kind: StorageClass
3+
metadata:
4+
name: mounter-bucket-xw-sc
5+
provisioner: minio.s3.csi.xw.com
6+
parameters:
7+
#目前支持两种类型: rclone,mountpoint-s3
8+
mounter: mountpoint-s3
9+
bucket: mounter-bucket-sc-dev
10+
access-key: {{ .Values.minio.accessKey }}
11+
secret-key: {{ .Values.minio.accessSecret }}
12+
endpoint: {{ .Values.minio.url }}

deploy/s3-csi/templates/storageclass.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ metadata:
44
name: minio-csi-s3-xw
55
provisioner: minio.s3.csi.xw.com
66
parameters:
7+
#目前支持两种类型: rclone,mountpoint-s3
78
mounter: mount-s3
89
bucket: {{ .Values.minio.bucket }}
910
access-key: {{ .Values.minio.accessKey }}

deploy/s3-csi/values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
global:
22
image: xwharbor.wxchina.com/cpaas-dev/component/csi-s3
3-
tag: v1.1.0
3+
tag: release-v1.2.0.1
44

55
minio:
66
url: 10.20.121.41:30629

deploy/test/pvc.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: test-s3-minio
55
namespace: minio
66
spec:
7-
storageClassName: minio-csi-s3-xw
7+
storageClassName: mounter-bucket-xw-sc
88
resources:
99
requests:
1010
storage: 10Gi

pkg/driver/nodeserver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
5555
return &csi.NodePublishVolumeResponse{}, nil
5656
}
5757

58-
mnt := s3.NewRclone(req)
58+
mnt := s3.NewMounter(req)
5959
err = mnt.Mount(volumeId, target)
6060
klog.V(4).Info("Rclone mount command execute finish!")
6161
if err != nil {

pkg/s3/minio.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import (
1111
)
1212

1313
const (
14-
Bucket string = "bucket"
15-
AccessKey string = "access-key"
16-
SecretKey string = "secret-key"
17-
Endpoint string = "endpoint"
18-
Version string = `S3-Service: Minio
14+
MounterType string = "mounter"
15+
Bucket string = "bucket"
16+
AccessKey string = "access-key"
17+
SecretKey string = "secret-key"
18+
Endpoint string = "endpoint"
19+
Version string = `S3-Service: Minio
1920
CSI: K8S
2021
Company: Xuanwu Technolojy
2122
`

pkg/s3/mounter.go

+21
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package s3
22

3+
import (
4+
"github.com/container-storage-interface/spec/lib/go/csi"
5+
)
6+
37
const (
48
AwsAccessKeyId = "AWS_ACCESS_KEY_ID"
59
AwsSecretAccessKey = "AWS_SECRET_ACCESS_KEY"
610
MountConfig = "MOUNT_CONFIG"
11+
12+
//定义Mounter挂载器类型
13+
RcloneMounter = "rclone"
14+
MountpointS3Mounter = "mountpoint-s3"
715
)
816

917
// 定义Mounter接口,定义好对接S3的挂载的接口
@@ -17,3 +25,16 @@ type Mounter interface {
1725
//执行mount的挂载操作
1826
Mount(source string, target string) error
1927
}
28+
29+
func NewMounter(req *csi.NodePublishVolumeRequest) Mounter {
30+
param := req.GetVolumeContext()
31+
mounter := param[MounterType]
32+
switch mounter {
33+
case RcloneMounter:
34+
return NewRclone(req)
35+
case MountpointS3Mounter:
36+
return NewMountpointS3(req)
37+
default:
38+
return NewRclone(req)
39+
}
40+
}

0 commit comments

Comments
 (0)