For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

MongoDB Search and Vector Search Settings

You can deploy MongoDB Search and Vector Search alongside MongoDB 8.2 or later using MongoDB Controllers for Kubernetes Operator.

The following example shows the settings inside the spec object for MongoDB Search and Vector Search deployment. To learn more about these settings, see the Required Settings and Optional Settings.

Note

This example is not a working configuration. It contains all available fields populated with sample values for reference. Some fields are mutually exclusive, and some take precedence over others (for example, source.external takes precedence over source.mongodbResourceRef). Refer to the field descriptions below for valid combinations.

Example

1spec:
2 source:
3 # external takes precedence over mongodbResourceRef
4 mongodbResourceRef:
5 name: mdb
6 external:
7 # hostAndPorts and shardedCluster are mutually exclusive
8 hostAndPorts:
9 - mdb-rs-external-0.example.com:27017
10 - mdb-rs-external-1.example.com:27017
11 - mdb-rs-external-2.example.com:27017
12 shardedCluster:
13 router:
14 hosts:
15 - mongos1.example.com:27017
16 - mongos2.example.com:27017
17 shards:
18 - shardName: shard-0
19 hosts:
20 - shard0-node1.example.com:27018
21 - shard0-node2.example.com:27018
22 - shardName: shard-1
23 hosts:
24 - shard1-node1.example.com:27018
25 - shard1-node2.example.com:27018
26 keyfileSecretRef:
27 name: mdb-keyfile
28 key: keyfile
29 tls:
30 # ca references a ConfigMap that contains ca.crt
31 ca:
32 name: mdbc-rs-ca
33 username: search-sync-source
34 passwordSecretRef:
35 name: mdbc-rs-search-sync-source-password
36 key: password
37 # x509 authentication (mutually exclusive with
38 # username/passwordSecretRef and source.tls)
39 x509:
40 clientCertificateSecretRef:
41 name: mongot-x509-client-cert
42 # Set only if the private key is encrypted
43 keyFilePasswordSecretRef:
44 name: mongot-x509-key-password
45 # TLS client certificate for SCRAM connections
46 # (mutually exclusive with x509):
47 # tls:
48 # clientCertificateSecretRef:
49 # name: mongot-scram-client-cert
50 # keyFilePasswordSecretRef:
51 # name: mongot-scram-key-password
52 security:
53 tls:
54 certificateKeySecretRef:
55 name: mdbs-tls-secret
56 certsSecretPrefix: my-prefix
57 # Set only if the private key is encrypted
58 keyFilePasswordSecretRef:
59 name: mdbs-tls-key-password
60 version: "1.70.1"
61 autoEmbedding:
62 embeddingModelAPIKeySecret:
63 name: embedding-model-api-query-key
64 providerEndpoint: https://ai.mongodb.com/v1/embeddings
65 featureFlags:
66 enableOverloadRetrySignal: true
67 logLevel: INFO
68 observability:
69 prometheus:
70 mode: enabled
71 port: 9946
72 metricsForwarder:
73 mode: auto
74 resourceRequirements:
75 requests:
76 cpu: 100m
77 memory: 128Mi
78 limits:
79 cpu: 250m
80 memory: 256Mi
81 deployment:
82 spec:
83 template:
84 spec:
85 nodeSelector:
86 kubernetes.io/os: linux
87 opsManager:
88 agentCredentials:
89 name: om-agent-api-key
90 projectConfigMapRef:
91 name: om-project-config
92 clusters:
93 - name: cluster-1
94 index: 0
95 replicas: 2
96 loadBalancer:
97 # Option 1: Operator-managed Envoy load balancer
98 managed:
99 externalHostname: "{shardName}.search.apps.example.com"
100 routerHostname: "search-router.apps.example.com:27028"
101 replicas: 2
102 resourceRequirements:
103 requests:
104 cpu: "100m"
105 memory: 128Mi
106 limits:
107 cpu: "500m"
108 memory: 512Mi
109 deployment:
110 spec:
111 template:
112 spec:
113 nodeSelector:
114 kubernetes.io/os: linux
115 retryPolicy:
116 numRetries: 2
117 perTryTimeout: "60s"
118 minMongotReadyReplicas: 1
119 # Option 2: User-provided (BYO) load balancer
120 # (mutually exclusive with managed)
121 unmanaged:
122 endpoint: "{shardName}-search-lb.corp.example.com:443"
123 resourceRequirements:
124 limits:
125 cpu: "3"
126 memory: 5Gi
127 requests:
128 cpu: "2"
129 memory: 4Gi
130 persistence:
131 single:
132 storage: 16G
133 storageClass: standard
134 statefulSet:
135 spec:
136 template:
137 spec:
138 nodeSelector:
139 kubernetes.io/os: linux
140 jvmFlags:
141 - -Xms2g
142 - -Xmx2g
143 advancedMongotConfigs:
144 someAdvancedSetting: value
145 syncSourceSelector:
146 matchTagSets:
147 - region: us-east-1
148 workload: search
149 - {}
150 shardOverrides:
151 - shardNames:
152 - shard-0
153 replicas: 3
154 resourceRequirements:
155 requests:
156 cpu: "4"
157 memory: 8Gi
158 persistence:
159 single:
160 storage: 32G
161 jvmFlags:
162 - -Xms4g
163 - -Xmx4g
164 statefulSet:
165 spec:
166 template:
167 spec:
168 nodeSelector:
169 disktype: ssd

This section describes the settings that are required for deploying the MongoDB Search and Vector Search resource. If you define only the required settings in the Custom Resource Definition (CRD), the MongoDB Controllers for Kubernetes Operator uses the defaults for all optional settings to configure MongoDBSearch.

apiVersion

Type: string

Version of the MongoDB Kubernetes resource schema. Set the value to mongodb.com/v1.

kind

Type: string

Kind of MongoDB Kubernetes resource to create. Set this to MongoDBSearch.

metadata.namespace

Type: string

Namespace in which to create the MongoDBSearch resource. To leverage automatic configuration of MongoDBSearch and MongoDB or MongoDBCommunity resources, create the MongoDBSearch resource in the same namespace as the MongoDB or MongoDBCommunity resource.

metadata.name

Type: string

