Skip to content

Commit

Permalink
Merge pull request #2 from liuxuzxx/feature/support-mountpoint-s3
Browse files Browse the repository at this point in the history
Feature/support mountpoint s3
  • Loading branch information
liuxuzxx authored Apr 9, 2024
2 parents 5ccd3c1 + 6fefda1 commit 69d5596
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 9 deletions.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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|

<summary>Previous Images</summary>

| 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插件实现

Expand Down
2 changes: 1 addition & 1 deletion cmd/s3csi/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
tag="v1.1.0"
tag="release-v1.2.0.1"

go build

Expand Down
12 changes: 12 additions & 0 deletions deploy/s3-csi/templates/mounter-bucket-sc.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions deploy/s3-csi/templates/storageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion deploy/s3-csi/values.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/test/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions pkg/s3/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`
Expand Down
21 changes: 21 additions & 0 deletions pkg/s3/mounter.go
Original file line number Diff line number Diff line change
@@ -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的挂载的接口
Expand All @@ -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)
}
}

0 comments on commit 69d5596

Please sign in to comment.