The MongoDBSearch custom resource lets you deploy and configure
MongoDB Search and Vector Search nodes alongside your MongoDB database
deployments in Kubernetes. The MongoDBSearch resource deploys mongot
processes that provide full-text and semantic search capabilities by
syncing data from your MongoDB deployment.
To learn more about deploying MongoDB Search and Vector Search, see Deploy MongoDB Search and Vector Search.
Example
The following example shows a resource specification for a
MongoDBSearch custom resource:
1 spec: 2 source: 3 mongodbResourceRef: 4 name: mdb 5 external: 6 hostAndPorts: 7 - mdb-rs-external-0.example.com:27017 8 - mdb-rs-external-1.example.com:27017 9 - mdb-rs-external-2.example.com:27017 10 shardedCluster: 11 router: 12 hosts: 13 - mongos1.example.com:27017 14 - mongos2.example.com:27017 15 shards: 16 - shardName: shard-0 17 hosts: 18 - shard0-node1.example.com:27018 19 - shard0-node2.example.com:27018 20 - shardName: shard-1 21 hosts: 22 - shard1-node1.example.com:27018 23 - shard1-node2.example.com:27018 24 tls: 25 ca: 26 name: mdbc-rs-ca 27 username: search-sync-source 28 passwordSecretRef: 29 name: mdbc-rs-search-sync-source-password 30 key: password 31 # x509 authentication (mutually exclusive with 32 # username/passwordSecretRef) 33 x509: 34 clientCertificateSecretRef: 35 name: mongot-x509-client-cert 36 replicas: 2 37 loadBalancer: 38 # Option 1: Operator-managed Envoy load balancer 39 managed: 40 externalHostname: "search.apps.example.com" 41 resourceRequirements: 42 requests: 43 cpu: "100m" 44 memory: 128Mi 45 limits: 46 cpu: "500m" 47 memory: 512Mi 48 deployment: 49 spec: 50 template: 51 spec: 52 nodeSelector: 53 kubernetes.io/os: linux 54 # Option 2: User-provided (BYO) load balancer 55 # (mutually exclusive with managed) 56 unmanaged: 57 endpoint: "search-lb.corp.example.com:443" 58 security: 59 tls: 60 certificateKeySecretRef: 61 name: mdbs-tls-secret 62 certsSecretPrefix: my-prefix 63 resourceRequirements: 64 limits: 65 cpu: "3" 66 memory: 5Gi 67 requests: 68 cpu: "2" 69 memory: 3Gi 70 persistence: 71 single: 72 storage: 16Gi 73 storageClass: standard 74 version: "0.64.0" 75 statefulSet: 76 spec: 77 template: 78 spec: 79 nodeSelector: 80 kubernetes.io/os: linux 81 jvmFlags: 82 - -Xms2g 83 - -Xmx2g 84 autoEmbedding: 85 embeddingModelAPIKeySecret: 86 name: embedding-model-api-query-key 87 providerEndpoint: https://ai.mongodb.com/v1/embeddings 88 logLevel: INFO 89 prometheus: {}
Required MongoDBSearch Resource Settings
This section describes settings that you must use for all
MongoDBSearch resources.
apiVersionType: string
Version of the MongoDB Kubernetes resource schema. Set the value to
mongodb.com/v1.
kindType: string
Kind of MongoDB Kubernetes resource to create. Set this to
MongoDBSearch.
metadata.namespaceType: string
Namespace where the
MongoDBSearchresource should be created. To leverage automatic configuration ofMongoDBSearchandMongoDBorMongoDBCommunityresources, theMongoDBSearchresource should be created in the same namespace as theMongoDBorMongoDBCommunityresource.
metadata.nameType: string
Unique identifier of the
MongoDBSearchresource.Resource names must be 44 characters or less.
Optional MongoDBSearch Resource Settings
The MongoDBSearch custom resource can use the following settings:
Data Source Settings
spec.sourceType: 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:MongoDBis externalMongoDBhas a different name fromMongoDBSearch
The
MongoDBSearchresource must always be connected to a MongoDB deployment. If you deployed using the Kubernetes Operator withMongoDBorMongoDBCommunityCRD, and ifspec.sourceis empty, the Kubernetes Operator uses the following based on themetadata.nameto look for the database in Kubernetes:Find
MongoDBorMongoDBCommunityresources with the same name as set formetadata.nameinMongoDBSearch, in the same namespace.Find the password secret for the
mongotuser from the<MongoDBSearch.metadata.name>-search-sync-source-passwordsecret.
spec.source.mongodbResourceRef.nameType: string
Name of the
MongoDBorMongoDBCommunityresource 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 oneMongoDBSearchresource referencing the sameMongoDBorMongoDBCommunityresource.Use this field only if your
MongoDBorMongoDBCommunityresource is deployed in the same Kubernetes cluster and is in the same namespace as yourMongoDBSearchresource.spec.source.usernameType: string
Username to use to authenticate
mongotwithmongod. The specified user must have thesearchCoordinatorrole. If omitted, the Kubernetes Operator assumes the username issearch-sync-source.spec.source.passwordSecretRef.nameType: string
Name of the secret that contains the password that
mongotmust use to authenticate withmongod. If omitted, defaults to<MongoDBSearch.metadata.name>-search-sync-source-password.spec.source.passwordSecretRef.keyType: string
Key under which the password value is stored in the secret. If omitted, defaults to
password.
x509 Authentication Settings
spec.source.x509Type: object
Configures x509 client certificate authentication for the
mongotsync source connection. If you set this field,mongotauthenticates to MongoDB using x509 instead of username and password.This field is mutually exclusive with
spec.source.passwordSecretRefandspec.source.username.spec.source.x509.clientCertificateSecretRefType: 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 (required)tls.key— Private key (required)tls.keyFilePassword— Password for the private key (optional)
External MongoDB Settings
spec.source.externalType: object
Settings that describe the external data source. Specify these settings only if you want to connect to an external MongoDB that wasn't deployed using the Kubernetes Operator.
spec.source.external.hostAndPortsType: array of strings
List of hostnames and ports of the external replica set. This field is mutually exclusive with
spec.source.external.shardedCluster.spec.source.external.shardedClusterType: object
Declares an external sharded MongoDB cluster as the data source for
mongot. Contains configuration formongosrouters and per-shard replica set members.spec.source.external.shardedCluster.router.hostsType: array of strings
List of endpoints for the
mongosrouter instances inhost:portformat.spec.source.external.shardedCluster.shardsType: array of objects
List of all shards in the external MongoDB cluster. Each entry describes one shard's replica set.
spec.source.external.shardedCluster.shards[*].shardNameType: string
The logical name of the shard.
spec.source.external.shardedCluster.shards[*].hostsType: array of strings
List of endpoints of the
mongodreplica set members for this shard in thehost:portformat.spec.source.external.tls.ca.nameType: string
Name of the Secret containing the trusted chain of the certificate authorities that issued the TLS certificate used by the
mongodnodes.
Security Settings
spec.securityType: object
Security settings for
mongotlisten server.spec.security.tlsType: object
TLS settings for
mongot. If omitted,mongotwon't use TLS for incoming connections.spec.security.tls.certificateKeySecretRef.nameType: string
Deprecated since version 1.8.0: Use
spec.security.tls.certsSecretPrefixinstead.Name of the TLS secret in the same namespace containing the private key (
tls.key) and the certificate (tls.crt).spec.security.tls.certsSecretPrefixType: string
Prefix that the Kubernetes Operator uses to derive TLS secret names by naming convention.
Replica and Load Balancer Settings
spec.replicasType: integer
Number of
mongotpods to deploy. For a replica set source, this is the total number ofmongotpods. For a sharded cluster source, this is the number ofmongotpods per shard.If
spec.replicasis greater than1, you must also configurespec.loadBalancerto route traffic betweenmongodand the multiplemongotinstances.If omitted, defaults to
1.spec.loadBalancerType: object
Configuration for L7 load balancing between
mongod(ormongos) andmongot. This field is required ifspec.replicasis greater than1.Exactly one of
managedorunmanagedmust be set.spec.loadBalancer.managedType: object
Configures an operator-managed Envoy load balancer. This field is mutually exclusive with
spec.loadBalancer.unmanaged.spec.loadBalancer.managed.externalHostnameType: string
Hostname that the Envoy proxy expects for SNI matching on incoming requests.
spec.loadBalancer.managed.resourceRequirementsType: core/v1/ResourceRequirements
CPU and memory that the Envoy container can request and be limited to.
spec.loadBalancer.managed.deploymentType: object
Overrides that the Kubernetes Operator merges into the operator-created Envoy Deployment.
spec.loadBalancer.unmanagedType: object
Configures a user-provided (Bring Your Own) L7 load balancer. This field is mutually exclusive with
spec.loadBalancer.managed.spec.loadBalancer.unmanaged.endpointType: string
The endpoint of the BYO load balancer in
host:portformat.
Resource Settings
spec.resourceRequirementsType: core/v1/ResourceRequirements
CPU and memory that the
mongodb-searchcontainer can request and be limited to.If omitted, the Kubernetes Operator uses the following default values:
requests: cpu: 2 memory: 2G spec.resourceRequirements.limitsType: object
Upper cap on the resource, CPU and memory, that the
mongodb-searchcontainer can consume.spec.resourceRequirements.requestsType: object
Amount of CPU and memory requested for the
mongodb-searchcontainer.
Persistence Settings
spec.persistence.singleType: object
Storage configuration for MongoDB Search and Vector Search persistence volume where indexes are stored. Each search instance (pod) has its own independent storage.
ScalarData TypeDescriptionlabelSelectorstring
Tag used to bind mounted volumes to directories.
storagestring
Minimum size of Persistent Volume that should be mounted. Default value is
10GB.storageClassstring
Type of storage specified in a Persistent Volume Claim.
Logging Settings
spec.logLevelType: string
Verbosity of the
mongotlogs. Value can be one of the following:TRACEDEBUGINFOWARNERROR
If omitted, defaults to
INFO.
Metrics Settings
spec.prometheusType: object
Configuration to enable Prometheus metrics endpoint. If omitted, the metrics endpoint in
mongotis disabled.spec.prometheus.portType: string
Port on which to enable Prometheus metrics endpoint. By default, Prometheus metrics endpoint is enabled on port
9946.
Automated Embedding Settings
Important
Automated embedding is available as a Preview feature for only 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.autoEmbeddingType: object
Configuration for automated embedding for text data in your collection.
spec.autoEmbedding.embeddingModelAPIKeySecret.nameType: string
Name of the secret that contains the embedding model API keys that
mongotmust use to generate embeddings at index- and query-time.spec.autoEmbedding.providerEndpointType: string
Embedding model endpoint URL for generating embeddings.
JVM Configuration Settings
spec.jvmFlagsType: array of strings
JVM flags passed to the
mongotprocess. If you don't specify-Xmsor-Xmxin this field, the Kubernetes Operator auto-calculates heap size by setting both to half ofspec.resourceRequirements.requests.memory.
Other Settings
spec.versionType: string
Version of
mongodb-searchdocker image. If omitted, the Kubernetes Operator automatically chooses the newest version of MongoDBSearch.spec.statefulSetType: apps/v1/StatefulSet
Specification for the StatefulSet created for deploying
mongotpods, that overwrites the settings that the Kubernetes Operator applies.Note
Don't set resource requirements or persistence settings using
spec.statefulSet. Instead, use thespec.resourceRequirementsandspec.persistencefields respectively.
Status Fields
The Kubernetes Operator reports status information under the
status field of the MongoDBSearch resource.
status.loadBalancerType: object
Status of the operator-managed load balancer (Envoy). This field is present only when
spec.loadBalancer.managedis set.status.loadBalancer.phaseType: string
Current phase of the managed load balancer. Possible values include
Pending,Running, andFailed.