Unique identifier of the MongoDBSearch resource. The name must be a valid Kubernetes DNS subdomain name. Keep the name short. The Kubernetes Operator derives the names of the Kubernetes resources it creates from it, for example {name}-search-{clusterIndex}-{shardName}. The Kubernetes Operator validates that every generated name fits within the Kubernetes DNS limits of 63 characters for labels and 253 characters for subdomain names.

spec.clusters

Type: array of objects

Per-Kubernetes-cluster deployment configuration for MongoDBSearch. This field is required and must contain at least one entry and at most 50 entries: one entry for a single-cluster deployment, or one entry for each Kubernetes cluster that runs mongot pods in a multi-cluster deployment. For the full field reference, including name and index, see spec.clusters.

This section describes the optional settings for the MongoDB Search and Vector Search resource. If you omit the optional settings and define only the required settings in the CRD, the MongoDB Controllers for Kubernetes Operator uses the defaults for all optional settings to configure MongoDBSearch.

spec.source

Type: object

Setting that describes the MongoDB source for mongot. The source can be a replica set or a sharded cluster. This setting is required if:

  • MongoDB is external

  • MongoDB has a different name from MongoDBSearch

The MongoDBSearch resource must always be connected to a MongoDB deployment. If you deployed using the Kubernetes Operator with MongoDB or MongoDBCommunity CRD, and if spec.source is empty, the Kubernetes Operator uses the following based on the metadata.name to look for the database in Kubernetes:

  • Find MongoDB or MongoDBCommunity resources with the same name as set for metadata.name in MongoDBSearch, in the same namespace.

  • Find the password secret for the mongot user from the <MongoDBSearch.metadata.name>-<username>-password secret, which for the default username yields <MongoDBSearch.metadata.name>-search-sync-source-password.

spec.source.mongodbResourceRef.name

Type: string

Name of the MongoDB or MongoDBCommunity resource to associate with this MongoDB Search and Vector Search resource. The Kubernetes Operator supports both replica sets and sharded clusters. You can't have more than one MongoDBSearch resource referencing the same MongoDB or MongoDBCommunity resource. If you specify a different name, you must explicitly point to the MongoDB or MongoDBCommunity where you want to enable MongoDB Search and Vector Search.

If you reference a sharded cluster MongoDB resource, the Kubernetes Operator auto-discovers the shard topology (shard names, replica set members, mongos routers) and creates per-shard mongot StatefulSets automatically. You don't need to perform any additional external configuration.

Use this field only if your MongoDB or MongoDBCommunity resource is deployed in the same Kubernetes cluster and is in the same namespace as your MongoDBSearch resource. If you set this field, the Kubernetes Operator automatically:

  • Sets proper connection strings to the database.

  • Reconfigures MongoDB database deployments by setting necessary parameters to enable search functionality and configures the addresses of the search pods.

If your database is deployed outside of Kubernetes or is in a different namespace, use spec.source.external to configure the connection to the database. If you set both fields, spec.source.external takes precedence.

If omitted, the Kubernetes Operator looks for a MongoDB or MongoDBCommunity resource with the same name as this MongoDBSearch resource.

spec.source.mongodbResourceRef.namespace

Type: string

Namespace of the MongoDB or MongoDBCommunity resource that spec.source.mongodbResourceRef.name refers to. The Kubernetes Operator currently ignores this field and always uses the namespace of the MongoDBSearch resource. Cross-namespace references are unsupported. If your database is in a different namespace, use spec.source.external.

spec.source.username

Type: string

Username to use to authenticate mongot with mongod. The specified user must have the searchCoordinator role. If omitted, the Kubernetes Operator assumes the username is search-sync-source.

spec.source.passwordSecretRef.name

Type: string

Name of the secret that contains the password that mongot must use to authenticate with mongod. If omitted, defaults to <MongoDBSearch.metadata.name>-<username>-password, where <username> is the value of spec.source.username. For the default username search-sync-source, this yields <MongoDBSearch.metadata.name>-search-sync-source-password.

spec.source.passwordSecretRef.key

Type: string

Key under which the password value is stored in the secret. If omitted, defaults to password.

spec.source.x509

Type: object

Configures x509 client certificate authentication for the mongot sync source connection. If you set this field, mongot authenticates to MongoDB using x509 instead of username and password.

This field is mutually exclusive with spec.source.passwordSecretRef, spec.source.username, and spec.source.tls. The Kubernetes Operator rejects the configuration if you specify both x509 and password authentication.

spec.source.x509.clientCertificateSecretRef

Type: object

Secret that contains the x509 client certificate and key for authenticating to the MongoDB sync source. The Secret must contain the following keys:

  • tls.crt — Client certificate

  • tls.key — Private key

If the private key is encrypted with a password, store the password in a separate Secret and reference it with spec.source.x509.keyFilePasswordSecretRef.

You must specify this field if you set spec.source.x509.

Example

spec:
source:
x509:
clientCertificateSecretRef:
name: mongot-x509-client-cert
spec.source.x509.keyFilePasswordSecretRef

Type: object

Secret that contains the password that decrypts the password-encrypted private key in spec.source.x509.clientCertificateSecretRef. The Secret must contain the password under the keyFilePassword key. Omit this field if the private key is not encrypted.

spec.source.tls

Type: object

Configures a TLS client certificate for the mongot sync source connection if you use SCRAM (username and password) authentication. If you set this field, mongot presents the client certificate during the TLS handshake with the source MongoDB deployment (mutual TLS transport). mongot still authenticates with the username and password.

Use this field only with SCRAM authentication (spec.source.passwordSecretRef). This field is mutually exclusive with spec.source.x509. If you want the client certificate itself to serve as the authentication credential, use spec.source.x509 instead.

spec.source.tls.clientCertificateSecretRef

Type: object

Secret that contains the TLS client certificate and key that mongot presents during the TLS handshake with the source MongoDB deployment. The Secret must contain the following keys:

  • tls.crt — Client certificate

  • tls.key — Private key

You must specify this field if you set spec.source.tls.

spec.source.tls.keyFilePasswordSecretRef

Type: object

Secret that contains the password that decrypts the password-encrypted private key in spec.source.tls.clientCertificateSecretRef. The Secret must contain the password under the keyFilePassword key. Omit this field if the private key is not encrypted.

