Skip to content

Commit

Permalink
deploy: add csidriver object for cephfs and rbd
Browse files Browse the repository at this point in the history
csidriver object can be created on the kubernetes
for below reason.

If a CSI driver creates a CSIDriver object,
Kubernetes users can easily discover the CSI
Drivers installed on their cluster
(simply by issuing kubectl get CSIDriver)

Ref: https://kubernetes-csi.github.io/docs/csi-driver-object.html#what-is-the-csidriver-object

attachRequired is always required to be set to
true to avoid issue on RWO PVC.

more details about it at rook/rook#4332

Signed-off-by: Madhu Rajanna <[email protected]>
  • Loading branch information
Madhu-1 authored and mergify[bot] committed Mar 31, 2021
1 parent d80b8d7 commit fba6a2d
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 10 deletions.
11 changes: 6 additions & 5 deletions charts/ceph-csi-cephfs/templates/csidriver-crd.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{{- if not .Values.provisioner.attacher.enabled -}}
apiVersion: storage.k8s.io/v1beta1
{{ if semverCompare ">=1.18" .Capabilities.KubeVersion.GitVersion }}
apiVersion: storage.k8s.io/v1
{{ else }}
apiVersion: storage.k8s.io/v1betav1
{{ end }}
kind: CSIDriver
metadata:
name: {{ .Values.driverName }}
namespace: {{ .Release.Namespace }}
spec:
attachRequired: false
attachRequired: true
podInfoOnMount: false
{{- end -}}
11 changes: 6 additions & 5 deletions charts/ceph-csi-rbd/templates/csidriver-crd.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{{- if not .Values.provisioner.attacher.enabled -}}
apiVersion: storage.k8s.io/v1beta1
{{ if semverCompare ">=1.18" .Capabilities.KubeVersion.GitVersion }}
apiVersion: storage.k8s.io/v1
{{ else }}
apiVersion: storage.k8s.io/betav1
{{ end }}
kind: CSIDriver
metadata:
name: {{ .Values.driverName }}
namespace: {{ .Release.Namespace }}
spec:
attachRequired: false
attachRequired: true
podInfoOnMount: false
{{- end -}}
10 changes: 10 additions & 0 deletions deploy/cephfs/kubernetes/csidriver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# if Kubernetes version is less than 1.18 change
# apiVersion to storage.k8s.io/v1betav1
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: cephfs.csi.ceph.com
spec:
attachRequired: true
podInfoOnMount: false
10 changes: 10 additions & 0 deletions deploy/rbd/kubernetes/csidriver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# if Kubernetes version is less than 1.18 change
# apiVersion to storage.k8s.io/v1betav1
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: rbd.csi.ceph.com
spec:
attachRequired: true
podInfoOnMount: false
15 changes: 15 additions & 0 deletions e2e/cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package e2e
import (
"context"
"fmt"
"io/ioutil"
"os"
"strings"
"sync"

Expand Down Expand Up @@ -61,6 +63,19 @@ func deleteCephfsPlugin() {
}

func createORDeleteCephfsResouces(action string) {
csiDriver, err := ioutil.ReadFile(cephfsDirPath + csiDriverObject)
if err != nil {
// createORDeleteRbdResouces is used for upgrade testing as csidriverObject is
// newly added, discarding file not found error.
if !os.IsNotExist(err) {
e2elog.Failf("failed to read content from %s with error %v", cephfsDirPath+csiDriverObject, err)
}
} else {
_, err = framework.RunKubectlInput(cephCSINamespace, string(csiDriver), action, "-f", "-")
if err != nil {
e2elog.Failf("failed to %s CSIDriver object with error %v", action, err)
}
}
data, err := replaceNamespaceInTemplate(cephfsDirPath + cephfsProvisioner)
if err != nil {
e2elog.Failf("failed to read content from %s with error %v", cephfsDirPath+cephfsProvisioner, err)
Expand Down
16 changes: 16 additions & 0 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package e2e
import (
"context"
"fmt"
"io/ioutil"
"os"
"strings"
"sync"

Expand All @@ -23,6 +25,7 @@ var (
rbdNodePluginRBAC = "csi-nodeplugin-rbac.yaml"
rbdNodePluginPSP = "csi-nodeplugin-psp.yaml"
configMap = "csi-config-map.yaml"
csiDriverObject = "csidriver.yaml"
rbdDirPath = "../deploy/rbd/kubernetes/"
rbdExamplePath = "../examples/rbd/"
rbdDeploymentName = "csi-rbdplugin-provisioner"
Expand Down Expand Up @@ -67,6 +70,19 @@ func deleteRBDPlugin() {
}

func createORDeleteRbdResouces(action string) {
csiDriver, err := ioutil.ReadFile(rbdDirPath + csiDriverObject)
if err != nil {
// createORDeleteRbdResouces is used for upgrade testing as csidriverObject is
// newly added, discarding file not found error.
if !os.IsNotExist(err) {
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+csiDriverObject, err)
}
} else {
_, err = framework.RunKubectlInput(cephCSINamespace, string(csiDriver), action, "-f", "-")
if err != nil {
e2elog.Failf("failed to %s CSIDriver object with error %v", action, err)
}
}
data, err := replaceNamespaceInTemplate(rbdDirPath + rbdProvisioner)
if err != nil {
e2elog.Failf("failed to read content from %s with error %v", rbdDirPath+rbdProvisioner, err)
Expand Down

0 comments on commit fba6a2d

Please sign in to comment.