Skip to content

Commit 3ccf568

Browse files
committed
Add .spec.clusterSpecList field to MongoDB
1 parent 0af0efd commit 3ccf568

File tree

9 files changed

+539
-84
lines changed

9 files changed

+539
-84
lines changed

api/v1/mdb/mongodb_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,13 @@ type DbCommonSpec struct {
421421
// +kubebuilder:validation:Enum=SingleCluster;MultiCluster
422422
// +optional
423423
Topology string `json:"topology,omitempty"`
424+
425+
// ClusterSpecList defines the configuration for MongoDB instances across multiple Kubernetes clusters.
426+
// This field is used when Topology is set to "MultiCluster" and specifies how MongoDB members
427+
// are distributed across different clusters, including member counts, service configurations,
428+
// and external access settings for each cluster.
429+
// +optional
430+
ClusterSpecList ClusterSpecList `json:"clusterSpecList,omitempty"`
424431
}
425432

426433
type MongoDbSpec struct {

api/v1/mdbmulti/mongodb_multi_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ type MongoDBMultiSpec struct {
227227
// +kubebuilder:pruning:PreserveUnknownFields
228228
mdbv1.DbCommonSpec `json:",inline"`
229229

230-
ClusterSpecList mdbv1.ClusterSpecList `json:"clusterSpecList,omitempty"`
231-
232230
// Mapping stores the deterministic index for a given cluster-name.
233231
Mapping map[string]int `json:"-"`
234232
}

config/crd/bases/mongodb.com_mongodb.yaml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,151 @@ spec:
396396
clusterDomain:
397397
format: hostname
398398
type: string
399+
clusterSpecList:
400+
description: |-
401+
ClusterSpecList defines the configuration for MongoDB instances across multiple Kubernetes clusters.
402+
This field is used when Topology is set to "MultiCluster" and specifies how MongoDB members
403+
are distributed across different clusters, including member counts, service configurations,
404+
and external access settings for each cluster.
405+
items:
406+
description: |-
407+
ClusterSpecItem is the mongodb multi-cluster spec that is specific to a
408+
particular Kubernetes cluster, this maps to the statefulset created in each cluster
409+
properties:
410+
clusterName:
411+
description: |-
412+
ClusterName is name of the cluster where the MongoDB Statefulset will be scheduled, the
413+
name should have a one on one mapping with the service-account created in the central cluster
414+
to talk to the workload clusters.
415+
type: string
416+
externalAccess:
417+
description: ExternalAccessConfiguration provides external access
418+
configuration for Multi-Cluster.
419+
properties:
420+
externalDomain:
421+
description: An external domain that is used for exposing
422+
MongoDB to the outside world.
423+
type: string
424+
externalService:
425+
description: Provides a way to override the default (NodePort)
426+
Service
427+
properties:
428+
annotations:
429+
additionalProperties:
430+
type: string
431+
description: A map of annotations that shall be added
432+
to the externally available Service.
433+
type: object
434+
spec:
435+
description: A wrapper for the Service spec object.
436+
type: object
437+
x-kubernetes-preserve-unknown-fields: true
438+
type: object
439+
type: object
440+
memberConfig:
441+
description: MemberConfig allows to specify votes, priorities
442+
and tags for each of the mongodb process.
443+
items:
444+
properties:
445+
priority:
446+
type: string
447+
tags:
448+
additionalProperties:
449+
type: string
450+
type: object
451+
votes:
452+
type: integer
453+
type: object
454+
type: array
455+
members:
456+
description: Amount of members for this MongoDB Replica Set
457+
type: integer
458+
podSpec:
459+
properties:
460+
persistence:
461+
description: Note, that this field is used by MongoDB resources
462+
only, let's keep it here for simplicity
463+
properties:
464+
multiple:
465+
properties:
466+
data:
467+
properties:
468+
labelSelector:
469+
type: object
470+
x-kubernetes-preserve-unknown-fields: true
471+
storage:
472+
type: string
473+
storageClass:
474+
type: string
475+
type: object
476+
journal:
477+
properties:
478+
labelSelector:
479+
type: object
480+
x-kubernetes-preserve-unknown-fields: true
481+
storage:
482+
type: string
483+
storageClass:
484+
type: string
485+
type: object
486+
logs:
487+
properties:
488+
labelSelector:
489+
type: object
490+
x-kubernetes-preserve-unknown-fields: true
491+
storage:
492+
type: string
493+
storageClass:
494+
type: string
495+
type: object
496+
type: object
497+
single:
498+
properties:
499+
labelSelector:
500+
type: object
501+
x-kubernetes-preserve-unknown-fields: true
502+
storage:
503+
type: string
504+
storageClass:
505+
type: string
506+
type: object
507+
type: object
508+
podTemplate:
509+
type: object
510+
x-kubernetes-preserve-unknown-fields: true
511+
type: object
512+
service:
513+
description: this is an optional service, it will get the name
514+
"<rsName>-service" in case not provided
515+
type: string
516+
statefulSet:
517+
description: |-
518+
StatefulSetConfiguration holds the optional custom StatefulSet
519+
that should be merged into the operator created one.
520+
properties:
521+
metadata:
522+
description: StatefulSetMetadataWrapper is a wrapper around
523+
Labels and Annotations
524+
properties:
525+
annotations:
526+
additionalProperties:
527+
type: string
528+
type: object
529+
labels:
530+
additionalProperties:
531+
type: string
532+
type: object
533+
type: object
534+
spec:
535+
type: object
536+
x-kubernetes-preserve-unknown-fields: true
537+
required:
538+
- spec
539+
type: object
540+
required:
541+
- members
542+
type: object
543+
type: array
399544
configServerCount:
400545
type: integer
401546
configSrv:

config/crd/bases/mongodb.com_mongodbmulticluster.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ spec:
388388
format: hostname
389389
type: string
390390
clusterSpecList:
391+
description: |-
392+
ClusterSpecList defines the configuration for MongoDB instances across multiple Kubernetes clusters.
393+
This field is used when Topology is set to "MultiCluster" and specifies how MongoDB members
394+
are distributed across different clusters, including member counts, service configurations,
395+
and external access settings for each cluster.
391396
items:
392397
description: |-
393398
ClusterSpecItem is the mongodb multi-cluster spec that is specific to a

controllers/operator/construct/multicluster/multicluster_replicaset_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ func getMultiClusterMongoDB() mdbmulti.MongoDBMultiCluster {
4646
},
4747
Roles: []mdb.MongoDBRole{},
4848
},
49-
},
50-
ClusterSpecList: mdb.ClusterSpecList{
51-
{
52-
ClusterName: "foo",
53-
Members: 3,
49+
ClusterSpecList: mdb.ClusterSpecList{
50+
{
51+
ClusterName: "foo",
52+
Members: 3,
53+
},
5454
},
5555
},
5656
}