The following settings are required only for configuring a connection to an external MongoDB deployment.

spec.source.external

Type: object

Settings that describe the external data source. This object describes the settings for the MongoDB Search and Vector Search resource to connect to an external MongoDB. Specify these settings only if you want to connect to an external MongoDB that wasn't deployed using the Kubernetes Operator. If you specify these settings, they take precedence over spec.source.mongodbResourceRef. If you used the Kubernetes Operator to install MongoDB in the same cluster, these settings are optional.

spec.source.external.keyfileSecretRef

Type: object

Secret that contains the mongod keyfile that mongot uses to connect to the external MongoDB deployment.

spec.source.external.keyfileSecretRef.name

Type: string

Name of the Secret that contains the keyfile. You must specify this field if you set spec.source.external.keyfileSecretRef.

spec.source.external.keyfileSecretRef.key

Type: string

Key under which the keyfile is stored in the Secret. This field is optional.

spec.source.external.hostAndPorts

Type: array of strings

List of hostnames and ports of the external replica set. This is a host seed list to the MongoDB replica set. The mongot connects to the database in a replica set mode and gets the list of all other nodes using db.hello().

This field is mutually exclusive with spec.source.external.shardedCluster. Use hostAndPorts for replica set sources and shardedCluster for sharded cluster sources.

Example

hostAndPorts:
- mdbc-rs-0.my-external-domain.example.com:27017
- mdbc-rs-1.my-external-domain.example.com:27017
- mdbc-rs-2.my-external-domain.example.com:27017
spec.source.external.tls

Type: object

TLS Settings that mongot must use when connecting to the external MongoDB database.

spec.source.external.tls.ca.name

Type: string

Name of the ConfigMap containing the trusted chain of the certificate authorities that issued the TLS certificate used by the mongod nodes.

Example

spec:
source:
external:
tls:
ca:
name: trusted-ca

You must specify the certificate (or certificate chain) under the ca.crt key in this ConfigMap.

Example

kind: ConfigMap
apiVersion: v1
metadata:
name: trusted-ca
data:
ca.crt: |
-----BEGIN CERTIFICATE-----
MIIDBTCCAe2gAwIBAgIIH3EOUAGAsx0wDQYJKoZIhvcNAQELBQAwFTETMBEGA1UE
[...]
U/4rN8Ias/FONYFRtGfs9uXHmo2MP04BF+9ED2dlbNDUbat+6XCozLJj98nI4VEi
qaV3JrVFHTgN
-----END CERTIFICATE-----

The following settings are required only for configuring a connection to an external MongoDB sharded cluster. They extend the existing spec.source.external settings.

Note

spec.source.external.hostAndPorts (for replica sets) and spec.source.external.shardedCluster are mutually exclusive. Specify only one of them.

spec.source.external.shardedCluster

Type: object

Declares an external sharded MongoDB cluster as the data source for mongot. Contains configuration for mongos routers and per-shard replica set members.

Use this only if the MongoDB sharded cluster is deployed outside of Kubernetes and is not managed by the Kubernetes Operator. For operator-managed sharded clusters deployed with the MongoDB CRD, use spec.source.mongodbResourceRef instead. The Kubernetes Operator auto-discovers shard topology.

Example

spec:
source:
external:
shardedCluster:
router:
hosts:
- "mongos1.external:27017"
- "mongos2.external:27017"
shards:
- shardName: "shard-0"
hosts:
- "shard0-node1.external:27018"
- "shard0-node2.external:27018"
- shardName: "shard-1"
hosts:
- "shard1-node1.external:27018"
- "shard1-node2.external:27018"
spec.source.external.shardedCluster.router

Type: object

Configuration for the mongos (router) instances of the external sharded cluster.

spec.source.external.shardedCluster.router.hosts

Type: array of strings

List of endpoints for the mongos router instances in host:port format. All mongot instances connect to these routers. Specify at least one entry.

Example

router:
hosts:
- "mongos1.external:27017"
- "mongos2.external:27017"
spec.source.external.shardedCluster.shards

Type: array of objects

List of all shards in the external MongoDB cluster. Each entry describes one shard's replica set. The Kubernetes Operator creates one mongot StatefulSet for each shard, where each StatefulSet contains the number of pods specified in spec.clusters[].replicas. Specify at least one shard entry.

spec.source.external.shardedCluster.shards[*].shardName

Type: string

The logical name of the shard. The Kubernetes Operator uses this name for Kubernetes resource naming (StatefulSets, Services, Secrets). The value can be different from the MongoDB shard name.

Naming constraints:

  • Must be unique across all shards.

  • Must conform to Kubernetes DNS label name rules (RFC 1123), which allow lowercase alphanumeric characters and hyphens (-), and require that the name start and end with an alphanumeric character. Periods (.) and underscores (_) are not allowed. The maximum length is 63 characters.

  • The Kubernetes Operator combines metadata.name, the cluster index, and shardName into the names of the Kubernetes resources it creates (for example, {name}-search-{clusterIndex}-{shardName}), and validates that every generated name fits within the Kubernetes DNS limits of 63 characters for labels and 253 characters for subdomain names. Keep shardName short enough for these limits.

Example

shards:
- shardName: "shard-0"
hosts:
- "shard0-node1.external:27018"
spec.source.external.shardedCluster.shards[*].hosts

Type: array of strings

List of endpoints of the mongod replica set members for this shard in the host:port format. mongot instances replicate data from these hosts. Specify at least one entry.

Each replica set (shard) has its own group of mongot instances, which source data only from that replica set. Different shards never share the same mongot instances.

Example

shards:
- shardName: "shard-0"
hosts:
- "shard0-node1.external:27018"
- "shard0-node2.external:27018"
- "shard0-node3.external:27018"

The following settings describe each entry of the required spec.clusters array.

spec.clusters

Type: array of objects

Per-Kubernetes-cluster deployment configuration for MongoDBSearch. This field is required and must contain at least one entry and at most 50 entries. All sizing and placement settings, such as replicas, loadBalancer, resourceRequirements, persistence, jvmFlags, and statefulSet, live inside a clusters entry. These settings have no top-level equivalents.

For a single-cluster deployment, specify one entry. You can omit name and index.

Example

spec:
clusters:
- {}

