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 (
|
var (
|
||||||
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
|
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")
|
nodeId = flag.String("nodeid", "", "node id")
|
||||||
volumeMounter = flag.String("volumemounter", "", "default volume mounter (possible options are 'kernel', 'fuse')")
|
volumeMounter = flag.String("volumemounter", "", "default volume mounter (possible options are 'kernel', 'fuse')")
|
||||||
metadataStorage = flag.String("metadatastorage", "node", "metadata persistence method [node|k8s_configmap]")
|
metadataStorage = flag.String("metadatastorage", "node", "metadata persistence method [node|k8s_configmap]")
|
||||||
@ -41,6 +41,14 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
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 {
|
if err := createPersistentStorage(path.Join(cephfs.PluginFolder, "controller")); err != nil {
|
||||||
glog.Errorf("failed to create persistent storage for controller: %v", err)
|
glog.Errorf("failed to create persistent storage for controller: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -33,13 +33,13 @@ spec:
|
|||||||
- "--csi-address=$(ADDRESS)"
|
- "--csi-address=$(ADDRESS)"
|
||||||
env:
|
env:
|
||||||
- name: ADDRESS
|
- name: ADDRESS
|
||||||
value: /var/lib/kubelet/plugins/csi-cephfsplugin/csi.sock
|
value: /var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi.sock
|
||||||
imagePullPolicy: "IfNotPresent"
|
imagePullPolicy: "IfNotPresent"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin
|
mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||||
volumes:
|
volumes:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/lib/kubelet/plugins/csi-cephfsplugin
|
path: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
|
@ -29,18 +29,18 @@ spec:
|
|||||||
- name: csi-provisioner
|
- name: csi-provisioner
|
||||||
image: quay.io/k8scsi/csi-provisioner:v0.3.0
|
image: quay.io/k8scsi/csi-provisioner:v0.3.0
|
||||||
args:
|
args:
|
||||||
- "--provisioner=csi-cephfsplugin"
|
- "--provisioner=cephfs.csi.ceph.com"
|
||||||
- "--csi-address=$(ADDRESS)"
|
- "--csi-address=$(ADDRESS)"
|
||||||
- "--v=5"
|
- "--v=5"
|
||||||
env:
|
env:
|
||||||
- name: ADDRESS
|
- name: ADDRESS
|
||||||
value: /var/lib/kubelet/plugins/csi-cephfsplugin/csi.sock
|
value: /var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi.sock
|
||||||
imagePullPolicy: "IfNotPresent"
|
imagePullPolicy: "IfNotPresent"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin
|
mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||||
volumes:
|
volumes:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/lib/kubelet/plugins/csi-cephfsplugin
|
path: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
|
@ -25,16 +25,16 @@ spec:
|
|||||||
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
|
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
|
||||||
env:
|
env:
|
||||||
- name: ADDRESS
|
- 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
|
- 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
|
- name: KUBE_NODE_NAME
|
||||||
valueFrom:
|
valueFrom:
|
||||||
fieldRef:
|
fieldRef:
|
||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin
|
mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||||
- name: registration-dir
|
- name: registration-dir
|
||||||
mountPath: /registration
|
mountPath: /registration
|
||||||
- name: csi-cephfsplugin
|
- name: csi-cephfsplugin
|
||||||
@ -48,7 +48,7 @@ spec:
|
|||||||
- "--nodeid=$(NODE_ID)"
|
- "--nodeid=$(NODE_ID)"
|
||||||
- "--endpoint=$(CSI_ENDPOINT)"
|
- "--endpoint=$(CSI_ENDPOINT)"
|
||||||
- "--v=5"
|
- "--v=5"
|
||||||
- "--drivername=csi-cephfsplugin"
|
- "--drivername=cephfs.csi.ceph.com"
|
||||||
- "--metadatastorage=k8s_configmap"
|
- "--metadatastorage=k8s_configmap"
|
||||||
env:
|
env:
|
||||||
- name: NODE_ID
|
- name: NODE_ID
|
||||||
@ -60,11 +60,11 @@ spec:
|
|||||||
fieldRef:
|
fieldRef:
|
||||||
fieldPath: metadata.namespace
|
fieldPath: metadata.namespace
|
||||||
- name: CSI_ENDPOINT
|
- 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"
|
imagePullPolicy: "IfNotPresent"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: plugin-dir
|
- name: plugin-dir
|
||||||
mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin
|
mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||||
- name: pods-mount-dir
|
- name: pods-mount-dir
|
||||||
mountPath: /var/lib/kubelet/pods
|
mountPath: /var/lib/kubelet/pods
|
||||||
mountPropagation: "Bidirectional"
|
mountPropagation: "Bidirectional"
|
||||||
@ -78,7 +78,7 @@ spec:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: plugin-dir
|
- name: plugin-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/lib/kubelet/plugins/csi-cephfsplugin
|
path: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
- name: registration-dir
|
- name: registration-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
@ -90,7 +90,7 @@ spec:
|
|||||||
type: Directory
|
type: Directory
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/lib/kubelet/plugins/csi-cephfsplugin
|
path: /var/lib/kubelet/plugins/cephfs.csi.ceph.com
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
- name: host-sys
|
- name: host-sys
|
||||||
hostPath:
|
hostPath:
|
||||||
|
@ -64,7 +64,7 @@ spec:
|
|||||||
- "--nodeid=$(NODE_ID)"
|
- "--nodeid=$(NODE_ID)"
|
||||||
- "--endpoint=$(CSI_ENDPOINT)"
|
- "--endpoint=$(CSI_ENDPOINT)"
|
||||||
- "--v=5"
|
- "--v=5"
|
||||||
- "--drivername=csi-rbdplugin"
|
- "--drivername=rbd.csi.ceph.com"
|
||||||
- "--containerized=true"
|
- "--containerized=true"
|
||||||
env:
|
env:
|
||||||
- name: HOST_ROOTFS
|
- name: HOST_ROOTFS
|
||||||
|
@ -25,7 +25,7 @@ spec:
|
|||||||
- name: csi-provisioner
|
- name: csi-provisioner
|
||||||
image: "{{ .Values.provisioner.image.repository }}:{{ .Values.provisioner.image.tag }}"
|
image: "{{ .Values.provisioner.image.repository }}:{{ .Values.provisioner.image.tag }}"
|
||||||
args:
|
args:
|
||||||
- "--provisioner=csi-rbdplugin"
|
- "--provisioner=rbd.csi.ceph.com"
|
||||||
- "--csi-address=$(ADDRESS)"
|
- "--csi-address=$(ADDRESS)"
|
||||||
- "--v=5"
|
- "--v=5"
|
||||||
env:
|
env:
|
||||||
|
@ -12,7 +12,7 @@ serviceAccounts:
|
|||||||
create: true
|
create: true
|
||||||
name:
|
name:
|
||||||
|
|
||||||
socketDir: /var/lib/kubelet/plugins/csi-rbdplugin
|
socketDir: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
socketFile: csi.sock
|
socketFile: csi.sock
|
||||||
|
|
||||||
attacher:
|
attacher:
|
||||||
|
@ -33,13 +33,13 @@ spec:
|
|||||||
- "--csi-address=$(ADDRESS)"
|
- "--csi-address=$(ADDRESS)"
|
||||||
env:
|
env:
|
||||||
- name: ADDRESS
|
- name: ADDRESS
|
||||||
value: /var/lib/kubelet/plugins/csi-rbdplugin/csi.sock
|
value: /var/lib/kubelet/plugins/rbd.csi.ceph.com/csi.sock
|
||||||
imagePullPolicy: "IfNotPresent"
|
imagePullPolicy: "IfNotPresent"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
mountPath: /var/lib/kubelet/plugins/csi-rbdplugin
|
mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
volumes:
|
volumes:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
|
@ -29,18 +29,18 @@ spec:
|
|||||||
- name: csi-provisioner
|
- name: csi-provisioner
|
||||||
image: quay.io/k8scsi/csi-provisioner:v0.3.0
|
image: quay.io/k8scsi/csi-provisioner:v0.3.0
|
||||||
args:
|
args:
|
||||||
- "--provisioner=csi-rbdplugin"
|
- "--provisioner=rbd.csi.ceph.com"
|
||||||
- "--csi-address=$(ADDRESS)"
|
- "--csi-address=$(ADDRESS)"
|
||||||
- "--v=5"
|
- "--v=5"
|
||||||
env:
|
env:
|
||||||
- name: ADDRESS
|
- name: ADDRESS
|
||||||
value: /var/lib/kubelet/plugins/csi-rbdplugin/csi.sock
|
value: /var/lib/kubelet/plugins/rbd.csi.ceph.com/csi.sock
|
||||||
imagePullPolicy: "IfNotPresent"
|
imagePullPolicy: "IfNotPresent"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
mountPath: /var/lib/kubelet/plugins/csi-rbdplugin
|
mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
volumes:
|
volumes:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
|
@ -26,16 +26,16 @@ spec:
|
|||||||
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
|
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
|
||||||
env:
|
env:
|
||||||
- name: ADDRESS
|
- 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
|
- 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
|
- name: KUBE_NODE_NAME
|
||||||
valueFrom:
|
valueFrom:
|
||||||
fieldRef:
|
fieldRef:
|
||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
mountPath: /var/lib/kubelet/plugins/csi-rbdplugin
|
mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
- name: registration-dir
|
- name: registration-dir
|
||||||
mountPath: /registration
|
mountPath: /registration
|
||||||
- name: csi-rbdplugin
|
- name: csi-rbdplugin
|
||||||
@ -49,7 +49,7 @@ spec:
|
|||||||
- "--nodeid=$(NODE_ID)"
|
- "--nodeid=$(NODE_ID)"
|
||||||
- "--endpoint=$(CSI_ENDPOINT)"
|
- "--endpoint=$(CSI_ENDPOINT)"
|
||||||
- "--v=5"
|
- "--v=5"
|
||||||
- "--drivername=csi-rbdplugin"
|
- "--drivername=rbd.csi.ceph.com"
|
||||||
- "--containerized=true"
|
- "--containerized=true"
|
||||||
- "--metadatastorage=k8s_configmap"
|
- "--metadatastorage=k8s_configmap"
|
||||||
env:
|
env:
|
||||||
@ -64,11 +64,11 @@ spec:
|
|||||||
fieldRef:
|
fieldRef:
|
||||||
fieldPath: metadata.namespace
|
fieldPath: metadata.namespace
|
||||||
- name: CSI_ENDPOINT
|
- 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"
|
imagePullPolicy: "IfNotPresent"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: plugin-dir
|
- name: plugin-dir
|
||||||
mountPath: /var/lib/kubelet/plugins/csi-rbdplugin
|
mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
- name: pods-mount-dir
|
- name: pods-mount-dir
|
||||||
mountPath: /var/lib/kubelet/pods
|
mountPath: /var/lib/kubelet/pods
|
||||||
mountPropagation: "Bidirectional"
|
mountPropagation: "Bidirectional"
|
||||||
@ -84,7 +84,7 @@ spec:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: plugin-dir
|
- name: plugin-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
- name: registration-dir
|
- name: registration-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
@ -96,7 +96,7 @@ spec:
|
|||||||
type: Directory
|
type: Directory
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
- name: host-dev
|
- name: host-dev
|
||||||
hostPath:
|
hostPath:
|
||||||
|
@ -25,7 +25,7 @@ make image-cephfsplugin
|
|||||||
Option | Default value | Description
|
Option | Default value | Description
|
||||||
--------------------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
--------------------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
`--endpoint` | `unix://tmp/csi.sock` | CSI endpoint, must be a UNIX socket
|
`--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
|
`--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.
|
`--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`)
|
`--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
|
Option | Default value | Description
|
||||||
--------------------|-----------------------|---------------------------------------------------------------------------------------------------
|
--------------------|-----------------------|---------------------------------------------------------------------------------------------------
|
||||||
`--endpoint` | `unix://tmp/csi.sock` | CSI endpoint, must be a UNIX socket
|
`--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
|
`--nodeid` | _empty_ | This node's ID
|
||||||
`--containerized` | true | Whether running in containerized mode
|
`--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`)
|
`--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
|
imagePullPolicy: Always
|
||||||
volumes:
|
volumes:
|
||||||
- hostPath:
|
- hostPath:
|
||||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
path: /var/lib/kubelet/plugins/rbd.csi.ceph.com
|
||||||
type: DirectoryOrCreate
|
type: DirectoryOrCreate
|
||||||
name: socket-dir
|
name: socket-dir
|
||||||
|
@ -20,18 +20,21 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi/v0"
|
"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"
|
"github.com/ceph/ceph-csi/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// PluginFolder is the kubelet plugin directory for cephfs plugin
|
|
||||||
PluginFolder = "/var/lib/kubelet/plugins/csi-cephfsplugin"
|
|
||||||
// Version of the cephfs csi driver
|
// Version of the cephfs csi driver
|
||||||
Version = "0.3.0"
|
Version = "0.3.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// PluginFolder is the kubelet plugin directory for cephfs plugin
|
||||||
|
PluginFolder = "/var/lib/kubelet/plugins/"
|
||||||
|
)
|
||||||
|
|
||||||
type cephfsDriver struct {
|
type cephfsDriver struct {
|
||||||
driver *csicommon.CSIDriver
|
driver *csicommon.CSIDriver
|
||||||
|
|
||||||
|
@ -23,12 +23,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
cephRootPrefix = PluginFolder + "/controller/volumes/root-"
|
|
||||||
cephVolumesRoot = "csi-volumes"
|
cephVolumesRoot = "csi-volumes"
|
||||||
|
|
||||||
namespacePrefix = "ns-"
|
namespacePrefix = "ns-"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
cephRootPrefix = PluginFolder + "/controller/volumes/root-"
|
||||||
|
)
|
||||||
|
|
||||||
func getCephRootPathLocal(volId volumeID) string {
|
func getCephRootPathLocal(volId volumeID) string {
|
||||||
return cephRootPrefix + string(volId)
|
return cephRootPrefix + string(volId)
|
||||||
}
|
}
|
||||||
|
@ -21,20 +21,23 @@ import (
|
|||||||
|
|
||||||
"github.com/ceph/ceph-csi/pkg/util"
|
"github.com/ceph/ceph-csi/pkg/util"
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi/v0"
|
"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/mount"
|
||||||
"k8s.io/kubernetes/pkg/util/nsenter"
|
"k8s.io/kubernetes/pkg/util/nsenter"
|
||||||
"k8s.io/utils/exec"
|
"k8s.io/utils/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PluginFolder defines the location of rbdplugin
|
|
||||||
const (
|
const (
|
||||||
PluginFolder = "/var/lib/kubelet/plugins/csi-rbdplugin"
|
|
||||||
rbdDefaultAdminId = "admin"
|
rbdDefaultAdminId = "admin"
|
||||||
rbdDefaultUserId = rbdDefaultAdminId
|
rbdDefaultUserId = rbdDefaultAdminId
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// PluginFolder defines the location of rbdplugin
|
||||||
|
PluginFolder = "/var/lib/kubelet/plugins/"
|
||||||
|
)
|
||||||
|
|
||||||
type rbd struct {
|
type rbd struct {
|
||||||
driver *csicommon.CSIDriver
|
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 (
|
var (
|
||||||
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
|
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")
|
nodeID = flag.String("nodeid", "", "node id")
|
||||||
containerized = flag.Bool("containerized", true, "whether run as containerized")
|
containerized = flag.Bool("containerized", true, "whether run as containerized")
|
||||||
metadataStorage = flag.String("metadatastorage", "node", "metadata persistence method [node|k8s_configmap]")
|
metadataStorage = flag.String("metadatastorage", "node", "metadata persistence method [node|k8s_configmap]")
|
||||||
@ -41,6 +41,14 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
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 {
|
if err := createPersistentStorage(path.Join(rbd.PluginFolder, "controller")); err != nil {
|
||||||
glog.Errorf("failed to create persistent storage for controller %v", err)
|
glog.Errorf("failed to create persistent storage for controller %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user