helm_chart/crds/mongodb.com_mongodb.yaml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,151 @@ spec:
396396
clusterDomain:
397397
format: hostname
398398
type: string
399+
clusterSpecList:
400+
description: |-
401+
ClusterSpecList defines the configuration for MongoDB instances across multiple Kubernetes clusters.
402+
This field is used when Topology is set to "MultiCluster" and specifies how MongoDB members
403+
are distributed across different clusters, including member counts, service configurations,
404+
and external access settings for each cluster.
405+
items:
406+
description: |-
407+
ClusterSpecItem is the mongodb multi-cluster spec that is specific to a
408+
particular Kubernetes cluster, this maps to the statefulset created in each cluster
409+
properties:
410+
clusterName:
411+
description: |-
412+
ClusterName is name of the cluster where the MongoDB Statefulset will be scheduled, the
413+
name should have a one on one mapping with the service-account created in the central cluster
414+
to talk to the workload clusters.
415+
type: string
416+
externalAccess:
417+
description: ExternalAccessConfiguration provides external access
418+
configuration for Multi-Cluster.
419+
properties:
420+
externalDomain:
421+
description: An external domain that is used for exposing
422+
MongoDB to the outside world.
423+
type: string
424+
externalService:
425+
description: Provides a way to override the default (NodePort)
426+
Service
427+
properties:
428+
annotations:
429+
additionalProperties:
430+
type: string
431+
description: A map of annotations that shall be added
432+
to the externally available Service.
433+
type: object
434+
spec:
435+
description: A wrapper for the Service spec object.
436+
type: object
437+
x-kubernetes-preserve-unknown-fields: true
438+
type: object
439+
type: object
440+
memberConfig:
441+
description: MemberConfig allows to specify votes, priorities
442+
and tags for each of the mongodb process.
443+
items:
444+
properties:
445+
priority:
446+
type: string
447+
tags:
448+
additionalProperties:
449+
type: string
450+
type: object
451+
votes:
452+
type: integer
453+
type: object
454+
type: array
455+
members:
456+
description: Amount of members for this MongoDB Replica Set
457+
type: integer
458+
podSpec:
459+
properties:
460+
persistence:
461+
description: Note, that this field is used by MongoDB resources
462+
only, let's keep it here for simplicity
463+
properties:
464+
multiple:
465+
properties:
466+
data:
467+
properties:
468+
labelSelector:
469+
type: object
470+
x-kubernetes-preserve-unknown-fields: true
471+
storage:
472+
type: string
473+
storageClass:
474+
type: string
475+
type: object
476+
journal:
477+
properties:
478+
labelSelector:
479+
type: object
480+
x-kubernetes-preserve-unknown-fields: true
481+
storage:
482+
type: string
483+
storageClass:
484+
type: string
485+
type: object
486+
logs:
487+
properties:
488+
labelSelector:
489+
type: object
490+
x-kubernetes-preserve-unknown-fields: true
491+
storage:
492+
type: string
493+
storageClass:
494+
type: string
495+
type: object
496+
type: object
497+
single:
498+
properties:
499+
labelSelector:
500+
type: object
501+
x-kubernetes-preserve-unknown-fields: true
502+
storage:
503+
type: string
504+
storageClass:
505+
type: string
506+
type: object
507+
type: object
508+
podTemplate:
509+
type: object
510+
x-kubernetes-preserve-unknown-fields: true
511+
type: object
512+
service:
513+
description: this is an optional service, it will get the name
514+
"<rsName>-service" in case not provided
515+
type: string
516+
statefulSet:
517+
description: |-
518+
StatefulSetConfiguration holds the optional custom StatefulSet
519+
that should be merged into the operator created one.
520+
properties:
521+
metadata:
522+
description: StatefulSetMetadataWrapper is a wrapper around
523+
Labels and Annotations
524+
properties:
525+
annotations:
526+
additionalProperties:
527+
type: string
528+
type: object
529+
labels:
530+
additionalProperties:
531+
type: string
532+
type: object
533+
type: object
534+
spec:
535+
type: object
536+
x-kubernetes-preserve-unknown-fields: true
537+
required:
538+
- spec
539+
type: object
540+
required:
541+
- members
542+
type: object
543+
type: array
399544
configServerCount:
400545
type: integer
401546
configSrv:

helm_chart/crds/mongodb.com_mongodbmulticluster.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ spec:
388388
format: hostname
389389
type: string
390390
clusterSpecList:
391+
description: |-
392+
ClusterSpecList defines the configuration for MongoDB instances across multiple Kubernetes clusters.
393+
This field is used when Topology is set to "MultiCluster" and specifies how MongoDB members
394+
are distributed across different clusters, including member counts, service configurations,
395+
and external access settings for each cluster.
391396
items:
392397
description: |-
393398
ClusterSpecItem is the mongodb multi-cluster spec that is specific to a

0 commit comments

Comments
 (0)