mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-29 17:50:23 +00:00
Merge pull request #262 from Madhu-1/fix-driver-name
Fix driver name as per CSI spec
This commit is contained in:
commit
76a647d20e
@ -32,7 +32,7 @@ func init() {
|
||||
|
||||
var (
|
||||
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
|
||||
driverName = flag.String("drivername", "csi-cephfsplugin", "name of the driver")
|
||||
driverName = flag.String("drivername", "cephfs.csi.ceph.com", "name of the driver")
|
||||
nodeId = flag.String("nodeid", "", "node id")
|
||||
volumeMounter = flag.String("volumemounter", "", "default volume mounter (possible options are 'kernel', 'fuse')")
|
||||
metadataStorage = flag.String("metadatastorage", "node", "metadata persistence method [node|k8s_configmap]")
|
||||
@ -41,6 +41,14 @@ var (
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
err := util.ValidateDriverName(*driverName)
|
||||
if err != nil {
|
||||
glog.Errorf("failed to validate driver name: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
//update plugin name
|
||||
cephfs.PluginFolder = cephfs.PluginFolder + *driverName
|
||||
|
||||
if err := createPersistentStorage(path.Join(cephfs.PluginFolder, "controller")); err != nil {
|
||||
glog.Errorf("failed to create persistent storage for controller: %v", err)
|
||||
os.Exit(1)
|
||||
|
@ -33,13 +33,13 @@ spec:
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: /var/lib/kubelet/plugins/csi-cephfsplugin/csi.sock
|
||||
value: /var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin
|
||||
mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||
volumes:
|
||||
- name: socket-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-cephfsplugin
|
||||
path: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||
type: DirectoryOrCreate
|
||||
|
@ -29,18 +29,18 @@ spec:
|
||||
- name: csi-provisioner
|
||||
image: quay.io/k8scsi/csi-provisioner:v0.3.0
|
||||
args:
|
||||
- "--provisioner=csi-cephfsplugin"
|
||||
- "--provisioner=cephfs.csi.ceph.com"
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
- "--v=5"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: /var/lib/kubelet/plugins/csi-cephfsplugin/csi.sock
|
||||
value: /var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin
|
||||
mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||
volumes:
|
||||
- name: socket-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-cephfsplugin
|
||||
path: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||
type: DirectoryOrCreate
|
||||
|
@ -25,16 +25,16 @@ spec:
|
||||
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: /var/lib/kubelet/plugins/csi-cephfsplugin/csi.sock
|
||||
value: /var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi.sock
|
||||
- name: DRIVER_REG_SOCK_PATH
|
||||
value: /var/lib/kubelet/plugins/csi-cephfsplugin/csi.sock
|
||||
value: /var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi.sock
|
||||
- name: KUBE_NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin
|
||||
mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||
- name: registration-dir
|
||||
mountPath: /registration
|
||||
- name: csi-cephfsplugin
|
||||
@ -44,11 +44,11 @@ spec:
|
||||
add: ["SYS_ADMIN"]
|
||||
allowPrivilegeEscalation: true
|
||||
image: quay.io/cephcsi/cephfsplugin:v0.3.0
|
||||
args :
|
||||
args:
|
||||
- "--nodeid=$(NODE_ID)"
|
||||
- "--endpoint=$(CSI_ENDPOINT)"
|
||||
- "--v=5"
|
||||
- "--drivername=csi-cephfsplugin"
|
||||
- "--drivername=cephfs.csi.ceph.com"
|
||||
- "--metadatastorage=k8s_configmap"
|
||||
env:
|
||||
- name: NODE_ID
|
||||
@ -60,11 +60,11 @@ spec:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: CSI_ENDPOINT
|
||||
value: unix://var/lib/kubelet/plugins/csi-cephfsplugin/csi.sock
|
||||
value: unix://var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
volumeMounts:
|
||||
- name: plugin-dir
|
||||
mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin
|
||||
mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||
- name: pods-mount-dir
|
||||
mountPath: /var/lib/kubelet/pods
|
||||
mountPropagation: "Bidirectional"
|
||||
@ -78,7 +78,7 @@ spec:
|
||||
volumes:
|
||||
- name: plugin-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-cephfsplugin
|
||||
path: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||
type: DirectoryOrCreate
|
||||
- name: registration-dir
|
||||
hostPath:
|
||||
@ -90,7 +90,7 @@ spec:
|
||||
type: Directory
|
||||
- name: socket-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-cephfsplugin
|
||||
path: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||
type: DirectoryOrCreate
|
||||
- name: host-sys
|
||||
hostPath:
|
||||
|
@ -64,7 +64,7 @@ spec:
|
||||
- "--nodeid=$(NODE_ID)"
|
||||
- "--endpoint=$(CSI_ENDPOINT)"
|
||||
- "--v=5"
|
||||
- "--drivername=csi-rbdplugin"
|
||||
- "--drivername=rbd.csi.ceph.com"
|
||||
- "--containerized=true"
|
||||
env:
|
||||
- name: HOST_ROOTFS
|
||||
|
@ -25,7 +25,7 @@ spec:
|
||||
- name: csi-provisioner
|
||||
image: "{{ .Values.provisioner.image.repository }}:{{ .Values.provisioner.image.tag }}"
|
||||
args:
|
||||
- "--provisioner=csi-rbdplugin"
|
||||
- "--provisioner=rbd.csi.ceph.com"
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
- "--v=5"
|
||||
env:
|
||||
|
@ -12,7 +12,7 @@ serviceAccounts:
|
||||
create: true
|
||||
name:
|
||||
|
||||
socketDir: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
socketDir: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
socketFile: csi.sock
|
||||
|
||||
attacher:
|
||||
|
@ -33,13 +33,13 @@ spec:
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: /var/lib/kubelet/plugins/csi-rbdplugin/csi.sock
|
||||
value: /var/lib/kubelet/plugins/rbd.csi.ceph.com/csi.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
volumes:
|
||||
- name: socket-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
type: DirectoryOrCreate
|
||||
|
@ -29,18 +29,18 @@ spec:
|
||||
- name: csi-provisioner
|
||||
image: quay.io/k8scsi/csi-provisioner:v0.3.0
|
||||
args:
|
||||
- "--provisioner=csi-rbdplugin"
|
||||
- "--provisioner=rbd.csi.ceph.com"
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
- "--v=5"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: /var/lib/kubelet/plugins/csi-rbdplugin/csi.sock
|
||||
value: /var/lib/kubelet/plugins/rbd.csi.ceph.com/csi.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
volumes:
|
||||
- name: socket-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
type: DirectoryOrCreate
|
||||
|
@ -26,16 +26,16 @@ spec:
|
||||
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: /var/lib/kubelet/plugins/csi-rbdplugin/csi.sock
|
||||
value: /var/lib/kubelet/plugins/rbd.csi.ceph.com/csi.sock
|
||||
- name: DRIVER_REG_SOCK_PATH
|
||||
value: /var/lib/kubelet/plugins/csi-rbdplugin/csi.sock
|
||||
value: /var/lib/kubelet/plugins/rbd.csi.ceph.com/csi.sock
|
||||
- name: KUBE_NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
- name: registration-dir
|
||||
mountPath: /registration
|
||||
- name: csi-rbdplugin
|
||||
@ -45,11 +45,11 @@ spec:
|
||||
add: ["SYS_ADMIN"]
|
||||
allowPrivilegeEscalation: true
|
||||
image: quay.io/cephcsi/rbdplugin:v0.3.0
|
||||
args :
|
||||
args:
|
||||
- "--nodeid=$(NODE_ID)"
|
||||
- "--endpoint=$(CSI_ENDPOINT)"
|
||||
- "--v=5"
|
||||
- "--drivername=csi-rbdplugin"
|
||||
- "--drivername=rbd.csi.ceph.com"
|
||||
- "--containerized=true"
|
||||
- "--metadatastorage=k8s_configmap"
|
||||
env:
|
||||
@ -64,11 +64,11 @@ spec:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: CSI_ENDPOINT
|
||||
value: unix://var/lib/kubelet/plugins/csi-rbdplugin/csi.sock
|
||||
value: unix://var/lib/kubelet/plugins/rbd.csi.ceph.com/csi.sock
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
volumeMounts:
|
||||
- name: plugin-dir
|
||||
mountPath: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
- name: pods-mount-dir
|
||||
mountPath: /var/lib/kubelet/pods
|
||||
mountPropagation: "Bidirectional"
|
||||
@ -84,7 +84,7 @@ spec:
|
||||
volumes:
|
||||
- name: plugin-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
type: DirectoryOrCreate
|
||||
- name: registration-dir
|
||||
hostPath:
|
||||
@ -96,7 +96,7 @@ spec:
|
||||
type: Directory
|
||||
- name: socket-dir
|
||||
hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
type: DirectoryOrCreate
|
||||
- name: host-dev
|
||||
hostPath:
|
||||
|
@ -25,7 +25,7 @@ make image-cephfsplugin
|
||||
Option | Default value | Description
|
||||
--------------------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
`--endpoint` | `unix://tmp/csi.sock` | CSI endpoint, must be a UNIX socket
|
||||
`--drivername` | `csi-cephfsplugin` | name of the driver (Kubernetes: `provisioner` field in StorageClass must correspond to this value)
|
||||
`--drivername` | `cephfs.csi.ceph.com` | name of the driver (Kubernetes: `provisioner` field in StorageClass must correspond to this value)
|
||||
`--nodeid` | _empty_ | This node's ID
|
||||
`--volumemounter` | _empty_ | default volume mounter. Available options are `kernel` and `fuse`. This is the mount method used if volume parameters don't specify otherwise. If left unspecified, the driver will first probe for `ceph-fuse` in system's path and will choose Ceph kernel client if probing failed.
|
||||
`--metadatastorage` | _empty_ | Whether metadata should be kept on node as file or in a k8s configmap (`node` or `k8s_configmap`)
|
||||
|
@ -25,7 +25,7 @@ make image-rbdplugin
|
||||
Option | Default value | Description
|
||||
--------------------|-----------------------|---------------------------------------------------------------------------------------------------
|
||||
`--endpoint` | `unix://tmp/csi.sock` | CSI endpoint, must be a UNIX socket
|
||||
`--drivername` | `csi-cephfsplugin` | name of the driver (Kubernetes: `provisioner` field in StorageClass must correspond to this value)
|
||||
`--drivername` | `rbd.csi.ceph.com` | name of the driver (Kubernetes: `provisioner` field in StorageClass must correspond to this value)
|
||||
`--nodeid` | _empty_ | This node's ID
|
||||
`--containerized` | true | Whether running in containerized mode
|
||||
`--metadatastorage` | _empty_ | Whether should metadata be kept on node as file or in a k8s configmap (`node` or `k8s_configmap`)
|
||||
|
@ -51,6 +51,6 @@ spec:
|
||||
imagePullPolicy: Always
|
||||
volumes:
|
||||
- hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||
type: DirectoryOrCreate
|
||||
name: socket-dir
|
||||
|
@ -20,18 +20,21 @@ import (
|
||||
"github.com/golang/glog"
|
||||
|
||||
"github.com/container-storage-interface/spec/lib/go/csi/v0"
|
||||
"github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
csicommon "github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// PluginFolder is the kubelet plugin directory for cephfs plugin
|
||||
PluginFolder = "/var/lib/kubelet/plugins/csi-cephfsplugin"
|
||||
// Version of the cephfs csi driver
|
||||
Version = "0.3.0"
|
||||
)
|
||||
|
||||
var (
|
||||
// PluginFolder is the kubelet plugin directory for cephfs plugin
|
||||
PluginFolder = "/var/lib/kubelet/plugins/"
|
||||
)
|
||||
|
||||
type cephfsDriver struct {
|
||||
driver *csicommon.CSIDriver
|
||||
|
||||
|
@ -23,12 +23,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
cephRootPrefix = PluginFolder + "/controller/volumes/root-"
|
||||
cephVolumesRoot = "csi-volumes"
|
||||
|
||||
namespacePrefix = "ns-"
|
||||
)
|
||||
|
||||
var (
|
||||
cephRootPrefix = PluginFolder + "/controller/volumes/root-"
|
||||
)
|
||||
|
||||
func getCephRootPathLocal(volId volumeID) string {
|
||||
return cephRootPrefix + string(volId)
|
||||
}
|
||||
|
@ -21,20 +21,23 @@ import (
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
"github.com/container-storage-interface/spec/lib/go/csi/v0"
|
||||
"github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
csicommon "github.com/kubernetes-csi/drivers/pkg/csi-common"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
"k8s.io/kubernetes/pkg/util/nsenter"
|
||||
"k8s.io/utils/exec"
|
||||
)
|
||||
|
||||
// PluginFolder defines the location of rbdplugin
|
||||
const (
|
||||
PluginFolder = "/var/lib/kubelet/plugins/csi-rbdplugin"
|
||||
rbdDefaultAdminId = "admin"
|
||||
rbdDefaultUserId = rbdDefaultAdminId
|
||||
)
|
||||
|
||||
var (
|
||||
// PluginFolder defines the location of rbdplugin
|
||||
PluginFolder = "/var/lib/kubelet/plugins/"
|
||||
)
|
||||
|
||||
type rbd struct {
|
||||
driver *csicommon.CSIDriver
|
||||
|
||||
|
41
pkg/util/util.go
Normal file
41
pkg/util/util.go
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
)
|
||||
|
||||
// ValidateDriverName validates the driver name
|
||||
func ValidateDriverName(driverName string) error {
|
||||
if len(driverName) == 0 {
|
||||
return errors.New("driver name is empty")
|
||||
}
|
||||
|
||||
if len(driverName) > 63 {
|
||||
return errors.New("driver name length should be less than 63 chars")
|
||||
}
|
||||
var err error
|
||||
for _, msg := range validation.IsDNS1123Subdomain(strings.ToLower(driverName)) {
|
||||
if err == nil {
|
||||
err = errors.New(msg)
|
||||
continue
|
||||
}
|
||||
err = errors.Wrap(err, msg)
|
||||
}
|
||||
return err
|
||||
}
|
10
rbd/main.go
10
rbd/main.go
@ -32,7 +32,7 @@ func init() {
|
||||
|
||||
var (
|
||||
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
|
||||
driverName = flag.String("drivername", "csi-rbdplugin", "name of the driver")
|
||||
driverName = flag.String("drivername", "rbd.csi.ceph.com", "name of the driver")
|
||||
nodeID = flag.String("nodeid", "", "node id")
|
||||
containerized = flag.Bool("containerized", true, "whether run as containerized")
|
||||
metadataStorage = flag.String("metadatastorage", "node", "metadata persistence method [node|k8s_configmap]")
|
||||
@ -41,6 +41,14 @@ var (
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
err := util.ValidateDriverName(*driverName)
|
||||
if err != nil {
|
||||
glog.Errorf("failed to validate driver name: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
//update plugin name
|
||||
rbd.PluginFolder = rbd.PluginFolder + *driverName
|
||||
|
||||
if err := createPersistentStorage(path.Join(rbd.PluginFolder, "controller")); err != nil {
|
||||
glog.Errorf("failed to create persistent storage for controller %v", err)
|
||||
os.Exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user