For a multi-cluster deployment, specify one entry for each Kubernetes cluster that runs mongot pods. If you specify more than one entry, the following rules apply:

  • name is required on every entry and must be unique.

  • index is required on every entry and must be unique.

  • The MongoDB source must be external (spec.source.external). Multi-cluster deployments don't support operator-managed MongoDB sources.

  • Every entry must configure an operator-managed load balancer (loadBalancer.managed). Multi-cluster deployments don't support unmanaged load balancers.

The Kubernetes Operator enforces these rules through CRD validation rules and reconcile-time validation.

spec.clusters[].name

Type: string

Name of the Kubernetes cluster for this entry, with a maximum length of 253 characters. You can omit this field for a single-cluster deployment.

If spec.clusters contains more than one entry, name is required, must be unique across entries, and can't change after you create the resource.

spec.clusters[].index

Type: integer

Stable integer identifier of the Kubernetes cluster for this entry. The value must be between 0 and 999, and must be unique across entries. If spec.clusters contains more than one entry, index is required on every entry.

The Kubernetes Operator includes the index in the names of the Kubernetes resources it creates for this cluster entry, for example {name}-search-{index} for StatefulSets, {name}-search-{index}-svc for Services, and {name}-search-{index}-config for ConfigMaps. For sharded cluster sources, the names also include the shard name, for example {name}-search-{index}-{shardName} and {name}-search-{index}-{shardName}-svc.

Warning

Don't change the index of an existing entry because the index is part of the resource names. Changing it causes the Kubernetes Operator to create new resources under the new index and orphan the resources at the old index. This applies to every index-bearing resource, including proxy Services ({name}-search-{index}[-{shardName}]-proxy-svc), the Envoy Deployment and ConfigMap ({name}-search-lb-{index}), load balancer certificate Secrets, and metrics forwarder resources ({name}-search-metrics-forwarder-{index}).

For a single-cluster deployment, you can omit this field and it defaults to 0. However, if each member Kubernetes cluster runs its own Kubernetes Operator instance, set index explicitly to a distinct value in each cluster's MongoDBSearch resource. Distinct indexes keep the generated hostnames and resource names from colliding across clusters.

spec.clusters[].replicas

Type: integer

Number of mongot pods to deploy in this Kubernetes cluster. For a replica set source, this is the total number of mongot pods. For a sharded cluster source, this is the number of mongot pods per shard.

If spec.clusters[].replicas is greater than 1, you must also configure spec.clusters[].loadBalancer to route traffic between mongod and the multiple mongot instances.

If you set spec.clusters[].replicas to 0, the Kubernetes Operator takes the mongot deployment in this cluster offline. The Kubernetes Operator scales the StatefulSet to zero pods and keeps the MongoDBSearch resource and its other Kubernetes resources in place.

If omitted, defaults to 1.

Example

spec:
clusters:
- replicas: 2
spec.clusters[].resourceRequirements

Type: core/v1/ResourceRequirements

CPU and memory that the mongodb-search container can request and be limited to. We recommend using this field to customize resource allocations instead of overriding it with spec.clusters[].statefulSet.

If you do not override the JVM heap size in spec.clusters[].jvmFlags, the Kubernetes Operator sets the default heap size (-Xmx) to 50% of the memory request of the mongot container. Adjust spec.clusters[].resourceRequirements accordingly to control both pod resources and JVM heap size.

If omitted, the Kubernetes Operator uses the following default values:

requests:
cpu: 2
memory: 4Gi
spec.clusters[].resourceRequirements.limits

Type: object

Upper cap on the resources (CPU and memory) that the mongodb-search container can consume. By default, no limits are set. If omitted, the pod isn't restricted and so, might use all the resources on the node. We recommend setting limits based on your workload.

spec.clusters[].resourceRequirements.requests

Type: object

Amount of CPU and memory requested for the mongodb-search container. If you specify only one of cpu or memory, the Kubernetes Operator applies the default value for the other. If omitted, the Kubernetes Operator uses the following default values:

requests:
cpu: 2
memory: 4Gi
spec.clusters[].persistence.single

Type: object

Storage configuration for MongoDB Search and Vector Search persistence volume where MongoDB Search and Vector Search indexes are stored. Each search instance (pod) has its own independent storage to maintain indexes, which isn't shared with the MongoDB database. Only index metadata (definitions) are stored in the database itself.

Scalar
Data Type
Description

labelSelector

string

Tag used to bind mounted volumes to directories.

storage

string

Minimum size of Persistent Volume to mount. This value is expressed as an integer followed by a unit of storage in JEDEC notation.

Default value is 16G.

For example, if a replica set requires 60 gigabytes of storage space, set this value to 60G.

storageClass

string

Type of storage specified in a Persistent Volume Claim. You can create this storage type as a StorageClass object before using it in this object specification.

Make sure to set the StorageClass reclaimPolicy to Retain. This ensures that data is retained when a Persistent Volume Claim is removed.

MongoDBSearch supports only the single persistence mode, which uses one volume for all data. Although the CRD schema also contains a spec.clusters[].persistence.multiple field, the Kubernetes Operator doesn't apply it. If you omit persistence, the Kubernetes Operator sets spec.clusters[].persistence.single.storage to 16G.

spec.clusters[].loadBalancer

Type: object

Configuration for L7 load balancing between mongod (or mongos) and mongot. This field is required if spec.clusters[].replicas is greater than 1. If spec.clusters[].replicas is 1, this field is optional. You can configure a load balancer even for a single mongot instance to prepare for scaling up later.

Exactly one of managed or unmanaged must be set.

All entries in spec.clusters must agree on the load balancer mode: either every entry sets loadBalancer.managed, every entry sets loadBalancer.unmanaged, or no entry sets loadBalancer. The Kubernetes Operator rejects mixed modes. Multi-cluster deployments support only the managed mode.

