You can deploy MongoDB Search and Vector Search alongside MongoDB v8.0 or higher using MongoDB Controllers for Kubernetes Operator.
Example Resource Specification
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.
Example
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 keyfileSecretRef: 11 name: mdbc-rs-keyfile 12 key: keyfile 13 tls: 14 ca: 15 name: mdbc-rs-ca 16 username: search-sync-source 17 passwordSecretRef: 18 name: mdbc-rs-search-sync-source-password 19 key: password 20 security: 21 tls: 22 certificateKeySecretRef: 23 name: mdbs-tls-secret 24 resourceRequirements: 25 limits: 26 cpu: "3" 27 memory: 5Gi 28 requests: 29 cpu: "2" 30 memory: 3Gi 31 logLevel: INFO
Required Settings
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.
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. The resource name can be a maximum of 44 characters in length.
Optional Settings
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.sourceType: object
Setting that describes the MongoDB source replica set for
mongot. This is required if:MongoDBis externalMongoDBhas a different name fromMongoDBSearch
The
MongoDBSearchresource must always be connected to the replica set. If you deployed the replica set 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 theMongoDBSearch.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. You can't have more than oneMongoDBSearchresource referencing the sameMongoDBorMongoDBCommunityresource. If you specify a different name, you must explicitly point to theMongoDBorMongoDBCommunitywhere you want to enable MongoDB Search and Vector Search.Use this field only if your
MongoDBorMongoDBCommunityresource is deployed in the same Kubernetes cluster and is in the same namespace as yourMongoDBSearchresource. Setting this field allows the Kubernetes Operator to automatically:Set proper connection strings to the database.
Reconfigure MongoDB database deployments by setting necessary parameters to enable search functionality and configure the addresses of the search pods.
If your database is deployed outside of Kubernetes or is in a different namespace, use
spec.externalto configure connection to the database. This field is mutually exclusive withspec.external.If omitted, the Kubernetes Operator will look for
MongoDBorMongoDBCommunityresource with the same name as thisMongoDBSearchresource.
spec.source.externalType: 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. These settings should be specified only if you want to connect to an external MongoDB that wasn't deployed using the Kubernetes Operator. If specified, these settings override settings for
spec.source.mongodbResourceRef.name. If you used the Kubernetes Operator to install MongoDB in the same cluster, these settings are optional.
spec.source.external.hostAndPortsType: 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
mongotconnects to the database in a replica set mode and gets the list of all other nodes usingdb.hello().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.keyfileSecretRefType: object
Reference to the Kubernetes secret that contains the keyfile for internal cluster authentication.
spec.source.external.keyfileSecretRef.nameType: string
Name of keyfile used to authenticate
mongodtomongot. The specified secret name must contain the same keyfile that is used by the MongoDB replica set members for internal communication.
spec.source.external.keyfileSecretRef.keyType: string
Contents of the keyfile as string.
Tip
You can find keyfile in the
auth.keyfield of the automation config for your Cloud Manager or Ops Manager instance.
spec.source.external.tlsType: object
TLS Settings that
mongotmust use when connecting to the external MongoDB database.
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.Example
spec: source: external: tls: ca: name: trusted-ca The certificate (or certificates if this is a chain of trusted CA certificates) must be specified under
ca.crtkey in this Secret.Example
name: Secret apiVersion: v1 metadata: name: trusted-ca data: ca.crt: | -----BEGIN CERTIFICATE----- MIIDBTCCAe2gAwIBAgIIH3EOUAGAsx0wDQYJKoZIhvcNAQELBQAwFTETMBEGA1UE [...] U/4rN8Ias/FONYFRtGfs9uXHmo2MP04BF+9ED2dlbNDUbat+6XCozLJj98nI4VEi qaV3JrVFHTgN -----END CERTIFICATE-----
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.
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
Name of a TLS secret in the same namespace containing private key (
tls.key) and the certificate (tls.crt). The secret can be of typekubernetes.io/tls(that is issued by cert-manager) or can be created manually. This is required for enabling TLS inmongot.
spec.resourceRequirementsType: core/v1/ResourceRequirements
CPU and memory that the
mongodb-searchcontainer can request and be limited to. We recommend using this field to customize resource allocations instead of overriding it withspec.statefulSet.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. By default, there are no limits 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.resourceRequirements.requestsType: object
Amount of CPU and memory requested for the
mongodb-searchcontainer. If omitted, the Kubernetes Operator uses the following default values:requests: cpu: 2 memory: 2G
spec.logLevelType: string
Verbosity of the
mongotlogs. Value can be one of the following:TRACEDEBUGINFOWARNERROR
If omitted, defaults to
INFO.
spec.persistence.singleType: 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.
ScalarData TypeDescriptionlabelSelectorstring
Tag used to bind mounted volumes to directories.
storagestring
Minimum size of Persistent Volume that should be mounted. This value is expressed as an integer followed by a unit of storage in JEDEC notation.
Default value is 16Gi.
For example, if replica set requires 60 gigabytes of storage space, set this value to
60Gi.storageClassstring
Type of storage specified in a Persistent Volume Claim. You may create this storage type as a StorageClass object before using it in this object specification.
Make sure to set the StorageClass
reclaimPolicyto Retain. This ensures that data is retained when a Persistent Volume Claim is removed.MongoDBSearchsupports onlysinglepersistence field. If omitted, the Kubernetes Operator setsspec.persistence.single.storageto10GB.
spec.versionType: string
Version of
mongodb-searchdocker image. If omitted, the Kubernetes Operator automatically chooses the newest version ofMongoDBSearch. You can set it explicitly to prevent automatic upgrades when the Kubernetes Operator version is upgraded.
spec.statefulSetType: apps/v1/StatefulSet
Specification for the StatefulSet, created for deploying
mongotpods, that overwrites the settings that the Kubernetes Operator applies. The overrides are always applied last. Supports both thespec.statefulSet.specandspec.statefulSet.metadatafields.Note
Don't set resource requirements or persistence settings using
spec.statefulSet. Instead, use thespec.resourceRequirementsandspec.persistencefields respectively.