diff --git a/cmd/cephfs/main.go b/cmd/cephfs/main.go index 8ee9141e6..fc5c0dbcc 100644 --- a/cmd/cephfs/main.go +++ b/cmd/cephfs/main.go @@ -27,7 +27,7 @@ import ( 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", "", "metadata persistence method [node|k8s_configmap]") @@ -43,6 +43,13 @@ func init() { func main() { + err := util.ValidateDriverName(*driverName) + if err != nil { + klog.Fatalln(err) + } + //update plugin name + cephfs.PluginFolder = cephfs.PluginFolder + *driverName + cp, err := util.CreatePersistanceStorage(cephfs.PluginFolder, *metadataStorage, *driverName) if err != nil { os.Exit(1) diff --git a/cmd/rbd/main.go b/cmd/rbd/main.go index 6f61c637f..35cf08390 100644 --- a/cmd/rbd/main.go +++ b/cmd/rbd/main.go @@ -27,7 +27,7 @@ import ( 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", "", "metadata persistence method [node|k8s_configmap]") @@ -43,6 +43,13 @@ func init() { func main() { + err := util.ValidateDriverName(*driverName) + if err != nil { + klog.Fatalln(err) + } + //update plugin name + rbd.PluginFolder = rbd.PluginFolder + *driverName + cp, err := util.CreatePersistanceStorage(rbd.PluginFolder, *metadataStorage, *driverName) if err != nil { os.Exit(1) diff --git a/deploy/cephfs/helm/README.md b/deploy/cephfs/helm/README.md index 0e4a1f223..fcd4a98a8 100644 --- a/deploy/cephfs/helm/README.md +++ b/deploy/cephfs/helm/README.md @@ -21,3 +21,9 @@ If you want to delete your Chart, use this command ```bash helm delete --purge "ceph-csi-cephfs" ``` + +If you want to delete the namespace, use this command + +```bash +kubectl delete namespace ceph-csi-rbd +``` diff --git a/deploy/cephfs/helm/templates/nodeplugin-daemonset.yaml b/deploy/cephfs/helm/templates/nodeplugin-daemonset.yaml index 20ac11933..9181d6102 100644 --- a/deploy/cephfs/helm/templates/nodeplugin-daemonset.yaml +++ b/deploy/cephfs/helm/templates/nodeplugin-daemonset.yaml @@ -39,7 +39,11 @@ spec: lifecycle: preStop: exec: - command: ["/bin/sh", "-c", "rm -rf /registration/csi-cephfsplugin /registration/csi-cephfsplugin-reg.sock"] + command: [ + "/bin/sh", "-c", + 'rm -rf /registration/{{ .Values.driverName }} + /registration/{{ .Values.driverName }}-reg.sock' + ] env: - name: KUBE_NODE_NAME valueFrom: @@ -64,11 +68,13 @@ spec: - "--nodeid=$(NODE_ID)" - "--endpoint=$(CSI_ENDPOINT)" - "--v=5" - - "--drivername=csi-cephfsplugin" + - "--drivername=$(DRIVER_NAME)" - "--metadatastorage=k8s_configmap" env: - name: HOST_ROOTFS value: "/rootfs" + - name: DRIVER_NAME + value: {{ .Values.driverName }} - name: NODE_ID valueFrom: fieldRef: diff --git a/deploy/cephfs/helm/templates/provisioner-statefulset.yaml b/deploy/cephfs/helm/templates/provisioner-statefulset.yaml index 2f5c48c8a..fe4fc6428 100644 --- a/deploy/cephfs/helm/templates/provisioner-statefulset.yaml +++ b/deploy/cephfs/helm/templates/provisioner-statefulset.yaml @@ -52,11 +52,13 @@ spec: - "--nodeid=$(NODE_ID)" - "--endpoint=$(CSI_ENDPOINT)" - "--v=5" - - "--drivername=csi-cephfsplugin" + - "--drivername=$(DRIVER_NAME)" - "--metadatastorage=k8s_configmap" env: - name: HOST_ROOTFS value: "/rootfs" + - name: DRIVER_NAME + value: {{ .Values.driverName }} - name: NODE_ID valueFrom: fieldRef: diff --git a/deploy/cephfs/helm/values.yaml b/deploy/cephfs/helm/values.yaml index f662c8849..b31c9733e 100644 --- a/deploy/cephfs/helm/values.yaml +++ b/deploy/cephfs/helm/values.yaml @@ -13,11 +13,11 @@ serviceAccounts: create: true name: -socketDir: /var/lib/kubelet/plugins/csi-cephfsplugin +socketDir: /var/lib/kubelet/plugins/cephfs.csi.ceph.com socketFile: csi.sock registrationDir: /var/lib/kubelet/plugins_registry volumeDevicesDir: /var/lib/kubelet/plugins/kubernetes.io/csi/volumeDevices - +driverName: cephfs.csi.ceph.com attacher: name: attacher diff --git a/deploy/cephfs/kubernetes/csi-cephfsplugin-attacher.yaml b/deploy/cephfs/kubernetes/csi-cephfsplugin-attacher.yaml index 06f27ca80..1cd97126b 100644 --- a/deploy/cephfs/kubernetes/csi-cephfsplugin-attacher.yaml +++ b/deploy/cephfs/kubernetes/csi-cephfsplugin-attacher.yaml @@ -34,13 +34,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 diff --git a/deploy/cephfs/kubernetes/csi-cephfsplugin-provisioner.yaml b/deploy/cephfs/kubernetes/csi-cephfsplugin-provisioner.yaml index b3c2ffc0d..8d515aacc 100644 --- a/deploy/cephfs/kubernetes/csi-cephfsplugin-provisioner.yaml +++ b/deploy/cephfs/kubernetes/csi-cephfsplugin-provisioner.yaml @@ -34,11 +34,11 @@ spec: - "--v=5" env: - name: ADDRESS - value: /var/lib/kubelet/plugins/csi-cephfsplugin/csi-provisioner.sock + value: /var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi-provisioner.sock imagePullPolicy: "IfNotPresent" volumeMounts: - name: socket-dir - mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin + mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com - name: csi-cephfsplugin securityContext: privileged: true @@ -49,7 +49,7 @@ spec: - "--nodeid=$(NODE_ID)" - "--endpoint=$(CSI_ENDPOINT)" - "--v=5" - - "--drivername=csi-cephfsplugin" + - "--drivername=cephfs.csi.ceph.com" - "--metadatastorage=k8s_configmap" env: - name: NODE_ID @@ -61,11 +61,11 @@ spec: fieldRef: fieldPath: metadata.namespace - name: CSI_ENDPOINT - value: unix://var/lib/kubelet/plugins/csi-cephfsplugin/csi-provisioner.sock + value: unix://var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi-provisioner.sock imagePullPolicy: "IfNotPresent" volumeMounts: - name: socket-dir - mountPath: /var/lib/kubelet/plugins/csi-cephfsplugin + mountPath: /var/lib/kubelet/plugins/cephfs.csi.ceph.com - name: host-sys mountPath: /sys - name: lib-modules @@ -76,7 +76,7 @@ spec: volumes: - 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: diff --git a/deploy/cephfs/kubernetes/csi-cephfsplugin.yaml b/deploy/cephfs/kubernetes/csi-cephfsplugin.yaml index 9e482c75a..0452efa3d 100644 --- a/deploy/cephfs/kubernetes/csi-cephfsplugin.yaml +++ b/deploy/cephfs/kubernetes/csi-cephfsplugin.yaml @@ -23,7 +23,7 @@ spec: args: - "--v=5" - "--csi-address=/csi/csi.sock" - - "--kubelet-registration-path=/var/lib/kubelet/plugins/csi-cephfsplugin/csi.sock" + - "--kubelet-registration-path=/var/lib/kubelet/plugins/cephfs.csi.ceph.com/csi.sock" lifecycle: preStop: exec: @@ -53,7 +53,7 @@ spec: - "--nodeid=$(NODE_ID)" - "--endpoint=$(CSI_ENDPOINT)" - "--v=5" - - "--drivername=csi-cephfsplugin" + - "--drivername=cephfs.csi.ceph.com" - "--metadatastorage=k8s_configmap" env: - name: NODE_ID @@ -65,11 +65,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: csi-plugins-dir mountPath: /var/lib/kubelet/plugins/kubernetes.io/csi mountPropagation: "Bidirectional" @@ -86,7 +86,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: csi-plugins-dir hostPath: diff --git a/deploy/rbd/helm/README.md b/deploy/rbd/helm/README.md index 35ce742a0..250c10add 100644 --- a/deploy/rbd/helm/README.md +++ b/deploy/rbd/helm/README.md @@ -21,3 +21,9 @@ If you want to delete your Chart, use this command ```bash helm delete --purge "ceph-csi-rbd" ``` + +If you want to delete the namespace, use this command + +```bash +kubectl delete namespace ceph-csi-rbd +``` diff --git a/deploy/rbd/helm/templates/nodeplugin-daemonset.yaml b/deploy/rbd/helm/templates/nodeplugin-daemonset.yaml index 31ffa1db5..355983b49 100644 --- a/deploy/rbd/helm/templates/nodeplugin-daemonset.yaml +++ b/deploy/rbd/helm/templates/nodeplugin-daemonset.yaml @@ -39,7 +39,11 @@ spec: lifecycle: preStop: exec: - command: ["/bin/sh", "-c", "rm -rf /registration/csi-rbdplugin /registration/csi-rbdplugin-reg.sock"] + command: [ + "/bin/sh", "-c", + 'rm -rf /registration/{{ .Values.driverName }} + /registration/{{ .Values.driverName }}-reg.sock' + ] env: - name: KUBE_NODE_NAME valueFrom: @@ -64,12 +68,14 @@ spec: - "--nodeid=$(NODE_ID)" - "--endpoint=$(CSI_ENDPOINT)" - "--v=5" - - "--drivername=csi-rbdplugin" + - "--drivername=$(DRIVER_NAME)" - "--containerized=true" - "--metadatastorage=k8s_configmap" env: - name: HOST_ROOTFS value: "/rootfs" + - name: DRIVER_NAME + value: {{ .Values.driverName }} - name: NODE_ID valueFrom: fieldRef: diff --git a/deploy/rbd/helm/templates/provisioner-statefulset.yaml b/deploy/rbd/helm/templates/provisioner-statefulset.yaml index 2a455ee50..269cb0a44 100644 --- a/deploy/rbd/helm/templates/provisioner-statefulset.yaml +++ b/deploy/rbd/helm/templates/provisioner-statefulset.yaml @@ -69,12 +69,14 @@ spec: - "--nodeid=$(NODE_ID)" - "--endpoint=$(CSI_ENDPOINT)" - "--v=5" - - "--drivername=csi-rbdplugin" + - "--drivername=$(DRIVER_NAME)" - "--containerized=true" - "--metadatastorage=k8s_configmap" env: - name: HOST_ROOTFS value: "/rootfs" + - name: DRIVER_NAME + value: {{ .Values.driverName }} - name: NODE_ID valueFrom: fieldRef: diff --git a/deploy/rbd/helm/values.yaml b/deploy/rbd/helm/values.yaml index bf4c2fb5b..fdeb5d6d5 100644 --- a/deploy/rbd/helm/values.yaml +++ b/deploy/rbd/helm/values.yaml @@ -13,10 +13,11 @@ serviceAccounts: create: true name: -socketDir: /var/lib/kubelet/plugins/csi-rbdplugin +socketDir: /var/lib/kubelet/plugins/rbd.csi.ceph.com socketFile: csi.sock registrationDir: /var/lib/kubelet/plugins_registry volumeDevicesDir: /var/lib/kubelet/plugins/kubernetes.io/csi/volumeDevices +driverName: rbd.csi.ceph.com attacher: name: attacher diff --git a/deploy/rbd/kubernetes/csi-rbdplugin-attacher.yaml b/deploy/rbd/kubernetes/csi-rbdplugin-attacher.yaml index 4b7c15e83..a328f105f 100644 --- a/deploy/rbd/kubernetes/csi-rbdplugin-attacher.yaml +++ b/deploy/rbd/kubernetes/csi-rbdplugin-attacher.yaml @@ -34,13 +34,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 diff --git a/deploy/rbd/kubernetes/csi-rbdplugin-provisioner.yaml b/deploy/rbd/kubernetes/csi-rbdplugin-provisioner.yaml index cc647b7b9..61ab47495 100644 --- a/deploy/rbd/kubernetes/csi-rbdplugin-provisioner.yaml +++ b/deploy/rbd/kubernetes/csi-rbdplugin-provisioner.yaml @@ -34,11 +34,11 @@ spec: - "--v=5" env: - name: ADDRESS - value: /var/lib/kubelet/plugins/csi-rbdplugin/csi-provisioner.sock + value: /var/lib/kubelet/plugins/rbd.csi.ceph.com/csi-provisioner.sock imagePullPolicy: "IfNotPresent" volumeMounts: - name: socket-dir - mountPath: /var/lib/kubelet/plugins/csi-rbdplugin + mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com - name: csi-snapshotter image: quay.io/k8scsi/csi-snapshotter:v1.0.1 args: @@ -47,13 +47,13 @@ spec: - "--v=5" env: - name: ADDRESS - value: /var/lib/kubelet/plugins/csi-rbdplugin/csi-provisioner.sock + value: /var/lib/kubelet/plugins/rbd.csi.ceph.com/csi-provisioner.sock imagePullPolicy: Always securityContext: privileged: true volumeMounts: - name: socket-dir - mountPath: /var/lib/kubelet/plugins/csi-rbdplugin + mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com - name: csi-rbdplugin securityContext: privileged: true @@ -64,7 +64,7 @@ spec: - "--nodeid=$(NODE_ID)" - "--endpoint=$(CSI_ENDPOINT)" - "--v=5" - - "--drivername=csi-rbdplugin" + - "--drivername=rbd.csi.ceph.com" - "--containerized=true" - "--metadatastorage=k8s_configmap" env: @@ -79,11 +79,11 @@ spec: fieldRef: fieldPath: metadata.namespace - name: CSI_ENDPOINT - value: unix://var/lib/kubelet/plugins/csi-rbdplugin/csi-provisioner.sock + value: unix://var/lib/kubelet/plugins/rbd.csi.ceph.com/csi-provisioner.sock imagePullPolicy: "IfNotPresent" volumeMounts: - name: socket-dir - mountPath: /var/lib/kubelet/plugins/csi-rbdplugin + mountPath: /var/lib/kubelet/plugins/rbd.csi.ceph.com - mountPath: /dev name: host-dev - mountPath: /rootfs @@ -108,5 +108,5 @@ spec: path: /lib/modules - name: socket-dir hostPath: - path: /var/lib/kubelet/plugins/csi-rbdplugin + path: /var/lib/kubelet/plugins/rbd.csi.ceph.com type: DirectoryOrCreate diff --git a/deploy/rbd/kubernetes/csi-rbdplugin.yaml b/deploy/rbd/kubernetes/csi-rbdplugin.yaml index 86291dc7e..dbe7539bc 100644 --- a/deploy/rbd/kubernetes/csi-rbdplugin.yaml +++ b/deploy/rbd/kubernetes/csi-rbdplugin.yaml @@ -24,14 +24,14 @@ spec: args: - "--v=5" - "--csi-address=/csi/csi.sock" - - "--kubelet-registration-path=/var/lib/kubelet/plugins/csi-rbdplugin/csi.sock" + - "--kubelet-registration-path=/var/lib/kubelet/plugins/rbd.csi.ceph.com/csi.sock" lifecycle: preStop: exec: command: [ "/bin/sh", "-c", - "rm -rf /registration/csi-rbdplugin \ - /registration/csi-rbdplugin-reg.sock" + "rm -rf /registration/rbd.csi.ceph.com \ + /registration/rbd.csi.ceph.com-reg.sock" ] env: - name: KUBE_NODE_NAME @@ -54,7 +54,7 @@ spec: - "--nodeid=$(NODE_ID)" - "--endpoint=$(CSI_ENDPOINT)" - "--v=5" - - "--drivername=csi-rbdplugin" + - "--drivername=rbd.csi.ceph.com" - "--containerized=true" - "--metadatastorage=k8s_configmap" env: @@ -69,11 +69,11 @@ spec: fieldRef: fieldPath: metadata.namespace - name: CSI_ENDPOINT - value: unix://var/lib/kubelet/plugins_registry/csi-rbdplugin/csi.sock + value: unix://var/lib/kubelet/plugins_registry/rbd.csi.ceph.com/csi.sock imagePullPolicy: "IfNotPresent" volumeMounts: - name: plugin-dir - mountPath: /var/lib/kubelet/plugins_registry/csi-rbdplugin + mountPath: /var/lib/kubelet/plugins_registry/rbd.csi.ceph.com - name: pods-mount-dir mountPath: /var/lib/kubelet/pods mountPropagation: "Bidirectional" @@ -92,7 +92,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: plugin-mount-dir hostPath: diff --git a/docs/deploy-cephfs.md b/docs/deploy-cephfs.md index 659407d31..a88293a14 100644 --- a/docs/deploy-cephfs.md +++ b/docs/deploy-cephfs.md @@ -30,7 +30,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`) diff --git a/docs/deploy-rbd.md b/docs/deploy-rbd.md index bfaa46bb9..a2f40a439 100644 --- a/docs/deploy-rbd.md +++ b/docs/deploy-rbd.md @@ -29,7 +29,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`) diff --git a/examples/README.md b/examples/README.md index d27f9777a..956f666b9 100644 --- a/examples/README.md +++ b/examples/README.md @@ -108,7 +108,7 @@ one of your Ceph pod. To restore the snapshot to a new PVC, deploy [pvc-restore.yaml](./rbd/pvc-restore.yaml) and a testing pod -[pod-restore.yaml](./rbd/pvc-restore.yaml): +[pod-restore.yaml](./rbd/pod-restore.yaml): ```bash kubectl create -f pvc-restore.yaml diff --git a/examples/cephfs/storageclass.yaml b/examples/cephfs/storageclass.yaml index fb8dd0aa9..771c33998 100644 --- a/examples/cephfs/storageclass.yaml +++ b/examples/cephfs/storageclass.yaml @@ -3,7 +3,7 @@ apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: csi-cephfs -provisioner: csi-cephfsplugin +provisioner: cephfs.csi.ceph.com parameters: # Comma separated list of Ceph monitors # if using FQDN, make sure csi plugin's dns policy is appropriate. diff --git a/examples/rbd/snapshotclass.yaml b/examples/rbd/snapshotclass.yaml index 778f2b084..5e3b332f4 100644 --- a/examples/rbd/snapshotclass.yaml +++ b/examples/rbd/snapshotclass.yaml @@ -3,7 +3,7 @@ apiVersion: snapshot.storage.k8s.io/v1alpha1 kind: VolumeSnapshotClass metadata: name: csi-rbdplugin-snapclass -snapshotter: csi-rbdplugin +snapshotter: rbd.csi.ceph.com parameters: pool: rbd monitors: mon1:port,mon2:port,... diff --git a/examples/rbd/storageclass.yaml b/examples/rbd/storageclass.yaml index 320a489a8..75e95f3af 100644 --- a/examples/rbd/storageclass.yaml +++ b/examples/rbd/storageclass.yaml @@ -3,7 +3,7 @@ apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: csi-rbd -provisioner: csi-rbdplugin +provisioner: rbd.csi.ceph.com parameters: # Comma separated list of Ceph monitors # if using FQDN, make sure csi plugin's dns policy is appropriate. diff --git a/pkg/cephfs/driver.go b/pkg/cephfs/driver.go index 43a25b740..b2272e853 100644 --- a/pkg/cephfs/driver.go +++ b/pkg/cephfs/driver.go @@ -19,19 +19,21 @@ package cephfs import ( "k8s.io/klog" - "github.com/ceph/ceph-csi/pkg/csi-common" + csicommon "github.com/ceph/ceph-csi/pkg/csi-common" "github.com/ceph/ceph-csi/pkg/util" "github.com/container-storage-interface/spec/lib/go/csi" ) const ( - // PluginFolder defines the location of ceph plugin - PluginFolder = "/var/lib/kubelet/plugins/csi-cephfsplugin" + // version of ceph driver version = "1.0.0" ) +// PluginFolder defines the location of ceph plugin +var PluginFolder = "/var/lib/kubelet/plugins/" + // Driver contains the default identity,node and controller struct type Driver struct { cd *csicommon.CSIDriver diff --git a/pkg/cephfs/identityserver.go b/pkg/cephfs/identityserver.go index cf343ca89..c8d5edc52 100644 --- a/pkg/cephfs/identityserver.go +++ b/pkg/cephfs/identityserver.go @@ -19,7 +19,7 @@ package cephfs import ( "context" - "github.com/ceph/ceph-csi/pkg/csi-common" + csicommon "github.com/ceph/ceph-csi/pkg/csi-common" "github.com/container-storage-interface/spec/lib/go/csi" ) diff --git a/pkg/cephfs/volume.go b/pkg/cephfs/volume.go index caf9887dc..c8a77f335 100644 --- a/pkg/cephfs/volume.go +++ b/pkg/cephfs/volume.go @@ -25,12 +25,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) } diff --git a/pkg/rbd/controllerserver.go b/pkg/rbd/controllerserver.go index 49af63206..27c407fdf 100644 --- a/pkg/rbd/controllerserver.go +++ b/pkg/rbd/controllerserver.go @@ -96,8 +96,8 @@ func parseVolCreateRequest(req *csi.CreateVolumeRequest) (*rbdVolume, error) { isMultiNode := false isBlock := false for _, cap := range req.VolumeCapabilities { - // Only checking SINGLE_NODE_SINGLE_WRITER here because regardless of the other types (MULTI READER) we need to implement the same logic to ignore the in-use response - if cap.GetAccessMode().GetMode() != csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER { + // RO modes need to be handled indepedently (ie right now even if access mode is RO, they'll be RW upon attach) + if cap.GetAccessMode().GetMode() == csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER { isMultiNode = true } if cap.GetBlock() != nil { diff --git a/pkg/rbd/identityserver.go b/pkg/rbd/identityserver.go index 155586b31..891759f7c 100644 --- a/pkg/rbd/identityserver.go +++ b/pkg/rbd/identityserver.go @@ -19,7 +19,7 @@ package rbd import ( "context" - "github.com/ceph/ceph-csi/pkg/csi-common" + csicommon "github.com/ceph/ceph-csi/pkg/csi-common" "github.com/container-storage-interface/spec/lib/go/csi" ) diff --git a/pkg/rbd/nodeserver.go b/pkg/rbd/nodeserver.go index 3a88b456e..f31ec4cc5 100644 --- a/pkg/rbd/nodeserver.go +++ b/pkg/rbd/nodeserver.go @@ -78,8 +78,7 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis disableInUseChecks = true } else { klog.Warningf("MULTI_NODE_MULTI_WRITER currently only supported with volumes of access type `block`, invalid AccessMode for volume: %v", req.GetVolumeId()) - e := fmt.Errorf("rbd: MULTI_NODE_MULTI_WRITER access mode only allowed with BLOCK access type") - return nil, status.Error(codes.InvalidArgument, e.Error()) + return nil, status.Error(codes.InvalidArgument, "rbd: RWX access mode request is only valid for volumes with access type `block`") } } diff --git a/pkg/rbd/rbd.go b/pkg/rbd/rbd.go index 3fab59e01..3962a99f4 100644 --- a/pkg/rbd/rbd.go +++ b/pkg/rbd/rbd.go @@ -17,7 +17,7 @@ limitations under the License. package rbd import ( - "github.com/ceph/ceph-csi/pkg/csi-common" + csicommon "github.com/ceph/ceph-csi/pkg/csi-common" "github.com/ceph/ceph-csi/pkg/util" "github.com/container-storage-interface/spec/lib/go/csi" @@ -29,11 +29,13 @@ import ( // PluginFolder defines the location of rbdplugin const ( - PluginFolder = "/var/lib/kubelet/plugins/csi-rbdplugin" rbdDefaultAdminID = "admin" rbdDefaultUserID = rbdDefaultAdminID ) +// PluginFolder defines the location of ceph plugin +var PluginFolder = "/var/lib/kubelet/plugins/" + // Driver contains the default identity,node and controller struct type Driver struct { cd *csicommon.CSIDriver diff --git a/pkg/util/k8scmcache.go b/pkg/util/k8scmcache.go index 10a6d7ef5..5982602e2 100644 --- a/pkg/util/k8scmcache.go +++ b/pkg/util/k8scmcache.go @@ -25,7 +25,7 @@ import ( "github.com/pkg/errors" "k8s.io/klog" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8s "k8s.io/client-go/kubernetes" diff --git a/pkg/util/util.go b/pkg/util/util.go index ef8f37d50..6c298bc99 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -19,7 +19,10 @@ package util import ( "os" "path" + "strings" + "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/util/validation" "k8s.io/klog" ) @@ -68,3 +71,23 @@ func CreatePersistanceStorage(sPath, metaDataStore, driverName string) (CachePer func createPersistentStorage(persistentStoragePath string) error { return os.MkdirAll(persistentStoragePath, os.FileMode(0755)) } + +// 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 +}