The load balancer affects which TLS certificates mongod clients see and which hostnames those certificates must contain:

  • Without a load balancer, mongod connects directly to mongot. The TLS certificate presented to mongod is mongot's own certificate. If the MongoDB cluster is outside of Kubernetes, the mongot service is exposed on an external domain. You must include that external domain in the mongot TLS certificate's SAN (Subject Alternative Name) field.

  • With a managed load balancer (spec.clusters[].loadBalancer.managed), the Envoy proxy is the only component that connects directly to mongot. The Envoy proxy reaches mongot through the internal Service FQDNs:

    • Replica set: <name>-search-<clusterIndex>-svc.<ns>.svc.cluster.local

    • Sharded cluster: <name>-search-<clusterIndex>-<shard>-svc.<ns>.svc.cluster.local

    We recommend that you include these service FQDNs in the mongot TLS certificate's SAN field. The operator-managed Envoy proxy currently validates the mongot certificate against the certificate authority only and doesn't match SAN hostnames. External mongod processes see the Envoy proxy's TLS certificate, so include external domains in the Envoy certificate's SANs, not in the mongot certificate.

Tip

Enable a managed load balancer even if you initially deploy a single mongot pod. With the load balancer in place, the domains in your TLS certificates remain stable if you scale up spec.clusters[].replicas later because the load balancer is already present between mongod and mongot.

spec.clusters[].loadBalancer.managed

Type: object

Configures an operator-managed Envoy load balancer. The Kubernetes Operator deploys and manages the Envoy proxy with correct routing, mTLS, and HTTP/2+gRPC stream pinning. Set this field to an empty object ({}) to use the defaults.

This field is mutually exclusive with spec.clusters[].loadBalancer.unmanaged.

For sharded cluster sources, you must also configure spec.security.tls if you use a managed load balancer. The Envoy proxy routes traffic to the correct shard using SNI, which requires TLS.

Example

spec:
clusters:
- loadBalancer:
managed: {}
spec.clusters[].loadBalancer.managed.externalHostname

Type: string

Hostname that the Envoy proxy expects for SNI matching on incoming requests. The Kubernetes Operator uses this value to configure routing rules that match the TLS SNI field from incoming mongod connections. The Envoy TLS server certificate must include this hostname in its SAN (Subject Alternative Name) field.

For sharded cluster sources, the value must contain a {shardName} placeholder, which the Kubernetes Operator expands per shard. Each shard gets its own hostname, and the Envoy TLS server certificate must include all expanded shard hostnames in its SANs. You can use a wildcard certificate to cover all shards with a single certificate and avoid re-issuing when shards are added. For replica set sources, don't use the {shardName} placeholder.

This field is required if MongoDB is externally managed (not deployed by the Kubernetes Operator). If MongoDB is operator-managed in the same cluster, omit this field because the Kubernetes Operator auto-configures routing.

In multi-cluster deployments, each cluster entry typically uses a distinct hostname. However, the Kubernetes Operator permits sharing one hostname across clusters, for example if a failover proxy that spans availability zones fronts the Envoy proxies of multiple clusters.

Example

# Replica set with external MongoDB
spec:
clusters:
- loadBalancer:
managed:
externalHostname: "search.apps.example.com"
# Sharded cluster with external MongoDB
spec:
clusters:
- loadBalancer:
managed:
externalHostname: "{shardName}.search.example.com"
spec.clusters[].loadBalancer.managed.routerHostname

Type: string

Endpoint that mongos routers use to reach this cluster's mongot instances through the managed Envoy load balancer, in the host:port format. The Kubernetes Operator uses the hostname for SNI matching on the cluster-level routing chain, so the Envoy TLS server certificate must include this hostname in its SANs.

This field is required if you use a managed load balancer with an external sharded MongoDB source (spec.source.external.shardedCluster). The Kubernetes Operator ignores this field for replica set sources and for operator-managed MongoDB.

Unlike externalHostname, the Kubernetes Operator uses this value verbatim, so the value must not contain a {shardName} placeholder. This endpoint is the shard-agnostic entry point for mongos.

In multi-cluster deployments, each cluster entry typically uses a distinct value. However, the Kubernetes Operator permits sharing one value across clusters, for example if a failover proxy that spans availability zones fronts the Envoy proxies of multiple clusters.

Example

spec:
clusters:
- loadBalancer:
managed:
externalHostname: "{shardName}.search.example.com"
routerHostname: "search-router.example.com:27028"
spec.clusters[].loadBalancer.managed.replicas

Type: integer

Number of Envoy proxy pods to deploy in this Kubernetes cluster. The value must be 1 or greater. If omitted, defaults to 1.

spec.clusters[].loadBalancer.managed.resourceRequirements

Type: core/v1/ResourceRequirements

CPU and memory that the Envoy container can request and be limited to. If you specify this setting, the Kubernetes Operator replaces the defaults entirely.

If omitted, the Kubernetes Operator uses the following default values:

requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi

Example

spec:
clusters:
- loadBalancer:
managed:
resourceRequirements:
requests:
cpu: "200m"
memory: "256Mi"
limits:
cpu: "1"
memory: "1Gi"
spec.clusters[].loadBalancer.managed.deployment

Type: object

Overrides that the Kubernetes Operator merges into the operator-created Envoy Deployment. Follows the same convention as spec.statefulSet on MongoDB resources. If omitted, the Kubernetes Operator uses defaults for the Envoy Deployment.

This object contains two fields:

  • metadata — contains labels and annotations fields that the Kubernetes Operator merges into the Envoy Deployment metadata.

  • spec — an apps/v1/DeploymentSpec object. The Kubernetes Operator merges these overrides into the Envoy Deployment spec.

Example

spec:
clusters:
- loadBalancer:
managed:
deployment:
spec:
template:
spec:
nodeSelector:
kubernetes.io/os: linux
spec.clusters[].loadBalancer.managed.retryPolicy

Type: object

Retry behavior that the Envoy proxy applies to individual gRPC streams to the upstream mongot instances. The Envoy proxy sends each retry attempt to a different mongot host than the failed attempt.

If you omit this field, the Envoy proxy retries with the default values: 2 retries with a per-try timeout of 60s.

Example

spec:
clusters:
- loadBalancer:
managed:
retryPolicy:
numRetries: 2
perTryTimeout: "60s"
spec.clusters[].loadBalancer.managed.retryPolicy.numRetries

Type: integer

Maximum number of retries per request. The value must be 1 or greater. If omitted, defaults to 2, which allows three total attempts for each request.

spec.clusters[].loadBalancer.managed.retryPolicy.perTryTimeout

Type: string

Timeout for each individual attempt, including the original request, expressed as a duration string (for example, "30s"). If omitted, defaults to "60s".

