Allow configuring mounter via storageclass parameter
This commit is contained in:
parent
4b82c93978
commit
c7abe28ade
7 changed files with 18 additions and 17 deletions
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -23,6 +23,7 @@ type s3Client struct {
|
|||
|
||||
type bucket struct {
|
||||
Name string
|
||||
Mounter string
|
||||
FSPath string
|
||||
CapacityBytes int64
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue