diff --git a/controllers/ocsinitialization/ocsinitialization_controller.go b/controllers/ocsinitialization/ocsinitialization_controller.go index e7e3a3c6ac..34275c763e 100644 --- a/controllers/ocsinitialization/ocsinitialization_controller.go +++ b/controllers/ocsinitialization/ocsinitialization_controller.go @@ -237,6 +237,7 @@ func (r *OCSInitializationReconciler) ensureOcsOperatorConfigExists(initialData clusterNameKey = "CSI_CLUSTER_NAME" enableReadAffinityKey = "CSI_ENABLE_READ_AFFINITY" cephFSKernelMountOptionsKey = "CSI_CEPHFS_KERNEL_MOUNT_OPTIONS" + enableNFSKey = "ROOK_CSI_ENABLE_NFS" ) ocsOperatorConfig := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ @@ -248,6 +249,7 @@ func (r *OCSInitializationReconciler) ensureOcsOperatorConfigExists(initialData clusterNameKey: "", enableReadAffinityKey: "true", cephFSKernelMountOptionsKey: "ms_mode=prefer-crc", + enableNFSKey: "false", }, } err := r.Client.Create(r.ctx, ocsOperatorConfig) diff --git a/controllers/storagecluster/ocs_operator_config.go b/controllers/storagecluster/ocs_operator_config.go index 51ca3c112c..4046c5ed7a 100644 --- a/controllers/storagecluster/ocs_operator_config.go +++ b/controllers/storagecluster/ocs_operator_config.go @@ -22,11 +22,13 @@ func (r *StorageClusterReconciler) ensureOCSOperatorConfig(sc *ocsv1.StorageClus clusterNameKey = "CSI_CLUSTER_NAME" enableReadAffinityKey = "CSI_ENABLE_READ_AFFINITY" cephFSKernelMountOptionsKey = "CSI_CEPHFS_KERNEL_MOUNT_OPTIONS" + enableNFSKey = "ROOK_CSI_ENABLE_NFS" ) var ( clusterNameVal = r.getClusterID() enableReadAffinityVal = strconv.FormatBool(!sc.Spec.ExternalStorage.Enable) cephFSKernelMountOptionVal = getCephFSKernelMountOptions(sc) + enableNFSVal = getEnableNFSVal(sc) ) cm := &corev1.ConfigMap{ @@ -35,8 +37,10 @@ func (r *StorageClusterReconciler) ensureOCSOperatorConfig(sc *ocsv1.StorageClus Namespace: sc.Namespace, }, Data: map[string]string{ - clusterNameKey: clusterNameVal, - enableReadAffinityKey: enableReadAffinityVal, + clusterNameKey: clusterNameVal, + enableReadAffinityKey: enableReadAffinityVal, + cephFSKernelMountOptionsKey: cephFSKernelMountOptionVal, + enableNFSKey: enableNFSVal, }, } @@ -58,6 +62,9 @@ func (r *StorageClusterReconciler) ensureOCSOperatorConfig(sc *ocsv1.StorageClus if cm.Data[cephFSKernelMountOptionsKey] != cephFSKernelMountOptionVal { cm.Data[cephFSKernelMountOptionsKey] = cephFSKernelMountOptionVal } + if cm.Data[enableNFSKey] != enableNFSVal { + cm.Data[enableNFSKey] = enableNFSVal + } return ctrl.SetControllerReference(sc, cm, r.Scheme) }) if err != nil { @@ -128,3 +135,11 @@ func getCephFSKernelMountOptions(sc *ocsv1.StorageCluster) string { // so we need to set the mount options to prefer-crc return "ms_mode=prefer-crc" } + +// getEnableNFSVal returns the value of enableNFS based on the spec on the StorageCluster +func getEnableNFSVal(sc *ocsv1.StorageCluster) string { + if sc.Spec.NFS != nil && sc.Spec.NFS.Enable { + return "true" + } + return "false" +} diff --git a/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml b/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml index 3aa83a62be..a16dadd3b3 100644 --- a/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml +++ b/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml @@ -3004,6 +3004,11 @@ spec: configMapKeyRef: key: CSI_CEPHFS_KERNEL_MOUNT_OPTIONS name: ocs-operator-config + - name: ROOK_CSI_ENABLE_NFS + valueFrom: + configMapKeyRef: + key: ROOK_CSI_ENABLE_NFS + name: ocs-operator-config - name: CSI_PROVISIONER_TOLERATIONS value: |2- diff --git a/tools/csv-merger/csv-merger.go b/tools/csv-merger/csv-merger.go index 1618d3275b..29cfe896d8 100644 --- a/tools/csv-merger/csv-merger.go +++ b/tools/csv-merger/csv-merger.go @@ -270,6 +270,17 @@ func unmarshalCSV(filePath string) *csvv1.ClusterServiceVersion { }, }, }, + { + Name: "ROOK_CSI_ENABLE_NFS", + ValueFrom: &corev1.EnvVarSource{ + ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "ocs-operator-config", + }, + Key: "ROOK_CSI_ENABLE_NFS", + }, + }, + }, { Name: "CSI_PROVISIONER_TOLERATIONS", Value: `