diff --git a/ocs_ci/deployment/helpers/external_cluster_helpers.py b/ocs_ci/deployment/helpers/external_cluster_helpers.py index ab590486c82..7b54f958dc0 100644 --- a/ocs_ci/deployment/helpers/external_cluster_helpers.py +++ b/ocs_ci/deployment/helpers/external_cluster_helpers.py @@ -137,10 +137,16 @@ def get_external_cluster_details(self): params = f"{params} --run-as-user {ceph_user}" if config.EXTERNAL_MODE.get("use_rbd_namespace"): - rbd_namespace = config.EXTERNAL_MODE.get( - "rbd_namespace" - ) or self.create_rbd_namespace(rbd=rbd_name) + rbd_namespace = config.EXTERNAL_MODE.get("rbd_namespace") + if not rbd_namespace: + rbd_namespace = self.create_rbd_namespace(rbd=rbd_name) + config.EXTERNAL_MODE["rbd_namespace"] = rbd_namespace + params = f"{params} --rados-namespace {rbd_namespace}" + if "restricted-auth-permission" not in params: + params += " --restricted-auth-permission true" + if "cluster-name" not in params: + params += f" --k8s-cluster-name {cluster_name}" out = self.run_exporter_script(params=params) diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index 88ba5d2d761..89325ec8fed 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -685,6 +685,7 @@ def default_storage_class( OCS: Existing StorageClass Instance """ external = config.DEPLOYMENT["external_mode"] + rbd_namespace = config.EXTERNAL_MODE.get("rbd_namespace") custom_storage_class = config.ENV_DATA.get("custom_default_storageclass_names") if custom_storage_class: from ocs_ci.ocs.resources.storage_cluster import ( @@ -702,7 +703,9 @@ def default_storage_class( f"StorageCluster spec doesn't have the custom name for '{constants.CEPHBLOCKPOOL}' storageclass" ) else: - if external: + if rbd_namespace: + resource_name = f"{constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD_NAMESPACE_PREFIX}-{rbd_namespace}" + elif external: resource_name = constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD elif config.ENV_DATA["platform"].lower() in constants.HCI_PC_OR_MS_PLATFORM: storage_class = OCP(kind="storageclass") diff --git a/ocs_ci/ocs/constants.py b/ocs_ci/ocs/constants.py index 57586b40f65..046c18603f1 100644 --- a/ocs_ci/ocs/constants.py +++ b/ocs_ci/ocs/constants.py @@ -481,6 +481,9 @@ DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD_THICK = ( f"{DEFAULT_CLUSTERNAME_EXTERNAL_MODE}-ceph-rbd-thick" ) +DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD_NAMESPACE_PREFIX = ( + f"{DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD}-rados-namespace" +) # Default StorageClass for Provider-mode DEFAULT_STORAGECLASS_CLIENT_CEPHFS = f"{DEFAULT_CLUSTERNAME_CLIENT}-cephfs" diff --git a/ocs_ci/ocs/resources/storage_cluster.py b/ocs_ci/ocs/resources/storage_cluster.py index 99f8845beac..e9f642b5b85 100644 --- a/ocs_ci/ocs/resources/storage_cluster.py +++ b/ocs_ci/ocs/resources/storage_cluster.py @@ -464,9 +464,12 @@ def ocs_install_verification( ) elif config.DEPLOYMENT["external_mode"]: - sc_rbd = storage_class.get( - resource_name=constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD - ) + rbd_namespace = config.EXTERNAL_MODE.get("rbd_namespace") + if rbd_namespace: + rbd_resource_name = f"{constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD_NAMESPACE_PREFIX}-{rbd_namespace}" + else: + rbd_resource_name = constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD + sc_rbd = storage_class.get(resource_name=rbd_resource_name) sc_cephfs = storage_class.get( resource_name=(constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_CEPHFS) )