spec.clusters[].loadBalancer.managed.minMongotReadyReplicas

Type: integer

Minimum number of ready mongot replicas that a mongot group (for example, the mongot instances of one shard) must have before the Envoy proxy routes traffic to it. While a group is below this threshold, the Envoy proxy forwards the traffic intended for that group to a healthy mongot group and marks the requests with the routed_from_another_shard header. These requests return empty results instead of errors.

The value must be 1 or greater. If omitted, defaults to 1.

spec.clusters[].loadBalancer.unmanaged

Type: object

Configures a user-provided (Bring Your Own) L7 load balancer. You are responsible for deploying and configuring the load balancer externally.

This field is mutually exclusive with spec.clusters[].loadBalancer.managed. Multi-cluster deployments don't support unmanaged load balancers.

spec.clusters[].loadBalancer.unmanaged.endpoint

Type: string

The endpoint of the BYO load balancer in host:port format. You must specify this field if you configure spec.clusters[].loadBalancer.unmanaged.

If the Kubernetes Operator manages the MongoDB deployment (using spec.source.mongodbResourceRef), the Kubernetes Operator writes this value into the mongod configuration as mongotHost and searchIndexManagementHostAndPort. If MongoDB is external, you configure the mongod parameters yourself using the same value.

For external sharded cluster sources, the value must contain a {shardName} placeholder that the Kubernetes Operator expands per shard, and it must contain more than just the placeholder. For external replica set sources, the value must not contain a {shardName} placeholder.

Example

# Replica set example
spec:
clusters:
- loadBalancer:
unmanaged:
endpoint: "search-lb.corp.example.com:443"
# Sharded cluster example
spec:
clusters:
- loadBalancer:
unmanaged:
endpoint: "{shardName}-lb.corp.example.com:443"
spec.clusters[].shardOverrides

Type: array of objects

Overrides that size specific shards within this cluster entry differently from the cluster defaults. Use this field to give individual shards more or fewer mongot replicas, resources, or storage than the rest of the cluster.

You can use this field only with an external sharded cluster source (spec.source.external.shardedCluster). Each shard name that you reference must exist in spec.source.external.shardedCluster.shards[*].shardName, and you can override each shard at most once per cluster entry.

If you set replicas, resourceRequirements, persistence, or jvmFlags in an override, they replace the cluster value for the named shards. The Kubernetes Operator deep-merges statefulSet onto the cluster value. Fields that you don't set inherit the cluster value.

Example

spec:
clusters:
- replicas: 2
shardOverrides:
- shardNames:
- shard-0
replicas: 3
resourceRequirements:
requests:
cpu: "4"
memory: 8Gi
spec.clusters[].shardOverrides[*].shardNames

Type: array of strings

Names of the shards within this cluster entry that the override applies to. This field is required and must contain at least one entry.

spec.clusters[].shardOverrides[*].replicas

Type: integer

Replaces the cluster's mongot replica count for the named shards. A value of 0 takes the mongot instances for these shards offline.

spec.clusters[].shardOverrides[*].resourceRequirements

Type: core/v1/ResourceRequirements

Replaces the cluster's CPU and memory requests and limits for the named shards.

spec.clusters[].shardOverrides[*].persistence

Type: object

Replaces the cluster's persistent volume configuration for the named shards. Uses the same schema as spec.clusters[].persistence.

spec.clusters[].shardOverrides[*].statefulSet

Type: object

StatefulSet overrides for the named shards. Unlike the other override fields, the Kubernetes Operator deep-merges this value onto the cluster's spec.clusters[].statefulSet value instead of replacing it.

spec.clusters[].shardOverrides[*].jvmFlags

Type: array of strings

Replaces the cluster's spec.clusters[].jvmFlags for the named shards if you set it to a non-empty list. The format rules for spec.clusters[].jvmFlags also apply to this field.

spec.clusters[].syncSourceSelector

Type: object

Selects which mongod nodes the mongot instances in this cluster entry sync data from.

spec.clusters[].syncSourceSelector.matchTagSets

Type: array of objects

Ordered list of replica set tag sets that selects the sync source mongod nodes by their replica set tags. The Kubernetes Operator passes the list to the mongot configuration. mongot syncs from the nodes that the first matching tag set selects, and prefers secondary nodes.

Each entry is a map of tag names to tag values. An empty document ({}) matches any node, so you can append a trailing {} entry as a match-any fallback if no earlier tag set matches. You can specify at most 50 entries.

Example

spec:
clusters:
- syncSourceSelector:
matchTagSets:
- region: us-east-1
workload: search
- {}
spec.clusters[].jvmFlags

Type: array of strings

JVM flags passed to the mongot process. The Kubernetes Operator includes the flags without modification in the mongot startup command using --jvm-flags "<all flags space-separated>".

Each flag must start with -X, -XX:, or -D, must not contain spaces, and can contain only alphanumeric characters and the ., _, +, :, -, and = characters. The Kubernetes Operator rejects flags that don't match these rules.

If you don't specify -Xms or -Xmx in this field, the Kubernetes Operator auto-calculates heap size by setting both to half of spec.clusters[].resourceRequirements.requests.memory. If you don't specify resource requirements, the Kubernetes Operator uses a default of 4Gi memory request, yielding approximately -Xmx2048m -Xms2048m.

If you provide your own -Xms or -Xmx values, the Kubernetes Operator uses them and does not override the values. The Kubernetes Operator always appends the flags you provide after the operator-computed flags.

To learn more, see Hardware Sizing for mongot.

Example

spec:
clusters:
- jvmFlags:
- -Xms2g
- -Xmx2g
spec.clusters[].statefulSet

Type: object

Overrides for the StatefulSet that the Kubernetes Operator creates for deploying mongot pods. The Kubernetes Operator always applies the overrides last, so they overwrite the settings that the Kubernetes Operator computes.

This object contains two fields:

  • metadata — contains labels and annotations fields that the Kubernetes Operator merges into the StatefulSet metadata.

  • spec — an apps/v1/StatefulSetSpec object. The Kubernetes Operator merges these overrides into the StatefulSet spec.

Note

Don't set resource requirements or persistence settings using spec.clusters[].statefulSet. Instead, use the spec.clusters[].resourceRequirements and spec.clusters[].persistence fields respectively.

