Allow configuring mounter via storageclass parameter

This commit is contained in:
Cyrill Troxler 2018-07-29 10:00:53 +02:00
parent 4b82c93978
commit c7abe28ade
7 changed files with 18 additions and 17 deletions

View file

@ -83,7 +83,6 @@ spec:
- "--secret-access-key=$(SECRET_ACCESS_KEY)"
- "--s3-endpoint=$(S3_ENDPOINT)"
- "--region=$(REGION)"
- "--mounter=$(MOUNTER)"
- "--encryption-key=$(ENCRYPTION_KEY)"
- "--v=4"
env:
@ -113,11 +112,6 @@ spec:
secretKeyRef:
name: csi-s3-secret
key: region
- name: MOUNTER
valueFrom:
secretKeyRef:
name: csi-s3-secret
key: mounter
- name: ENCRYPTION_KEY
valueFrom:
secretKeyRef:

View file

@ -87,7 +87,6 @@ spec:
- "--secret-access-key=$(SECRET_ACCESS_KEY)"
- "--s3-endpoint=$(S3_ENDPOINT)"
- "--region=$(REGION)"
- "--mounter=$(MOUNTER)"
- "--encryption-key=$(ENCRYPTION_KEY)"
- "--v=4"
env:
@ -117,11 +116,6 @@ spec:
secretKeyRef:
name: csi-s3-secret
key: region
- name: MOUNTER
valueFrom:
secretKeyRef:
name: csi-s3-secret
key: mounter
- name: ENCRYPTION_KEY
valueFrom:
secretKeyRef:

View file

@ -8,9 +8,6 @@ stringData:
endpoint: <S3_ENDPOINT_URL>
# If not on S3, set it to ""
region: <S3_REGION>
# specify which mounter to use
# can be set to s3fs, goofys or s3ql
mounter: <MOUNTER>
# Currently only for s3ql
# If not using s3ql, set it to ""
encryptionKey: <FS_ENCRYPTION_KEY>

View file

@ -4,3 +4,7 @@ apiVersion: storage.k8s.io/v1
metadata:
name: csi-s3
provisioner: ch.ctrox.csi.s3-driver
parameters:
# specify which mounter to use
# can be set to s3backer, s3ql, s3fs or goofys
mounter: s3backer

View file

@ -50,6 +50,8 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}
capacityBytes := int64(req.GetCapacityRange().GetRequiredBytes())
params := req.GetParameters()
mounter := params[mounterTypeKey]
glog.V(5).Infof("Got a request to create bucket %s", volumeID)
@ -77,6 +79,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}
b := &bucket{
Name: volumeID,
Mounter: mounter,
CapacityBytes: capacityBytes,
FSPath: fsPrefix,
}

View file

@ -22,11 +22,17 @@ const (
goofysMounterType = "goofys"
s3qlMounterType = "s3ql"
s3backerMounterType = "s3backer"
mounterTypeKey = "mounter"
)
// newMounter returns a new mounter depending on the mounterType parameter
func newMounter(bucket *bucket, cfg *Config) (Mounter, error) {
switch cfg.Mounter {
mounter := bucket.Mounter
// Fall back to mounterType in cfg
if len(bucket.Mounter) == 0 {
mounter = cfg.Mounter
}
switch mounter {
case s3fsMounterType:
return newS3fsMounter(bucket, cfg)
@ -39,8 +45,10 @@ func newMounter(bucket *bucket, cfg *Config) (Mounter, error) {
case s3backerMounterType:
return newS3backerMounter(bucket, cfg)
default:
// default to s3backer
return newS3backerMounter(bucket, cfg)
}
return nil, fmt.Errorf("Error mounting bucket %s, invalid mounter specified: %s", bucket.Name, cfg.Mounter)
}
func fuseMount(path string, command string, args []string) error {

View file

@ -23,6 +23,7 @@ type s3Client struct {
type bucket struct {
Name string
Mounter string
FSPath string
CapacityBytes int64
}