Merge pull request #16102 from Madhu-1/add-clusterID

Provide option to set the clusterID in the RNS and SVG CR
This commit is contained in:
Travis Nielsen authored and GitHub committed 2025-07-28 08:48:38 -06:00
commit 55e02436da
13 files changed
+180 -10

No files matched your search

@@ -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.
@@ -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 <name> -o jsonpath="{.status.info.clusterID}"
```
```yaml
status:
info:
clusterID: 80fc4f4bacc064be641633e6ed25ba7e
$ kubectl -n rook-ceph get cephfilesystemsubvolumegroup <name> -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
+56
View File
@@ -1561,6 +1561,20 @@ string
<p>The data pool name for the Ceph Filesystem subvolume group layout, if the default CephFS pool is not desired.</p>
</td>
</tr>
<tr>
<td>
<code>clusterID</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>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.</p>
</td>
</tr>
</table>
</td>
</tr>
@@ -3286,6 +3300,20 @@ RadosNamespaceMirroring
<p>Mirroring configuration of CephBlockPoolRadosNamespace</p>
</td>
</tr>
<tr>
<td>
<code>clusterID</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>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.</p>
</td>
</tr>
</table>
</td>
</tr>
@@ -3359,6 +3387,20 @@ RadosNamespaceMirroring
<p>Mirroring configuration of CephBlockPoolRadosNamespace</p>
</td>
</tr>
<tr>
<td>
<code>clusterID</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>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.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="ceph.rook.io/v1.CephBlockPoolRadosNamespaceStatus">CephBlockPoolRadosNamespaceStatus
@@ -4135,6 +4177,20 @@ string
<p>The data pool name for the Ceph Filesystem subvolume group layout, if the default CephFS pool is not desired.</p>
</td>
</tr>
<tr>
<td>
<code>clusterID</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>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.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="ceph.rook.io/v1.CephFilesystemSubVolumeGroupSpecPinning">CephFilesystemSubVolumeGroupSpecPinning
+1
View File
@@ -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.
@@ -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
+24
View File
@@ -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
+4
View File
@@ -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
+5 -1
View File
@@ -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
+19
View File
@@ -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
@@ -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)
}
@@ -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) {
@@ -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)
}
@@ -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) {