core: add clusterID to rados namespace CRD

Providing an option for user to specify the clusterID
they want to use in the storageclass while creating
the radosnamespace.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna committed 2025-07-28 08:29:51 +02:00
1 parent 5fff02eb86
commit 2a41afcb28
7 files changed
+84

No files matched your search

+28
View File
@@ -3286,6 +3286,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 +3373,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
@@ -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:
+12
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:
+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
+10
View File
@@ -3685,6 +3685,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
@@ -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) {