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.

MongoDBCommunity Resource Specification

The MongoDBCommunity custom resource lets you deploy and manage MongoDB Community Edition replica sets in Kubernetes. The Kubernetes Operator uses this resource to create statefulSets, services, and other Kubernetes resources required to run MongoDB Community deployments.

To learn more, see the MongoDB Community Operator documentation.

The following example shows a resource specification for a MongoDBCommunity custom resource:

apiVersion: mongodbcommunity.mongodb.com/v1kind: MongoDBCommunitymetadata: name: my-mongodb-communityspec: version: "8.0.0" type: ReplicaSet members: 3 security: tls: enabled: true certificateKeySecretRef: name: mongodb-tls-cert caConfigMapRef: name: mongodb-ca authentication: ignoreUnknownUsers: true modes: - SCRAM agent: logLevel: DEBUG statefulSet: spec: template: spec: containers: - name: mongod resources: limits: cpu: "2" memory: 2Gi requests: cpu: "1" memory: 1Gi - name: mongodb-agent resources: limits: cpu: "1" memory: 2Gi requests: cpu: "0.5" memory: 1Gi users: - name: mdb-admin db: admin passwordSecretRef: name: mdb-admin-user-password scramCredentialsSecretName: mdb-admin-user roles: - name: root db: admin

This section describes settings that you must use for all MongoDBCommunity resources.

apiVersion

Type: string

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

kind

Type: string

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

metadata.name

Type: string

Human-readable name so you can identify this particular MongoDBCommunity resource.

Resource names must be 44 characters or less.

spec.version

Type: string

Version of MongoDB Community to deploy. For example, "8.0.0".

spec.type

Type: string

Type of MongoDB deployment to create. The accepted value is ReplicaSet.

spec.members

Type: integer

Number of replica set members. This determines how many mongod pods the Kubernetes Operator creates in the StatefulSet.

The MongoDBCommunity custom resource can use the following settings:

spec.security

Type: object

Security configuration for the MongoDBCommunity resource. Contains TLS and authentication settings.

spec.security.tls

Type: object

TLS settings for the MongoDB deployment.

spec.security.tls.enabled

Type: boolean

Flag to enable or disable TLS for the MongoDB deployment. Set to true to enable TLS-encrypted connections.

spec.security.tls.certificateKeySecretRef.name

Type: string

Name of the Kubernetes secret that contains the TLS server certificate and private key for the MongoDB deployment.

spec.security.tls.caConfigMapRef.name

Type: string

Name of the Kubernetes ConfigMap that contains the Certificate Authority (CA) certificate used to verify TLS connections.

spec.security.authentication

Type: object

Authentication configuration for the MongoDB deployment.

spec.security.authentication.modes

Type: array of strings

List of authentication mechanisms to enable on the MongoDB deployment. Accepted values include:

  • SCRAM
spec.security.authentication.ignoreUnknownUsers

Type: boolean

If true, the Kubernetes Operator doesn't report an error for users that exist in the MongoDB deployment but are not defined in the MongoDBCommunity resource specification.

Default: false.

spec.agent

Type: object

Configuration settings for the MongoDB Agent.

spec.agent.logLevel

Type: string

Verbosity level of the MongoDB Agent logs. Accepted values include:

  • DEBUG

  • INFO

  • WARN

  • ERROR

spec.statefulSet

Type: object

Specification for the StatefulSet created by the Kubernetes Operator for your MongoDBCommunity resource. Use this to override default container resource requests and limits.

spec.statefulSet.spec

Type: object

StatefulSet specification that the Kubernetes Operator merges with generated defaults. Follows the standard Kubernetes StatefulSet spec.

spec.statefulSet.spec.template.spec.containers

Type: array of objects

List of container overrides. You can override resource requests and limits for the following containers:

  • mongod — The MongoDB database container.

  • mongodb-agent — The MongoDB Agent sidecar container.

containers: - name: mongod resources: limits: cpu: "2" memory: 2Gi requests: cpu: "1" memory: 1Gi - name: mongodb-agent resources: limits: cpu: "1" memory: 2Gi requests: cpu: "0.5" memory: 1Gi
spec.users

Type: array of objects

List of MongoDB database users to create for this deployment. Each user object defines the credentials and roles for a database user.

spec.users[*].name

Type: string

Username for the MongoDB database user.

spec.users[*].db

Type: string

Authentication database for the user. The default is admin.

spec.users[*].passwordSecretRef.name

Type: string

Name of the Kubernetes secret that contains the password for this database user.

spec.users[*].scramCredentialsSecretName

Type: string

Name of the secret where the Kubernetes Operator stores the generated SCRAM credentials for this user.

spec.users[*].roles

Type: array of objects

List of roles to assign to this database user.

spec.users[*].roles[*].name

Type: string

Name of the role to assign. For example, root, readWrite, readAnyDatabase, or searchCoordinator.

spec.users[*].roles[*].db

Type: string

Database on which the role applies. For example, admin.

You can deploy MongoDB Search and Vector Search alongside a MongoDBCommunity resource using the MongoDBSearch CRD. To enable search functionality, create a search-sync-source user with the searchCoordinator role:

users: - name: search-sync-source db: admin passwordSecretRef: name: my-resource-search-sync-source-password scramCredentialsSecretName: my-resource-search-sync-source roles: - name: searchCoordinator db: admin

Note

For MongoDB 8.2 and later, searchCoordinator is a built-in role. For earlier versions, the Kubernetes Operator creates the searchCoordinator custom role automatically.

To learn more, see Deploy MongoDB Search and Vector Search.