Skip to content

Commit 17da67b

Browse files
lsierantanandsyncsfealebenpaeviveksinghggits
authored
CLOUDP-312564: MongoDB Search - Public Preview (#425)
# Summary This PR contains all the changes related to the operator and e2e tests from the search's main feature branch. ## Proof of Work <!-- Enter your proof that it works here.--> ## Checklist - [ ] Have you linked a jira ticket and/or is the ticket in the title? - [ ] Have you checked whether your jira ticket required DOCSP changes? - [ ] Have you added changelog file? - use `skip-changelog` label if not needed - refer to [Changelog files and Release Notes](https://github.com/mongodb/mongodb-kubernetes/blob/master/CONTRIBUTING.md#changelog-files-and-release-notes) section in CONTRIBUTING.md for more details --------- Co-authored-by: Anand Singh <anand.singh@mongodb.com> Co-authored-by: Yavor Georgiev <fealebenpae@users.noreply.github.com> Co-authored-by: Vivek Singh <vsingh.ggits.2010@gmail.com> Co-authored-by: Yavor Georgiev <yavor.georgiev@mongodb.com>
1 parent f0f4584 commit 17da67b

File tree

55 files changed

+3861
-643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3861
-643
lines changed

.evergreen-tasks.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,3 +1287,29 @@ tasks:
12871287
tags: ["patch-run"]
12881288
commands:
12891289
- func: "e2e_test"
1290+
1291+
- name: e2e_search_community_tls
1292+
tags: ["patch-run"]
1293+
commands:
1294+
- func: "e2e_test"
1295+
1296+
- name: e2e_search_external_basic
1297+
tags: [ "patch-run" ]
1298+
commands:
1299+
- func: "e2e_test"
1300+
1301+
- name: e2e_search_external_tls
1302+
tags: [ "patch-run" ]
1303+
commands:
1304+
- func: "e2e_test"
1305+
1306+
- name: e2e_search_enterprise_basic
1307+
tags: [ "patch-run" ]
1308+
commands:
1309+
- func: "e2e_test"
1310+
1311+
- name: e2e_search_enterprise_tls
1312+
tags: [ "patch-run" ]
1313+
commands:
1314+
- func: "e2e_test"
1315+

.evergreen.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,9 @@ task_groups:
575575
tasks:
576576
- e2e_community_replicaset_scale
577577
- e2e_search_community_basic
578+
- e2e_search_community_tls
579+
- e2e_search_external_basic
580+
- e2e_search_external_tls
578581

579582
# This is the task group that contains all the tests run in the e2e_mdb_kind_ubuntu_cloudqa build variant
580583
- name: e2e_mdb_kind_cloudqa_task_group
@@ -699,6 +702,9 @@ task_groups:
699702
- e2e_replica_set_oidc_workforce
700703
- e2e_sharded_cluster_oidc_m2m_group
701704
- e2e_sharded_cluster_oidc_m2m_user
705+
# MongoDBSearch test group
706+
- e2e_search_enterprise_basic
707+
- e2e_search_enterprise_tls
702708
<<: *teardown_group
703709

704710
# this task group contains just a one task, which is smoke testing whether the operator

api/v1/search/mongodbsearch_types.go

Lines changed: 100 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package search
22

33
import (
4+
"fmt"
5+
46
"k8s.io/apimachinery/pkg/runtime/schema"
57
"k8s.io/apimachinery/pkg/types"
68

@@ -14,30 +16,76 @@ import (
1416
)
1517

1618
const (
17-
MongotDefaultPort = 27027
18-
MongotDefaultMetricsPort = 9946
19+
MongotDefaultPort = 27027
20+
MongotDefaultMetricsPort = 9946
21+
MongotDefautHealthCheckPort = 8080
22+
MongotDefaultSyncSourceUsername = "search-sync-source"
1923
)
2024

2125
func init() {
2226
v1.SchemeBuilder.Register(&MongoDBSearch{}, &MongoDBSearchList{})
2327
}
2428

2529
type MongoDBSearchSpec struct {
30+
// Optional version of MongoDB Search component (mongot). If not set, then the operator will set the most appropriate version of MongoDB Search.
2631
// +optional
2732
Version string `json:"version"`
33+
// MongoDB database connection details from which MongoDB Search will synchronize data to build indexes.
2834
// +optional
2935
Source *MongoDBSource `json:"source"`
36+
// StatefulSetSpec which the operator will apply to the MongoDB Search StatefulSet at the end of the reconcile loop. Use to provide necessary customizations,
37+
// which aren't exposed as fields in the MongoDBSearch.spec.
3038
// +optional
3139
StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"`
40+
// Configure MongoDB Search's persistent volume. If not defined, the operator will request 10GB of storage.
3241
// +optional
3342
Persistence *common.Persistence `json:"persistence,omitempty"`
43+
// Configure resource requests and limits for the MongoDB Search pods.
3444
// +optional
3545
ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
46+
// Configure security settings of the MongoDB Search server that MongoDB database is connecting to when performing search queries.
47+
// +optional
48+
Security Security `json:"security"`
3649
}
3750

3851
type MongoDBSource struct {
3952
// +optional
4053
MongoDBResourceRef *userv1.MongoDBResourceRef `json:"mongodbResourceRef,omitempty"`
54+
// +optional
55+
ExternalMongoDBSource *ExternalMongoDBSource `json:"external,omitempty"`
56+
// +optional
57+
PasswordSecretRef *userv1.SecretKeyRef `json:"passwordSecretRef,omitempty"`
58+
// +optional
59+
Username *string `json:"username,omitempty"`
60+
}
61+
62+
type ExternalMongoDBSource struct {
63+
HostAndPorts []string `json:"hostAndPorts,omitempty"`
64+
// mongod keyfile used to connect to the external MongoDB deployment
65+
KeyFileSecretKeyRef *userv1.SecretKeyRef `json:"keyfileSecretRef,omitempty"`
66+
// TLS configuration for the external MongoDB deployment
67+
// +optional
68+
TLS *ExternalMongodTLS `json:"tls,omitempty"`
69+
}
70+
71+
type ExternalMongodTLS struct {
72+
Enabled bool `json:"enabled"`
73+
// +optional
74+
CA *corev1.LocalObjectReference `json:"ca,omitempty"`
75+
}
76+
77+
type Security struct {
78+
// +optional
79+
TLS TLS `json:"tls"`
80+
}
81+
82+
type TLS struct {
83+
Enabled bool `json:"enabled"`
84+
// CertificateKeySecret is a reference to a Secret containing a private key and certificate to use for TLS.
85+
// The key and cert are expected to be PEM encoded and available at "tls.key" and "tls.crt".
86+
// This is the same format used for the standard "kubernetes.io/tls" Secret type, but no specific type is required.
87+
// +optional
88+
CertificateKeySecret corev1.LocalObjectReference `json:"certificateKeySecretRef"`
4189
}
4290

4391
type MongoDBSearchStatus struct {
@@ -105,6 +153,31 @@ func (s *MongoDBSearch) MongotConfigConfigMapNamespacedName() types.NamespacedNa
105153
return types.NamespacedName{Name: s.Name + "-search-config", Namespace: s.Namespace}
106154
}
107155

156+
func (s *MongoDBSearch) SourceUserPasswordSecretRef() *userv1.SecretKeyRef {
157+
var syncUserPasswordSecretKey *userv1.SecretKeyRef
158+
if s.Spec.Source != nil && s.Spec.Source.PasswordSecretRef != nil {
159+
syncUserPasswordSecretKey = s.Spec.Source.PasswordSecretRef
160+
} else {
161+
syncUserPasswordSecretKey = &userv1.SecretKeyRef{
162+
Name: fmt.Sprintf("%s-%s-password", s.Name, s.SourceUsername()),
163+
}
164+
}
165+
166+
if syncUserPasswordSecretKey.Key == "" {
167+
syncUserPasswordSecretKey.Key = "password"
168+
}
169+
170+
return syncUserPasswordSecretKey
171+
}
172+
173+
func (s *MongoDBSearch) SourceUsername() string {
174+
if s.Spec.Source != nil && s.Spec.Source.Username != nil {
175+
return *s.Spec.Source.Username
176+
}
177+
178+
return MongotDefaultSyncSourceUsername
179+
}
180+
108181
func (s *MongoDBSearch) StatefulSetNamespacedName() types.NamespacedName {
109182
return types.NamespacedName{Name: s.Name + "-search", Namespace: s.Namespace}
110183
}
@@ -118,13 +191,17 @@ func (s *MongoDBSearch) GetOwnerReferences() []metav1.OwnerReference {
118191
return []metav1.OwnerReference{ownerReference}
119192
}
120193

121-
func (s *MongoDBSearch) GetMongoDBResourceRef() userv1.MongoDBResourceRef {
194+
func (s *MongoDBSearch) GetMongoDBResourceRef() *userv1.MongoDBResourceRef {
195+
if s.IsExternalMongoDBSource() {
196+
return nil
197+
}
198+
122199
mdbResourceRef := userv1.MongoDBResourceRef{Namespace: s.Namespace, Name: s.Name}
123200
if s.Spec.Source != nil && s.Spec.Source.MongoDBResourceRef != nil && s.Spec.Source.MongoDBResourceRef.Name != "" {
124201
mdbResourceRef.Name = s.Spec.Source.MongoDBResourceRef.Name
125202
}
126203

127-
return mdbResourceRef
204+
return &mdbResourceRef
128205
}
129206

130207
func (s *MongoDBSearch) GetMongotPort() int32 {
@@ -134,3 +211,22 @@ func (s *MongoDBSearch) GetMongotPort() int32 {
134211
func (s *MongoDBSearch) GetMongotMetricsPort() int32 {
135212
return MongotDefaultMetricsPort
136213
}
214+
215+
// TLSSecretNamespacedName will get the namespaced name of the Secret containing the server certificate and key
216+
func (s *MongoDBSearch) TLSSecretNamespacedName() types.NamespacedName {
217+
return types.NamespacedName{Name: s.Spec.Security.TLS.CertificateKeySecret.Name, Namespace: s.Namespace}
218+
}
219+
220+
// TLSOperatorSecretNamespacedName will get the namespaced name of the Secret created by the operator
221+
// containing the combined certificate and key.
222+
func (s *MongoDBSearch) TLSOperatorSecretNamespacedName() types.NamespacedName {
223+
return types.NamespacedName{Name: s.Name + "-search-certificate-key", Namespace: s.Namespace}
224+
}
225+
226+
func (s *MongoDBSearch) GetMongotHealthCheckPort() int32 {
227+
return MongotDefautHealthCheckPort
228+
}
229+
230+
func (s *MongoDBSearch) IsExternalMongoDBSource() bool {
231+
return s.Spec.Source != nil && s.Spec.Source.ExternalMongoDBSource != nil
232+
}

api/v1/search/zz_generated.deepcopy.go

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)