spec.clusters[].advancedMongotConfigs

Type: object

Advanced mongot settings for this cluster entry. The Kubernetes Operator renders the value verbatim under the advancedConfigs key of the mongot configuration file, without reading or modifying it. This field doesn't affect the settings that the Kubernetes Operator generates elsewhere in the mongot configuration.

Use this field only for mongot settings that the MongoDBSearch resource doesn't expose as first-class fields.

spec.security

Type: object

Security settings for mongot listen server.

spec.security.tls

Type: object

TLS settings for mongot. If omitted, mongot doesn't use TLS for incoming connections.

If you use a managed load balancer with a sharded cluster source, this field is required. The Envoy proxy routes traffic to the correct shard using SNI, which depends on the TLS ClientHello. The Kubernetes Operator fails the reconcile if you omit spec.security.tls in this configuration.

spec.security.tls.certificateKeySecretRef.name

Type: string

Deprecated since version 1.8.0. : Use spec.security.tls.certsSecretPrefix instead.

Name of the TLS secret in the same namespace containing the private key (tls.key) and the certificate (tls.crt). The secret can be of type kubernetes.io/tls (that is issued by cert-manager) or can be created manually.

The Kubernetes Operator still supports this field for replica set deployments for backwards compatibility. However:

  • For sharded cluster deployments, the Kubernetes Operator rejects this field during validation. Use spec.security.tls.certsSecretPrefix instead, because a single secret reference cannot cover per-shard certificates.

  • If you specify both certificateKeySecretRef and certsSecretPrefix, certificateKeySecretRef takes precedence for replica set deployments.

For new deployments, use spec.security.tls.certsSecretPrefix even for replica sets.

spec.security.tls.certsSecretPrefix

Type: string

Prefix that the Kubernetes Operator uses to derive TLS secret names by naming convention. If you set this field, the Kubernetes Operator looks for secrets following these patterns instead of requiring explicit secret references for each component:

Component
Secret Name Pattern

Replica set's mongot server cert

{certsSecretPrefix}-{name}-search-cert

Sharded mongot cert (per cluster and shard)

{certsSecretPrefix}-{name}-search-{clusterIndex}-{shardName}-cert

Managed load balancer server cert (per cluster, all topologies)

{certsSecretPrefix}-{name}-search-lb-{clusterIndex}-cert

Managed load balancer client cert

{certsSecretPrefix}-{name}-search-lb-{clusterIndex}-client-cert

