diff --git a/Documentation/CRDs/Block-Storage/ceph-block-pool-rados-namespace-crd.md b/Documentation/CRDs/Block-Storage/ceph-block-pool-rados-namespace-crd.md index e4f35b854..680f55862 100644 --- a/Documentation/CRDs/Block-Storage/ceph-block-pool-rados-namespace-crd.md +++ b/Documentation/CRDs/Block-Storage/ceph-block-pool-rados-namespace-crd.md @@ -50,6 +50,8 @@ If any setting is unspecified, a suitable default will be used automatically. - `blockPoolName`: The metadata name of the CephBlockPool CR where the rados namespace will be created. +- `clusterID`: ClusterID to be used for this rados namespace in the CSI configuration. If it is not set, Rook will auto-generate the clusterID. + - `mirroring`: Sets up mirroring of the rados namespace (requires Ceph v20 or newer) - `mode`: mirroring mode to run, possible values are "pool" or "image" (required). Refer to the [mirroring modes Ceph documentation](https://docs.ceph.com/en/latest/rbd/rbd-mirroring/#namespace-configuration) for more details - `remoteNamespace`: Name of the rados namespace on the peer cluster where the namespace should get mirrored. The default is the same rados namespace. diff --git a/Documentation/CRDs/Shared-Filesystem/ceph-fs-subvolumegroup-crd.md b/Documentation/CRDs/Shared-Filesystem/ceph-fs-subvolumegroup-crd.md index 2ec51a121..1a982ba08 100644 --- a/Documentation/CRDs/Shared-Filesystem/ceph-fs-subvolumegroup-crd.md +++ b/Documentation/CRDs/Shared-Filesystem/ceph-fs-subvolumegroup-crd.md @@ -67,18 +67,19 @@ If any setting is unspecified, a suitable default will be used automatically. ## Create a storage class for the subvolume group -* Create a CephFilesystem CR -* Create a CephFilesystemSubvolumegroup CR +* Create a CephFilesystem CR +* Create a CephFilesystemSubvolumegroup CR + +**Note** The clusterID can be explicitly set in the spec of the CephFilesystemSubVolumeGroup CR. +If it is not set, Rook will auto-generate the clusterID. + * Extract the `clusterID` from the status of the CephFilesystemSubvolumegroup CR: ```bash - kubectl -n rook-ceph get cephfilesystemsubvolumegroup -o jsonpath="{.status.info.clusterID}" - ``` - - ```yaml - status: - info: - clusterID: 80fc4f4bacc064be641633e6ed25ba7e + $ kubectl -n rook-ceph get cephfilesystemsubvolumegroup -o jsonpath="{.status.info.clusterID}" + 80fc4f4bacc064be641633e6ed25ba7e ``` +This returns `spec.clusterID` if present, otherwise falls back to the auto generated one. + * Set the `clusterID` in the `StorageClass`, `VolumeSnapshotClass`, and `VolumeGroupSnapshotClass` to this value instead of the name of the cluster namespace diff --git a/Documentation/CRDs/specification.md b/Documentation/CRDs/specification.md index 90fdd0b51..d0f6abcbf 100644 --- a/Documentation/CRDs/specification.md +++ b/Documentation/CRDs/specification.md @@ -1561,6 +1561,20 @@ string

The data pool name for the Ceph Filesystem subvolume group layout, if the default CephFS pool is not desired.

+ + +clusterID
+ +string + + + +(Optional) +

ClusterID to be used for this subvolume group in the CSI configuration. +It must be unique among all Ceph clusters managed by Rook. +If not specified, the clusterID will be generated and can be found in the CR status.

+ + @@ -3286,6 +3300,20 @@ RadosNamespaceMirroring

Mirroring configuration of CephBlockPoolRadosNamespace

+ + +clusterID
+ +string + + + +(Optional) +

ClusterID to be used for this RadosNamespace in the CSI configuration. +It must be unique among all Ceph clusters managed by Rook. +If not specified, the clusterID will be generated and can be found in the CR status.

+ + @@ -3359,6 +3387,20 @@ RadosNamespaceMirroring

Mirroring configuration of CephBlockPoolRadosNamespace

+ + +clusterID
+ +string + + + +(Optional) +

ClusterID to be used for this RadosNamespace in the CSI configuration. +It must be unique among all Ceph clusters managed by Rook. +If not specified, the clusterID will be generated and can be found in the CR status.

+ +

CephBlockPoolRadosNamespaceStatus @@ -4135,6 +4177,20 @@ string

The data pool name for the Ceph Filesystem subvolume group layout, if the default CephFS pool is not desired.

+ + +clusterID
+ +string + + + +(Optional) +

ClusterID to be used for this subvolume group in the CSI configuration. +It must be unique among all Ceph clusters managed by Rook. +If not specified, the clusterID will be generated and can be found in the CR status.

+ +

CephFilesystemSubVolumeGroupSpecPinning diff --git a/PendingReleaseNotes.md b/PendingReleaseNotes.md index ae1ac031c..3f89a3ee5 100644 --- a/PendingReleaseNotes.md +++ b/PendingReleaseNotes.md @@ -7,3 +7,4 @@ - Previously, only the latest version of helm was tested and the docs stated only version 3.x of helm as a prerequisite. Now rook supports the six most recent minor versions of helm along with their their patch updates. Explicitly, helm versions 3.13 and newer are supported. +- Add support for specifying the clusterID in the CephBlockPoolRadosNamespace and the CephFilesystemSubVolumeGroup CR. diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml index 48cecc4bb..4a03837aa 100644 --- a/deploy/charts/rook-ceph/templates/resources.yaml +++ b/deploy/charts/rook-ceph/templates/resources.yaml @@ -63,6 +63,18 @@ spec: x-kubernetes-validations: - message: blockPoolName is immutable rule: self == oldSelf + clusterID: + description: |- + ClusterID to be used for this RadosNamespace in the CSI configuration. + It must be unique among all Ceph clusters managed by Rook. + If not specified, the clusterID will be generated and can be found in the CR status. + maxLength: 36 + minLength: 1 + pattern: ^[a-zA-Z0-9_-]+$ + type: string + x-kubernetes-validations: + - message: ClusterID is immutable + rule: self == oldSelf mirroring: description: Mirroring configuration of CephBlockPoolRadosNamespace properties: @@ -8992,6 +9004,18 @@ spec: spec: description: Spec represents the specification of a Ceph Filesystem SubVolumeGroup properties: + clusterID: + description: |- + ClusterID to be used for this subvolume group in the CSI configuration. + It must be unique among all Ceph clusters managed by Rook. + If not specified, the clusterID will be generated and can be found in the CR status. + maxLength: 36 + minLength: 1 + pattern: ^[a-zA-Z0-9_-]+$ + type: string + x-kubernetes-validations: + - message: ClusterID is immutable + rule: self == oldSelf dataPoolName: description: The data pool name for the Ceph Filesystem subvolume group layout, if the default CephFS pool is not desired. type: string diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml index 736533d05..ef51dd42d 100644 --- a/deploy/examples/crds.yaml +++ b/deploy/examples/crds.yaml @@ -66,6 +66,18 @@ spec: x-kubernetes-validations: - message: blockPoolName is immutable rule: self == oldSelf + clusterID: + description: |- + ClusterID to be used for this RadosNamespace in the CSI configuration. + It must be unique among all Ceph clusters managed by Rook. + If not specified, the clusterID will be generated and can be found in the CR status. + maxLength: 36 + minLength: 1 + pattern: ^[a-zA-Z0-9_-]+$ + type: string + x-kubernetes-validations: + - message: ClusterID is immutable + rule: self == oldSelf mirroring: description: Mirroring configuration of CephBlockPoolRadosNamespace properties: @@ -8986,6 +8998,18 @@ spec: spec: description: Spec represents the specification of a Ceph Filesystem SubVolumeGroup properties: + clusterID: + description: |- + ClusterID to be used for this subvolume group in the CSI configuration. + It must be unique among all Ceph clusters managed by Rook. + If not specified, the clusterID will be generated and can be found in the CR status. + maxLength: 36 + minLength: 1 + pattern: ^[a-zA-Z0-9_-]+$ + type: string + x-kubernetes-validations: + - message: ClusterID is immutable + rule: self == oldSelf dataPoolName: description: The data pool name for the Ceph Filesystem subvolume group layout, if the default CephFS pool is not desired. type: string diff --git a/deploy/examples/radosnamespace.yaml b/deploy/examples/radosnamespace.yaml index 80230947d..bd7ea355b 100644 --- a/deploy/examples/radosnamespace.yaml +++ b/deploy/examples/radosnamespace.yaml @@ -9,3 +9,7 @@ spec: # name: namespace-a # blockPoolName is the name of the CephBlockPool CR where the namespace will be created. blockPoolName: replicapool + # ClusterID to be used for this RadosNamespace in the CSI configuration. + # It must be unique among all Ceph clusters managed by Rook. + # If not specified, the clusterID will be generated and can be found in the CR status. + # clusterID: namespace-a diff --git a/deploy/examples/subvolumegroup.yaml b/deploy/examples/subvolumegroup.yaml index 50345142a..4f7538059 100644 --- a/deploy/examples/subvolumegroup.yaml +++ b/deploy/examples/subvolumegroup.yaml @@ -14,10 +14,14 @@ spec: # by default pinning is set with value: distributed=1 # for disabling default values set (distributed=0) pinning: - distributed: 1 # distributed=<0, 1> (disabled=0) + distributed: 1 # distributed=<0, 1> (disabled=0) # export: # export=<0-256> (disabled=-1) # random: # random=[0.0, 1.0](disabled=0.0) # Quota size of the subvolume group. #quota: 10G # data pool name for the subvolume group layout instead of the default data pool. #dataPoolName: myfs-replicated + # ClusterID to be used for this subvolume group in the CSI configuration. + # It must be unique among all Ceph clusters managed by Rook. + # If not specified, the clusterID will be generated and can be found in the CR status. + # clusterID: group-a diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index c63674b4b..e8d23f103 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -3586,6 +3586,15 @@ type CephFilesystemSubVolumeGroupSpec struct { // The data pool name for the Ceph Filesystem subvolume group layout, if the default CephFS pool is not desired. // +optional DataPoolName string `json:"dataPoolName"` + // ClusterID to be used for this subvolume group in the CSI configuration. + // It must be unique among all Ceph clusters managed by Rook. + // If not specified, the clusterID will be generated and can be found in the CR status. + // +optional + // +kubebuilder:validation:XValidation:message="ClusterID is immutable",rule="self == oldSelf" + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=36 + // +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$` + ClusterID string `json:"clusterID,omitempty"` } // CephFilesystemSubVolumeGroupSpecPinning represents the pinning configuration of SubVolumeGroup @@ -3685,6 +3694,16 @@ type CephBlockPoolRadosNamespaceSpec struct { // Mirroring configuration of CephBlockPoolRadosNamespace // +optional Mirroring *RadosNamespaceMirroring `json:"mirroring,omitempty"` + + // ClusterID to be used for this RadosNamespace in the CSI configuration. + // It must be unique among all Ceph clusters managed by Rook. + // If not specified, the clusterID will be generated and can be found in the CR status. + // +optional + // +kubebuilder:validation:XValidation:message="ClusterID is immutable",rule="self == oldSelf" + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=36 + // +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$` + ClusterID string `json:"clusterID,omitempty"` } // CephBlockPoolRadosNamespaceStatus represents the Status of Ceph BlockPool diff --git a/pkg/operator/ceph/file/subvolumegroup/controller.go b/pkg/operator/ceph/file/subvolumegroup/controller.go index b3010b1ad..1797c1868 100644 --- a/pkg/operator/ceph/file/subvolumegroup/controller.go +++ b/pkg/operator/ceph/file/subvolumegroup/controller.go @@ -452,6 +452,9 @@ func (r *ReconcileCephFilesystemSubVolumeGroup) updateStatus(observedGeneration } func buildClusterID(cephFilesystemSubVolumeGroup *cephv1.CephFilesystemSubVolumeGroup) string { + if cephFilesystemSubVolumeGroup.Spec.ClusterID != "" { + return cephFilesystemSubVolumeGroup.Spec.ClusterID + } clusterID := fmt.Sprintf("%s-%s-file-%s", cephFilesystemSubVolumeGroup.Namespace, cephFilesystemSubVolumeGroup.Spec.FilesystemName, getSubvolumeGroupName(cephFilesystemSubVolumeGroup)) return k8sutil.Hash(clusterID) } diff --git a/pkg/operator/ceph/file/subvolumegroup/controller_test.go b/pkg/operator/ceph/file/subvolumegroup/controller_test.go index 77125a18e..674ffe0a7 100644 --- a/pkg/operator/ceph/file/subvolumegroup/controller_test.go +++ b/pkg/operator/ceph/file/subvolumegroup/controller_test.go @@ -345,6 +345,20 @@ func Test_buildClusterID(t *testing.T) { cephFilesystemSubVolumeGroup := &cephv1.CephFilesystemSubVolumeGroup{ObjectMeta: metav1.ObjectMeta{Namespace: "rook-ceph", Name: longName}, Spec: cephv1.CephFilesystemSubVolumeGroupSpec{FilesystemName: "myfs"}} clusterID := buildClusterID(cephFilesystemSubVolumeGroup) assert.Equal(t, "29e92135b7e8c014079b9f9f3566777d", clusterID) + + inputClusterID := "test-clusterId" + cephFilesystemSubVolumeGroup = &cephv1.CephFilesystemSubVolumeGroup{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "rook-ceph", + Name: longName, + }, + Spec: cephv1.CephFilesystemSubVolumeGroupSpec{ + FilesystemName: "myfs", + ClusterID: inputClusterID, + }, + } + clusterID = buildClusterID(cephFilesystemSubVolumeGroup) + assert.Equal(t, inputClusterID, clusterID) } func Test_formatPinning(t *testing.T) { diff --git a/pkg/operator/ceph/pool/radosnamespace/controller.go b/pkg/operator/ceph/pool/radosnamespace/controller.go index 2a0e45784..347cd449d 100644 --- a/pkg/operator/ceph/pool/radosnamespace/controller.go +++ b/pkg/operator/ceph/pool/radosnamespace/controller.go @@ -488,6 +488,9 @@ func (r *ReconcileCephBlockPoolRadosNamespace) updateStatus(client client.Client } func buildClusterID(cephBlockPoolRadosNamespace *cephv1.CephBlockPoolRadosNamespace) string { + if cephBlockPoolRadosNamespace.Spec.ClusterID != "" { + return cephBlockPoolRadosNamespace.Spec.ClusterID + } clusterID := fmt.Sprintf("%s-%s-block-%s", cephBlockPoolRadosNamespace.Namespace, cephBlockPoolRadosNamespace.Spec.BlockPoolName, cephv1.GetRadosNamespaceName(cephBlockPoolRadosNamespace)) return k8sutil.Hash(clusterID) } diff --git a/pkg/operator/ceph/pool/radosnamespace/controller_test.go b/pkg/operator/ceph/pool/radosnamespace/controller_test.go index 097079752..66049a815 100644 --- a/pkg/operator/ceph/pool/radosnamespace/controller_test.go +++ b/pkg/operator/ceph/pool/radosnamespace/controller_test.go @@ -633,6 +633,21 @@ func Test_buildClusterID(t *testing.T) { cephBlockPoolRadosNamespace := &cephv1.CephBlockPoolRadosNamespace{ObjectMeta: metav1.ObjectMeta{Namespace: "rook-ceph", Name: longName}, Spec: cephv1.CephBlockPoolRadosNamespaceSpec{BlockPoolName: "replicapool"}} clusterID := buildClusterID(cephBlockPoolRadosNamespace) assert.Equal(t, "2a74e5201e6ff9d15916ce2109c4f868", clusterID) + + // test user provided clusterID + inputClusterID := "test-clusterID" + cephBlockPoolRadosNamespace = &cephv1.CephBlockPoolRadosNamespace{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "rook-ceph", + Name: longName, + }, + Spec: cephv1.CephBlockPoolRadosNamespaceSpec{ + BlockPoolName: "replicapool", + ClusterID: inputClusterID, + }, + } + clusterID = buildClusterID(cephBlockPoolRadosNamespace) + assert.Equal(t, inputClusterID, clusterID) } func TestGetRadosNamespaceName(t *testing.T) {