|
| 1 | +.. _meko-om-arch: |
| 2 | + |
| 3 | +============================== |
| 4 | +|onprem| Architecture in |k8s| |
| 5 | +============================== |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +You can use the |k8s-op-short| to deploy |onprem| and MongoDB resources |
| 16 | +to a |k8s| cluster. The |k8s-op-short| manages the lifecycle of each of |
| 17 | +these deployments differently. |
| 18 | + |
| 19 | +The ``MongoDBOpsManager`` Custom Resource Definition |
| 20 | +---------------------------------------------------- |
| 21 | + |
| 22 | +The |k8s-op-short| manages |onprem| deployments using the |
| 23 | +``MongoDBOpsManager`` |k8s-custom-resource|. The |k8s-op-short| watches |
| 24 | +the custom resource's specification for changes. When the |
| 25 | +specification changes, the |k8s-op-short| validates the changes and |
| 26 | +makes the appropriate updates to the resources in the |k8s| cluster. |
| 27 | + |
| 28 | +``MongoDBOpsManager`` |k8s-custom-resource|\s specification defines the |
| 29 | +following |onprem| components: |
| 30 | + |
| 31 | +- the Application Database, |
| 32 | +- the |onprem| application, and |
| 33 | +- the Backup Daemon. |
| 34 | + |
| 35 | +.. figure:: /images/meko-arch.svg |
| 36 | + :alt: Diagram showing the high-level architecture of the MongoDB |
| 37 | + Enterprise Kubernetes Operator |
| 38 | + :figwidth: 600px |
| 39 | + |
| 40 | +Application Database |
| 41 | +~~~~~~~~~~~~~~~~~~~~ |
| 42 | + |
| 43 | +For the Application Database, the |k8s-op-short| deploys a MongoDB |
| 44 | +replica set as a |k8s-statefulset| to the |k8s| cluster. |k8s| creates |
| 45 | +one Pod in the StatefulSet for each member |
| 46 | +that comprises your Application Database replica set. Each Pod in |
| 47 | +the StatefulSet runs a {+mdbagent+} instance. |
| 48 | + |
| 49 | +By default, each {+mdbagent+} starts the bundled |mongod| on its |
| 50 | +Pod in the StatefulSet. If you want to use a specific MongoDB Server |
| 51 | +version for the Application Database instead, specify the version that |
| 52 | +you want to start using the :opsmgrkube:`spec.applicationDatabase.version` |
| 53 | +setting. Each {+mdbagent+} downloads the |mongod| version you |
| 54 | +specify from the Internet and starts it on its Pod in the StatefulSet. |
| 55 | + |
| 56 | +After each {+mdbagent+} starts |mongod|\s on its Application Database |
| 57 | +Pod, the {+mdbagent+}\s add all |mongod| processes to the Application |
| 58 | +Database replica set. |
| 59 | + |
| 60 | +You configure the number of replicas in and other |
| 61 | +configuration options for the Application Database replica set in the |
| 62 | +:opsmgrkube:`spec.applicationDatabase` collection in the |
| 63 | +``MongoDBOpsManager`` custom resource. The |k8s-op-short| passes |
| 64 | +this configuration to the {+mdbagent+}\s using a |k8s-secret| that the |
| 65 | +|k8s-op-short| mounts to each Pod in the Application Database StatefulSet. |
| 66 | + |
| 67 | +Each time that you update |
| 68 | +the :opsmgrkube:`spec.applicationDatabase` collection, the |
| 69 | +|k8s-op-short| applies the changes to the {+mdbagent+} configuration and |
| 70 | +the StatefulSet specification, if applicable. If the StatefulSet |
| 71 | +specification changes, |k8s| upgrades the Pods in a rolling |
| 72 | +fashion and restarts each Pod. |
| 73 | + |
| 74 | +The |k8s-op-short| creates a |k8s-service| with ``clusterIp=none`` to |
| 75 | +provide connectivity to each Application Database Pod from within the |
| 76 | +|k8s| cluster. |
| 77 | + |
| 78 | +If you set :opsmgrkube:`spec.applicationDatabase.persistent` to |
| 79 | +**true**, the |k8s-op-short| creates a |k8s-pvc| for each Pod in the |
| 80 | +Application Database StatefulSet. |
| 81 | + |
| 82 | +.. note:: |
| 83 | + |
| 84 | + Depending on the |k8s-sc| or the environment to which you deploy the |
| 85 | + |k8s-op-short|, |k8s| might create the |k8s-pvs| using |
| 86 | + :k8sdocs:`dynamic volume provisioning </concepts/storage/dynamic-provisioning/>`. |
| 87 | + |
| 88 | +You can customize the |k8s-pvcs| for the Application Database Pods using |
| 89 | +the :opsmgrkube:`spec.applicationDatabase.podSpec.persistence.single |
| 90 | +<spec.applicationDatabase>` or |
| 91 | +:opsmgrkube:`spec.applicationDatabase.podSpec.persistence.multiple |
| 92 | +<spec.applicationDatabase>` options. |
| 93 | + |
| 94 | +|application| |
| 95 | +~~~~~~~~~~~~~ |
| 96 | + |
| 97 | +After the Application Database reaches a **Running** state, the |
| 98 | +|k8s-op-short| starts the |application|. For |onprem|, the |
| 99 | +|k8s-op-short| deploys a StatefulSet to the |k8s| cluster. |k8s| |
| 100 | +creates one Pod in the StatefulSet for each |onprem| replica that |
| 101 | +you want to deploy. Each Pod contains one |application| process. |
| 102 | + |
| 103 | +.. note:: |
| 104 | + |
| 105 | + :ref:`Deploy <deploy-om-container>` multiple |onprem| replicas to |
| 106 | + make your deployment highly available in the event of an |onprem| Pod |
| 107 | + failure. |
| 108 | + |
| 109 | +The |k8s-op-short| creates a |k8s-service| with ``clusterIp=none`` to |
| 110 | +allow clients deployed to the |k8s| cluster to connect to |onprem|. To |
| 111 | +allow clients external to the |k8s| cluster to connect to |onprem|, |
| 112 | +configure the :opsmgrkube:`spec.externalConnectivity` collection in the |
| 113 | +specification for your |onprem| deployment. |
| 114 | + |
| 115 | +Backup Daemon |
| 116 | +~~~~~~~~~~~~~ |
| 117 | + |
| 118 | +If :opsmgrkube:`spec.backup.enabled` is **true**, the |k8s-op-short| |
| 119 | +starts the Backup Daemon after the |application| reaches a **Running** |
| 120 | +stage. For the Backup Daemon, |k8s-op-short| deploys a StatefulSet |
| 121 | +to the |k8s| cluster. |k8s| creates one pod in the |
| 122 | +StatefulSet for the Backup Daemon. |
| 123 | + |
| 124 | +If you enable backup, you must provide additional fields in the |
| 125 | +:opsmgrkube:`spec.backup <spec.backup.enabled>` collection to configure: |
| 126 | +the :term:`oplog store <oplog store database>` and a :term:`blockstore |
| 127 | +<Backup Blockstore Database>` or an |s3| :term:`snapshot store <S3 |
| 128 | +Snapshot Store>`. |
| 129 | + |
| 130 | +If you enable backup, the |k8s-op-short| creates a |k8s-pvc| for the |
| 131 | +Backup Daemon's :term:`head database`. You can |
| 132 | +configure the head database using the :opsmgrkube:`spec.backup.headDB` |
| 133 | +setting. |
| 134 | + |
| 135 | +The |k8s-op-short| invokes |onprem| APIs to ensure that the |
| 136 | +|application|\'s backup configuration matches the one that you define in |
| 137 | +the custom resource definition. |
| 138 | + |
| 139 | +Reconciling the ``MongoDBOpsManager`` Custom Resource |
| 140 | +----------------------------------------------------- |
| 141 | + |
| 142 | +The following diagram describes how the |k8s-op-short| reconciles |
| 143 | +changes to the ``MongoDBOpsManager`` |k8s-crd|. |
| 144 | + |
| 145 | +.. figure:: /images/meko-reconciliation.svg |
| 146 | + :alt: Diagram describing how the MongoDB Enterprise Kubernetes |
| 147 | + Operator reconciles changes to the MongoDBOpsManager |
| 148 | + Custom Resource Definition |
| 149 | + :figwidth: 600px |
| 150 | + |
| 151 | +1. The |k8s-op-short| creates or updates the |
| 152 | + ``<om_resource_name>-db-config`` Secret. This secret contains |
| 153 | + the configurations that the {+mdbagent+} uses to start the |
| 154 | + Application Database replica set. |
| 155 | + |
| 156 | +2. The |k8s-op-short| creates or updates the ``<om_resource_name>-db`` |
| 157 | + Application Database StatefulSet. This StatefulSet contains at |
| 158 | + least three |k8s-pods|. |
| 159 | + |
| 160 | + - Each Pod runs one {+mdbagent+} instance. Each {+mdbagent+} starts a |
| 161 | + |mongod| instance on its pod. |
| 162 | + - The |k8s-op-short| mounts the ``<om_resource_name>-db-config`` |
| 163 | + Secret to each Pod. The {+mdbagent+} uses this secret to |
| 164 | + configure the Application Database replica set. |
| 165 | + |
| 166 | +3. The |k8s-op-short| creates or updates the ``<om_resource_name>`` |
| 167 | + StatefulSet. This StatefulSet contains one Pod for each |
| 168 | + |onprem| replica. Each |onprem| replica connects to the Application |
| 169 | + Database. |
| 170 | + |
| 171 | + .. note:: |
| 172 | + |
| 173 | + Most changes to the ``MongoDBOpsManager`` |k8s-custom-resource| |
| 174 | + trigger a rolling upgrade of the Pods in the |
| 175 | + ``<om_resource_name>`` StatefulSet. :ref:`Enabling TLS for the |
| 176 | + Application Database <secure-om-db-tls>` also triggers a rolling |
| 177 | + restart because the connection string to the Application Database |
| 178 | + changes. |
| 179 | + |
| 180 | + Changes to the following ``MongoDBOpsManager`` |
| 181 | + |k8s-custom-resource| collections don't trigger a rolling upgrade: |
| 182 | + |
| 183 | + - :opsmgrkube:`spec.backup <spec.backup.enabled>` |
| 184 | + - :opsmgrkube:`spec.applicationDatabase` |
| 185 | + |
| 186 | +4. The |k8s-op-short| invokes |onprem| APIs to create an admin user. |
| 187 | + The |k8s-op-short| saves this admin user's credentials in the |
| 188 | + ``<om_resource_name>-admin-key`` Secret. The |k8s-op-short| |
| 189 | + uses these credentials for all other |onprem| API invocations. |
| 190 | + |
| 191 | + .. note:: |
| 192 | + |
| 193 | + This reconciliation step happens only once: when you use the |
| 194 | + |k8s-op-short| to create an |onprem| resource. The |
| 195 | + |k8s-op-short| skips this step when it updates the resource. |
| 196 | + |
| 197 | +5. The |k8s-op-short| performs a rolling upgrade of the Pods in the |
| 198 | + ``<om_resource_name>-db`` Application Database StatefulSet |
| 199 | + to enable |onprem| to monitor it. |
| 200 | + |
| 201 | + .. note:: |
| 202 | + |
| 203 | + This reconciliation step happens only when you enable Monitoring |
| 204 | + for an application database for the first time. This happens most |
| 205 | + often when you deploy a new |onprem| resource. |
| 206 | + |
| 207 | +6. If :opsmgrkube:`spec.backup.enabled` is **true**, the |k8s-op-short| |
| 208 | + creates the ``<om_resource_name>-backup-daemon`` StatefulSet or |
| 209 | + verifies that it is running. The |k8s-op-short| mounts a |k8s-pv| for |
| 210 | + the head database. |
| 211 | + |
| 212 | + .. note:: |
| 213 | + |
| 214 | + The Backup Daemon connects to the same Application Database as the |
| 215 | + |onprem| deployment. |
| 216 | + |
| 217 | +7. If :opsmgrkube:`spec.backup.enabled` is **true**, the |k8s-op-short| |
| 218 | + invokes |onprem| APIs to ensure that the |application|\'s backup |
| 219 | + configuration matches the one that you define in the custom resource |
| 220 | + definition. |
0 commit comments