Where:

  • {name} is metadata.name of the MongoDBSearch resource

  • {clusterIndex} is the value of spec.clusters[].index (0 for a single-cluster deployment that doesn't set an index)

  • {shardName} is the value of spec.source.external.shardedCluster.shards[*].shardName

The Kubernetes Operator uses one managed load balancer server certificate per cluster for all topologies. For sharded clusters, the SANs of this certificate must include all expanded shard hostnames from externalHostname and the routerHostname.

The Kubernetes Operator resolves the mongot server certificate secret name in the following order:

  1. If you set spec.security.tls.certificateKeySecretRef.name, the Kubernetes Operator uses that name.

  2. If you set certsSecretPrefix, the Kubernetes Operator uses the naming patterns in the preceding table.

  3. If you set neither field, the Kubernetes Operator uses the default name {name}-search-cert for replica set deployments, or the default per-shard pattern {name}-search-{clusterIndex}-{shardName}-cert for sharded deployments.

If you don't set certsSecretPrefix, the managed load balancer certificates also use default names: the Kubernetes Operator mounts {name}-search-lb-{clusterIndex}-cert for the server certificate and {name}-search-lb-{clusterIndex}-client-cert for the client certificate.

Note

For sharded cluster deployments, the Kubernetes Operator rejects certificateKeySecretRef because a single secret reference cannot cover per-shard certificates. Use certsSecretPrefix, or set neither field and create secrets that follow the default per-shard pattern and the default-named load balancer certificate secrets.

Example

spec:
security:
tls:
certsSecretPrefix: my-prefix
spec.security.tls.keyFilePasswordSecretRef

Type: object

Secret that contains the password that decrypts the password-encrypted server private key in the TLS certificate secret. The Secret must contain the password under the keyFilePassword key. Omit this field if the server private key is not encrypted.

spec.logLevel

Type: string

Verbosity of the mongot logs. Value can be one of the following:

  • TRACE

  • DEBUG

  • INFO

  • WARN

  • ERROR

If omitted, defaults to INFO.

spec.observability

Type: object

Observability settings for the MongoDBSearch resource, including the Prometheus metrics endpoint in mongot and the metrics forwarder for Ops Manager.

spec.observability.prometheus

Type: object

Configuration for the Prometheus metrics endpoint in mongot. If you omit this field, the Kubernetes Operator enables the metrics endpoint on the default port 9946. To disable the endpoint, set spec.observability.prometheus.mode to disabled. To change the port, set spec.observability.prometheus.port.

spec.observability.prometheus.mode

Type: string

Enables or disables the Prometheus metrics endpoint in mongot. Value can be one of the following:

  • enabled

  • disabled

If omitted, defaults to enabled.

spec.observability.prometheus.port

Type: integer

Port on which to enable Prometheus metrics endpoint. By default, Prometheus metrics endpoint is enabled on port 9946.

spec.observability.metricsForwarder

Type: object

Configuration for the metrics forwarder, a Deployment that the Kubernetes Operator creates to scrape the mongot Prometheus metrics and forward them to Ops Manager.

spec.observability.metricsForwarder.mode

Type: string

Whether the Kubernetes Operator creates the metrics forwarder. Value can be one of the following:

  • auto — The Kubernetes Operator creates the forwarder for operator-managed MongoDB (Ops Manager-backed) sources, and for external sources only if you set spec.observability.metricsForwarder.opsManager. For MongoDBCommunity sources, the Kubernetes Operator doesn't create the forwarder.

  • enabled — The Kubernetes Operator always creates the forwarder. If the source is a MongoDBCommunity resource, the Kubernetes Operator reports an error because the forwarder isn't supported for MongoDBCommunity sources.

  • disabled — The Kubernetes Operator never creates the forwarder.

If omitted, defaults to auto.

The enabled and auto modes require the Prometheus endpoint (spec.observability.prometheus) to be enabled. If you disable the endpoint, the Kubernetes Operator reports an Invalid metrics forwarder status.

spec.observability.metricsForwarder.resourceRequirements

Type: core/v1/ResourceRequirements

CPU and memory that the metrics forwarder container can request and be limited to.

If omitted, the Kubernetes Operator uses the following default values:

requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 250m
memory: 256Mi
spec.observability.metricsForwarder.deployment

Type: object

Overrides that the Kubernetes Operator merges into the operator-created metrics forwarder Deployment. Follows the same convention as spec.clusters[].loadBalancer.managed.deployment: a metadata field with labels and annotations, and a spec field with an apps/v1/DeploymentSpec object.

spec.observability.metricsForwarder.opsManager

Type: object

Ops Manager project and credentials that the metrics forwarder sends metrics to. If omitted, the Kubernetes Operator derives the project and credentials from the connection configuration of the source MongoDB resource. Set this field for external MongoDB sources, where no source MongoDB resource exists.

If you set this field, you must set both agentCredentials and projectConfigMapRef.

spec.observability.metricsForwarder.opsManager.agentCredentials.name

Type: string

Name of the Secret that contains the Ops Manager Agent API key that the metrics forwarder authenticates with.

spec.observability.metricsForwarder.opsManager.projectConfigMapRef.name

Type: string

Name of the ConfigMap that contains the Ops Manager project configuration that the metrics forwarder sends metrics to.

Important

Automated embedding is available only as a Preview feature for MongoDB Community Edition deployment. The feature and corresponding documentation might change at any time during the Preview period. To learn more, see Preview Features.

spec.autoEmbedding

Type: Object

Configuration for Automated Embedding for text data in your collection.

spec.autoEmbedding.embeddingModelAPIKeySecret

Type: Object

Configuration for the embedding model provider API keys. To enable Automated Embedding, you must create two keys, one for generating embeddings at index-time for data in your collection and another for generating embeddings at query-time for the query text. If you don't already have the keys, we recommend that you create keys from two Atlas projects. To learn more about creating keys for the Atlas projects from the Atlas UI, see Manage API Keys.

spec.autoEmbedding.embeddingModelAPIKeySecret.name

Type: string

Name of the secret that contains the embedding model API keys that mongot must use to generate embeddings at index- and query-time. The Secret must contain the index-time key under the indexing-key key and the query-time key under the query-key key.

You can omit embeddingModelAPIKeySecret only if spec.autoEmbedding.providerEndpoint points to the operator-managed, self-hosted Voyage AI embedding service. Otherwise, the Kubernetes Operator requires it.

spec.autoEmbedding.providerEndpoint

Type: string

Embedding model endpoint URL for generating embeddings. Value varies based on whether you create the keys from the Atlas UI (recommended) or directly from the embedding service (Voyage AI). For keys created from:

  • Atlas UI, value is https://ai.mongodb.com/v1/embeddings (default)

  • Voyage AI, value is https://api.voyageai.com/v1/embeddings

spec.featureFlags

Type: object

Feature flags for mongot. If you set a flag to true, the Kubernetes Operator renders it into the mongot configuration. If you omit the featureFlags object or an individual flag, the schema default for that flag applies (true for enableOverloadRetrySignal).

spec.featureFlags.enableOverloadRetrySignal

Type: boolean

Enables the mongot overload retry signal. If you enable this flag, mongot signals load shedding to upstream proxies (such as the operator-managed Envoy load balancer) through gRPC RESOURCE_EXHAUSTED responses. The proxies then retry the request on another mongot instance.

If omitted, defaults to true.

spec.version

Type: string

Version of the mongodb-search Docker image. If omitted, the Kubernetes Operator uses the default MongoDB Search version bundled with it. You can set the version explicitly to prevent automatic upgrades when you upgrade the Kubernetes Operator.

The Kubernetes Operator reports status information under the status field of the MongoDBSearch resource.

status.phase

Type: string

Current phase of the MongoDBSearch resource. Possible values include Pending, Running, Failed, Disabled, Updated, and Unsupported.

This field is visible in kubectl get output under the PHASE column.

status.message

Type: string

Human-readable message with details about the current status, such as the reason the resource is in a Pending or Failed phase.

status.lastTransition

Type: string

Timestamp of the last transition of status.phase.

status.observedGeneration

Type: integer

Generation of the MongoDBSearch resource that the Kubernetes Operator last processed.

status.warnings

Type: array of strings

Warnings that the Kubernetes Operator reports for the resource.

status.version

Type: string

Version of MongoDB Search (mongot) that the Kubernetes Operator reconciled.

This field is visible in kubectl get output under the VERSION column.

status.resourcesNotReady

Type: array of objects

Dependent Kubernetes resources that are not yet ready. Each entry reports the kind and name of the resource and an optional message and list of errors.

status.pvc

Type: array of objects

State of the persistent volume claims of the mongot StatefulSets. Each entry reports the phase and the statefulsetName that the claims belong to.

status.loadBalancer

Type: object

Status of the operator-managed load balancer (Envoy). This field is present only if you set spec.clusters[].loadBalancer.managed. For multi-cluster deployments, the Kubernetes Operator reports the worst phase across the Envoy deployments of all clusters.

status.loadBalancer.phase

Type: string

Current phase of the managed load balancer. Possible values include Pending, Running, and Failed. The Kubernetes Operator reports this phase independently of the main status.phase, so you can monitor the Envoy deployment separately.

This field is also visible in kubectl get output under the LOADBALANCER column.

status.loadBalancer.message

Type: string

Human-readable message with details about the managed load balancer status.

status.metricsForwarder

Type: object

Status of the metrics forwarder.

status.metricsForwarder.phase

Type: string

Current phase of the metrics forwarder. Possible values include Pending, Running, and Failed. The phase reports Disabled if you set spec.observability.metricsForwarder.mode to disabled.

This field is also visible in kubectl get output under the METRICSFORWARDER column.

status.metricsForwarder.message

Type: string

Human-readable message with details about the metrics forwarder status.

Example

$ kubectl get mdbs
NAME PHASE VERSION LOADBALANCER METRICSFORWARDER AGE
mdb-rs-ext-lb-search Running 1.70.1 Running Running 14m