From 0a5b6923424a2ef7f57280b6419c801bca37cd2e Mon Sep 17 00:00:00 2001 From: CL0Pinette Date: Tue, 5 Aug 2025 11:14:01 +0200 Subject: [PATCH] csi: add CrossNamespaceVolumeDataSource feature gate This enables configuring the CrossNamespaceVolumeDataSource feature gate Signed-off-by: CL0Pinette (cherry picked from commit b63c222d178f9f1b2649a44991f55bd336da18ea) --- Documentation/Helm-Charts/operator-chart.md | 1 + deploy/charts/rook-ceph/templates/clusterrole.yaml | 3 +++ deploy/charts/rook-ceph/templates/configmap.yaml | 3 +++ deploy/charts/rook-ceph/values.yaml | 4 ++++ deploy/examples/common.yaml | 3 +++ deploy/examples/operator-openshift.yaml | 3 +++ deploy/examples/operator.yaml | 3 +++ pkg/operator/ceph/csi/csi.go | 5 +++++ pkg/operator/ceph/csi/spec.go | 1 + .../template/cephfs/csi-cephfsplugin-provisioner-dep.yaml | 1 + .../ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml | 1 + 11 files changed, 28 insertions(+) diff --git a/Documentation/Helm-Charts/operator-chart.md b/Documentation/Helm-Charts/operator-chart.md index 729f65b51..0da6cab10 100644 --- a/Documentation/Helm-Charts/operator-chart.md +++ b/Documentation/Helm-Charts/operator-chart.md @@ -61,6 +61,7 @@ The following table lists the configurable parameters of the rook-operator chart | `csi.cephfsLivenessMetricsPort` | CSI CephFS driver metrics port | `9081` | | `csi.cephfsPodLabels` | Labels to add to the CSI CephFS Deployments and DaemonSets Pods | `nil` | | `csi.clusterName` | Cluster name identifier to set as metadata on the CephFS subvolume and RBD images. This will be useful in cases like for example, when two container orchestrator clusters (Kubernetes/OCP) are using a single ceph cluster | `nil` | +| `csi.crossNamespaceVolumeDataSource.enabled` | Enable cross namespace volume data source provisioning | `false` | | `csi.csiAddons.enabled` | Enable CSIAddons | `false` | | `csi.csiAddons.repository` | CSIAddons sidecar image repository | `"quay.io/csiaddons/k8s-sidecar"` | | `csi.csiAddons.tag` | CSIAddons sidecar image tag | `"v0.12.0"` | diff --git a/deploy/charts/rook-ceph/templates/clusterrole.yaml b/deploy/charts/rook-ceph/templates/clusterrole.yaml index 135430be0..a34389fb5 100644 --- a/deploy/charts/rook-ceph/templates/clusterrole.yaml +++ b/deploy/charts/rook-ceph/templates/clusterrole.yaml @@ -664,6 +664,9 @@ rules: - apiGroups: [""] resources: ["nodes"] verbs: ["get", "list", "watch"] + - apiGroups: ["gateway.networking.k8s.io"] + resources: ["referencegrants"] + verbs: ["get", "list", "watch"] - apiGroups: ["replication.storage.openshift.io"] resources: ["volumegroupreplicationcontents"] verbs: ["get", "list", "watch"] diff --git a/deploy/charts/rook-ceph/templates/configmap.yaml b/deploy/charts/rook-ceph/templates/configmap.yaml index 03e79640f..0b050537b 100644 --- a/deploy/charts/rook-ceph/templates/configmap.yaml +++ b/deploy/charts/rook-ceph/templates/configmap.yaml @@ -130,6 +130,9 @@ data: ROOK_CSIADDONS_IMAGE: "{{ .Values.csi.csiAddons.repository }}:{{ .Values.csi.csiAddons.tag }}" {{- end }} {{- end }} +{{- if .Values.csi.crossNamespaceVolumeDataSource }} + CSI_ENABLE_CROSS_NAMESPACE_VOLUME_DATA_SOURCE: {{ .Values.csi.crossNamespaceVolumeDataSource.enabled | quote }} +{{- end }} {{- if .Values.csi.topology }} CSI_ENABLE_TOPOLOGY: {{ .Values.csi.topology.enabled | quote }} {{- if .Values.csi.topology.domainLabels }} diff --git a/deploy/charts/rook-ceph/values.yaml b/deploy/charts/rook-ceph/values.yaml index ec3460910..20bd868a4 100644 --- a/deploy/charts/rook-ceph/values.yaml +++ b/deploy/charts/rook-ceph/values.yaml @@ -557,6 +557,10 @@ csi: # - topology.kubernetes.io/zone # - topology.rook.io/rack + crossNamespaceVolumeDataSource: + # -- Enable cross namespace volume data source provisioning + enabled: false + # -- Whether to skip any attach operation altogether for CephFS PVCs. See more details # [here](https://kubernetes-csi.github.io/docs/skip-attach.html#skip-attach-with-csi-driver-object). # If cephFSAttachRequired is set to false it skips the volume attachments and makes the creation diff --git a/deploy/examples/common.yaml b/deploy/examples/common.yaml index abf9943e9..2f95563b6 100644 --- a/deploy/examples/common.yaml +++ b/deploy/examples/common.yaml @@ -222,6 +222,9 @@ rules: - apiGroups: [""] resources: ["nodes"] verbs: ["get", "list", "watch"] + - apiGroups: ["gateway.networking.k8s.io"] + resources: ["referencegrants"] + verbs: ["get", "list", "watch"] - apiGroups: ["replication.storage.openshift.io"] resources: ["volumegroupreplicationcontents"] verbs: ["get", "list", "watch"] diff --git a/deploy/examples/operator-openshift.yaml b/deploy/examples/operator-openshift.yaml index b732c763c..231ac1e76 100644 --- a/deploy/examples/operator-openshift.yaml +++ b/deploy/examples/operator-openshift.yaml @@ -572,6 +572,9 @@ data: # updated with node labels that define domains of interest # CSI_TOPOLOGY_DOMAIN_LABELS: "kubernetes.io/hostname,topology.kubernetes.io/zone,topology.rook.io/rack" + # Enable cross namespace volume data source provisioning. + CSI_ENABLE_CROSS_NAMESPACE_VOLUME_DATA_SOURCE: "false" + # Whether to skip any attach operation altogether for CephCSI PVCs. # See more details [here](https://kubernetes-csi.github.io/docs/skip-attach.html#skip-attach-with-csi-driver-object). # If set to false it skips the volume attachments and makes the creation of pods using the CephCSI PVC fast. diff --git a/deploy/examples/operator.yaml b/deploy/examples/operator.yaml index 18e79d2c3..f011b26e9 100644 --- a/deploy/examples/operator.yaml +++ b/deploy/examples/operator.yaml @@ -523,6 +523,9 @@ data: # updated with node labels that define domains of interest # CSI_TOPOLOGY_DOMAIN_LABELS: "kubernetes.io/hostname,topology.kubernetes.io/zone,topology.rook.io/rack" + # Enable cross namespace volume data source provisioning. + CSI_ENABLE_CROSS_NAMESPACE_VOLUME_DATA_SOURCE: "false" + # Whether to skip any attach operation altogether for CephCSI PVCs. # See more details [here](https://kubernetes-csi.github.io/docs/skip-attach.html#skip-attach-with-csi-driver-object). # If set to false it skips the volume attachments and makes the creation of pods using the CephCSI PVC fast. diff --git a/pkg/operator/ceph/csi/csi.go b/pkg/operator/ceph/csi/csi.go index 49752f3a9..9e91f89f0 100644 --- a/pkg/operator/ceph/csi/csi.go +++ b/pkg/operator/ceph/csi/csi.go @@ -162,6 +162,11 @@ func (r *ReconcileCSI) setParams() error { CSIParam.EnableCSIAddonsSideCar = true } + CSIParam.EnableCrossNamespaceVolumeDataSource = false + if strings.EqualFold(k8sutil.GetOperatorSetting("CSI_ENABLE_CROSS_NAMESPACE_VOLUME_DATA_SOURCE", "false"), "true") { + CSIParam.EnableCrossNamespaceVolumeDataSource = true + } + CSIParam.EnableCSITopology = false if strings.EqualFold(k8sutil.GetOperatorSetting("CSI_ENABLE_TOPOLOGY", "false"), "true") { CSIParam.EnableCSITopology = true diff --git a/pkg/operator/ceph/csi/spec.go b/pkg/operator/ceph/csi/spec.go index 967307e3c..8076f39dd 100644 --- a/pkg/operator/ceph/csi/spec.go +++ b/pkg/operator/ceph/csi/spec.go @@ -72,6 +72,7 @@ type Param struct { MountCustomCephConf bool EnableCSIEncryption bool EnableCSITopology bool + EnableCrossNamespaceVolumeDataSource bool EnableLiveness bool CephFSAttachRequired bool RBDAttachRequired bool diff --git a/pkg/operator/ceph/csi/template/cephfs/csi-cephfsplugin-provisioner-dep.yaml b/pkg/operator/ceph/csi/template/cephfs/csi-cephfsplugin-provisioner-dep.yaml index ff9554ad7..ebcb060f7 100644 --- a/pkg/operator/ceph/csi/template/cephfs/csi-cephfsplugin-provisioner-dep.yaml +++ b/pkg/operator/ceph/csi/template/cephfs/csi-cephfsplugin-provisioner-dep.yaml @@ -120,6 +120,7 @@ spec: - "--leader-election-renew-deadline={{ .LeaderElectionRenewDeadline }}" - "--leader-election-retry-period={{ .LeaderElectionRetryPeriod }}" - "--extra-create-metadata=true" + - "--feature-gates=CrossNamespaceVolumeDataSource={{ .EnableCrossNamespaceVolumeDataSource }}" {{ if .KubeApiBurst }} - "--kube-api-burst={{ .KubeApiBurst }}" {{ end }} diff --git a/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml b/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml index bacd76682..ded285066 100644 --- a/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml +++ b/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml @@ -39,6 +39,7 @@ spec: - "--extra-create-metadata=true" - "--prevent-volume-mode-conversion=true" - "--feature-gates=HonorPVReclaimPolicy=true" + - "--feature-gates=CrossNamespaceVolumeDataSource={{ .EnableCrossNamespaceVolumeDataSource }}" - "--feature-gates=Topology={{ .EnableCSITopology }}" {{ if .KubeApiBurst }} - "--kube-api-burst={{ .KubeApiBurst }}"