|
| 1 | +--- |
| 2 | +title: "MongoDB Replicated Cluster" |
| 3 | +weight: 3 |
| 4 | +linkTitle: "MongoDB Replicated Cluster" |
| 5 | +description: > |
| 6 | + MongoDB replicated cluster configuration for CRD and helm chart |
| 7 | +--- |
| 8 | + |
| 9 | +MongoDB cluster configuration is easily customizable using `helm` as well `kubectl`. Since all the configurations are in the form YAML file, it can be easily changed and customized. |
| 10 | + |
| 11 | +The `values.yaml` file for MongoDB cluster setup can be found [here](https://github.com/OT-CONTAINER-KIT/helm-charts/tree/main/charts/mongodb-cluster). But if the setup is not done using `Helm`, in that case Kubernetes manifests needs to be customized. |
| 12 | + |
| 13 | +## Parameters for Helm Chart |
| 14 | + |
| 15 | +| **Name** | **Value** | **Description** | |
| 16 | +|-------------------------------------------|:------------------------:|---------------------------------------------------| |
| 17 | +| `clusterSize` | 3 | Size of the MongoDB cluster | |
| 18 | +| `image.name` | quay.io/opstree/mongo | Name of the MongoDB image | |
| 19 | +| `image.tag` | v5.0 | Tag for the MongoDB image | |
| 20 | +| `image.imagePullPolicy` | IfNotPresent | Image Pull Policy of the MongoDB | |
| 21 | +| `resources` | {} | Request and limits for MongoDB statefulset | |
| 22 | +| `storage.enabled` | true | Storage is enabled for MongoDB or not | |
| 23 | +| `storage.accessModes` | ["ReadWriteOnce"] | AccessMode for storage provider | |
| 24 | +| `storage.storageSize` | 1Gi | Size of storage for MongoDB | |
| 25 | +| `storage.storageClass` | gp2 | Name of the storageClass to create storage | |
| 26 | +| `mongoDBMonitoring.enabled` | true | MongoDB exporter should be deployed or not | |
| 27 | +| `mongoDBMonitoring.image.name` | bitnami/mongodb-exporter | Name of the MongoDB exporter image | |
| 28 | +| `mongoDBMonitoring.image.tag` | 0.11.2-debian-10-r382 | Tag of the MongoDB exporter image | |
| 29 | +| `mongoDBMonitoring.image.imagePullPolicy` | IfNotPresent | Image Pull Policy of the MongoDB exporter image | |
| 30 | +| `serviceMonitor.enabled` | false | Servicemonitor to monitor MongoDB with Prometheus | |
| 31 | +| `serviceMonitor.interval` | 30s | Interval at which metrics should be scraped. | |
| 32 | +| `serviceMonitor.scrapeTimeout` | 10s | Timeout after which the scrape is ended | |
| 33 | +| `serviceMonitor.namespace` | monitoring | Namespace in which Prometheus operator is running | |
| 34 | + |
| 35 | +## Parameters for CRD Object Definition |
| 36 | + |
| 37 | +These are the parameters that are currently supported by the MongoDB operator for the cluster MongoDB database setup:- |
| 38 | + |
| 39 | +- clusterSize |
| 40 | +- kubernetesConfig |
| 41 | +- storage |
| 42 | +- mongoDBSecurity |
| 43 | +- mongoDBMonitoring |
| 44 | + |
| 45 | +### clusterSize |
| 46 | + |
| 47 | +`clusterSize` is the size of MongoDB replicated cluster. We have to provide the number of node count that we want to make part of MongoDB cluster. For example:- 1 primary and 2 secondary is 3 as pod count. |
| 48 | + |
| 49 | +```yaml |
| 50 | + clusterSize: 3 |
| 51 | +``` |
| 52 | +
|
| 53 | +### kubernetesConfig |
| 54 | +
|
| 55 | +`kubernetesConfig` is the general configuration paramater for MongoDB CRD in which we are defining the Kubernetes related configuration details like- image, tag, imagePullPolicy, and resources. |
| 56 | + |
| 57 | +```yaml |
| 58 | + kubernetesConfig: |
| 59 | + image: quay.io/opstree/mongo:v5.0 |
| 60 | + imagePullPolicy: IfNotPresent |
| 61 | + resources: |
| 62 | + requests: |
| 63 | + cpu: 1 |
| 64 | + memory: 8Gi |
| 65 | + limits: |
| 66 | + cpu: 1 |
| 67 | + memory: 8Gi |
| 68 | +``` |
| 69 | + |
| 70 | +### storage |
| 71 | + |
| 72 | +`storage` is the storage specific configuration for MongoDB CRD. With this parameter we can make enable persistence inside the MongoDB statefulset. In this parameter, we will provide inputs like- accessModes, size of the storage, and storageClass. |
| 73 | + |
| 74 | +```yaml |
| 75 | + storage: |
| 76 | + accessModes: ["ReadWriteOnce"] |
| 77 | + storageSize: 1Gi |
| 78 | + storageClass: csi-cephfs-sc |
| 79 | +``` |
| 80 | + |
| 81 | +### mongoDBSecurity |
| 82 | + |
| 83 | +`mongoDBSecurity` is the security specification for MongoDB CRD. If we want to enable our MongoDB database authenticated, in that case, we can enable this configuration. To enable the authentication we need to provide paramaters like- admin username, secret reference in Kubernetes. |
| 84 | + |
| 85 | +```yaml |
| 86 | + mongoDBSecurity: |
| 87 | + mongoDBAdminUser: admin |
| 88 | + secretRef: |
| 89 | + name: mongodb-secret |
| 90 | + key: password |
| 91 | +``` |
| 92 | + |
| 93 | +### mongoDBMonitoring |
| 94 | + |
| 95 | +`mongoDBMonitoring` is the monitoring feature for MongoDB CRD. By using this parameter we can enable the MongoDB monitoring using **[MongoDB Exporter](https://github.com/percona/mongodb_exporter)**. In this parameter, we need to provide image, imagePullPolicy and resources for mongodb exporter. |
| 96 | + |
| 97 | +```yaml |
| 98 | + mongoDBMonitoring: |
| 99 | + enableExporter: true |
| 100 | + image: bitnami/mongodb-exporter:0.11.2-debian-10-r382 |
| 101 | + imagePullPolicy: IfNotPresent |
| 102 | + resources: {} |
| 103 | +``` |
0 commit comments