Docs Menu
Docs Home
MongoDB Enterprise Kubernetes Operator

Configure Storage Options for MongoDB Resources

On this page

  • Prerequisites
  • Procedure

You can configure your MongoDB resources to bind to specific storage in your MongoDB CustomResourceDefinition. The persistence field in the MongoDB CustomResourceDefinition allows you to more precisely manage where Kubernetes stores the logs and metadata generated from MongoDB custom resources. Controlling log and metadata storage allows you to have more fine-grained control of processes that manage and interact with this generated metadata.

You can configure persistence settings per component in the MongoDB CustomResourceDefinition. These settings allow you to specify the relationship between a given component and one or more related PersistentVolume resources, which store output from your MongoDB custom resources.

The persistence setting specifies the number of and storage capacity of persistentVolumes associated with MongoDB custom resource-managed objects in your Kubernetes cluster.

To configure storage options for your MongoDB deployment, you must either have a MongoDB replica set deployed through the MongoDB Kubernetes Operator or meet the following prerequisites:

  • An Ops Manager instance or a Cloud Manager organization.

  • The MongoDB Enterprise Kubernetes Operator.

  • A Kubernetes Operator ConfigMap.

  • Credentials for the Kubernetes Operator or configure a different secret storage tool.

To create a single PersistentVolume in which a given component will store all MongoDB CustomResourceDefinition output, define the component's persistence as single. To create a distinct PersistentVolume for the component's data, journal, and logs, define the component's persistence as multiple.


Populate the persistence sections of your MongoDB CRD definition as shown in the following example:

3kind: MongoDB
5 name: my-sharded-cluster
7 shardCount: 2
8 mongodsPerShardCount: 3
9 mongosCount: 2
10 configServerCount: 3
11 version: "6.0.0"
12 service: my-service
13 type: ShardedCluster
15 persistent: true
17 configSrvPodSpec:
18 persistence:
19 single: true
21 shardPodSpec:
22 persistence:
23 multiple:
24 # if the child of "multiple" is omitted then the default size will be used.
25 # 16GB for "data", 1GB for "journal", 3GB for "logs"
26 data:
27 storage: "20Gi"
28 logs:
29 storage: "4Gi"
30 storageClass: standard
kubectl apply -f mongodb-crd.yaml


Configure Cluster Topology for MongoDB Resources


Manage Database Users