# mongodb/mongodb-kubernetes architecture

> Architecture diagram of the GitHub repository mongodb/mongodb-kubernetes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mongodb/mongodb-kubernetes
- Repository: https://github.com/mongodb/mongodb-kubernetes

## Overview

MCK is a Kubernetes operator for MongoDB Community and Enterprise Advanced. Users declare MongoDB resources; controllers reconcile those declarations into Kubernetes workloads and, for Enterprise deployments, coordinate with Ops Manager or Cloud Manager for automation, monitoring, and backups. The repository also includes Community replica-set management, search, multi-cluster support, user and role management, Prometheus integration, and migration tooling. The map follows documented capabilities and sampled controller relationships; several unsampled subsystems are represented at their exact directory paths, with links included only where documentation supports them.

Main entry points: [`controllers/operator/mongodbshardedcluster_controller.go`](https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/mongodbshardedcluster_controller.go) (Enterprise Reconcilers), [`mongodb-community-operator/controllers/replica_set_controller.go`](https://github.com/mongodb/mongodb-kubernetes/blob/master/mongodb-community-operator/controllers/replica_set_controller.go) (Community Replica Sets), [`api/mongodb/v1/mdb`](https://github.com/mongodb/mongodb-kubernetes/tree/master/api/mongodb/v1/mdb) (Enterprise Resource Types), [`mongodb-community-operator/api/v1/mongodbcommunity_types.go`](https://github.com/mongodb/mongodb-kubernetes/blob/master/mongodb-community-operator/api/v1/mongodbcommunity_types.go) (Community Resource Types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Resource APIs"]
  node_enterprise_api["Enterprise Resource Types"]
  node_om_api["Ops Manager Resource Types"]
  node_community_api["Community Resource Types"]
end

subgraph group_enterprise["Enterprise Reconciliation"]
  node_enterprise_controller["Enterprise Reconcilers"]
  node_appdb_controller["AppDB Reconciler"]
  node_om_workloads["Ops Manager Workloads"]
  node_om_client["Ops Manager Client<br/>[omclient.go]"]
  node_search["Search Reconciliation"]
end

subgraph group_community["Community Reconciliation"]
  node_community_controller["Community Replica Sets"]
  node_community_workload["Community StatefulSets"]
end

subgraph group_features["Shared Capabilities"]
  node_users_roles["Users and Roles"]
  node_auth["Authentication"]
  node_backup["Backup Management"]
  node_multi_cluster["Multi-Cluster Support"]
  node_metrics["Prometheus Integration"]
end

subgraph group_tools["User Tools"]
  node_migration["Migration Plugin"]
  node_kubectl["kubectl-mongodb<br/>[root.go]"]
end

node_user(("Cluster User"))
node_kube[("Kubernetes API")]
node_mongo[("MongoDB")]
node_om_service["Ops Manager / Cloud Manager"]
node_prometheus["Prometheus"]

node_user -->|"declares"| node_enterprise_api
node_user -->|"declares"| node_community_api
node_enterprise_api -.->|"reconciles"| node_enterprise_controller
node_om_api -.->|"configures"| node_appdb_controller
node_community_api -.->|"reconciles"| node_community_controller
node_enterprise_controller -->|"manages workloads"| node_kube
node_appdb_controller -->|"manages AppDB"| node_kube
node_community_controller -->|"builds workloads"| node_community_workload
node_community_workload -->|"creates StatefulSets"| node_kube
node_enterprise_controller -.->|"uses automation API"| node_om_client
node_om_client -->|"calls API"| node_om_service
node_enterprise_controller -.->|"constructs workloads"| node_om_workloads
node_enterprise_controller -.->|"reconciles search"| node_search
node_users_roles -->|"manages access"| node_mongo
node_community_controller -->|"configures authentication"| node_auth
node_enterprise_controller -->|"supports backups"| node_backup
node_enterprise_controller -.->|"supports multi-cluster"| node_multi_cluster
node_community_controller -->|"exports metrics"| node_prometheus
node_user -.->|"runs commands"| node_kubectl
node_kubectl -.->|"runs migration"| node_migration

click node_enterprise_api "https://github.com/mongodb/mongodb-kubernetes/tree/master/api/mongodb/v1/mdb"
click node_om_api "https://github.com/mongodb/mongodb-kubernetes/tree/master/api/mongodb/v1/om"
click node_community_api "https://github.com/mongodb/mongodb-kubernetes/blob/master/mongodb-community-operator/api/v1/mongodbcommunity_types.go"
click node_enterprise_controller "https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/mongodbshardedcluster_controller.go"
click node_appdb_controller "https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/appdbreplicaset_controller.go"
click node_om_workloads "https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/construct/opsmanager_construction.go"
click node_om_client "https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/om/omclient.go"
click node_search "https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/searchcontroller/mongodbsearch_reconcile_helper.go"
click node_community_controller "https://github.com/mongodb/mongodb-kubernetes/blob/master/mongodb-community-operator/controllers/replica_set_controller.go"
click node_community_workload "https://github.com/mongodb/mongodb-kubernetes/blob/master/mongodb-community-operator/controllers/construct/mongodbstatefulset.go"
click node_users_roles "https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/mongodbuser_controller.go"
click node_auth "https://github.com/mongodb/mongodb-kubernetes/tree/master/controllers/operator/authentication"
click node_backup "https://github.com/mongodb/mongodb-kubernetes/tree/master/controllers/om/backup"
click node_multi_cluster "https://github.com/mongodb/mongodb-kubernetes/tree/master/pkg/multicluster"
click node_metrics "https://github.com/mongodb/mongodb-kubernetes/tree/master/controllers/operator"
click node_migration "https://github.com/mongodb/mongodb-kubernetes/tree/master/cmd/kubectl-mongodb/migrate-to-mck"
click node_kubectl "https://github.com/mongodb/mongodb-kubernetes/blob/master/cmd/kubectl-mongodb/root/root.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_enterprise_api,node_om_api,node_community_api,node_user toneBlue
class node_enterprise_controller,node_appdb_controller,node_om_workloads,node_om_client,node_search,node_kube,node_mongo toneAmber
class node_community_controller,node_community_workload toneMint
class node_users_roles,node_auth,node_backup,node_multi_cluster,node_metrics toneRose
class node_migration,node_kubectl,node_om_service,node_prometheus toneIndigo
```

## Components

### Resource APIs

- [Enterprise Resource Types](https://github.com/mongodb/mongodb-kubernetes/tree/master/api/mongodb/v1/mdb): `api/mongodb/v1/mdb`
- [Ops Manager Resource Types](https://github.com/mongodb/mongodb-kubernetes/tree/master/api/mongodb/v1/om): `api/mongodb/v1/om`
- [Community Resource Types](https://github.com/mongodb/mongodb-kubernetes/blob/master/mongodb-community-operator/api/v1/mongodbcommunity_types.go): `mongodb-community-operator/api/v1/mongodbcommunity_types.go`

### Enterprise Reconciliation

- [Enterprise Reconcilers](https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/mongodbshardedcluster_controller.go): `controllers/operator/mongodbshardedcluster_controller.go`
- [AppDB Reconciler](https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/appdbreplicaset_controller.go): `controllers/operator/appdbreplicaset_controller.go`
- [Ops Manager Workloads](https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/construct/opsmanager_construction.go): `controllers/operator/construct/opsmanager_construction.go`
- [Ops Manager Client](https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/om/omclient.go): `controllers/om/omclient.go`
- [Search Reconciliation](https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/searchcontroller/mongodbsearch_reconcile_helper.go): `controllers/searchcontroller/mongodbsearch_reconcile_helper.go`

### Community Reconciliation

- [Community Replica Sets](https://github.com/mongodb/mongodb-kubernetes/blob/master/mongodb-community-operator/controllers/replica_set_controller.go): `mongodb-community-operator/controllers/replica_set_controller.go`
- [Community StatefulSets](https://github.com/mongodb/mongodb-kubernetes/blob/master/mongodb-community-operator/controllers/construct/mongodbstatefulset.go): `mongodb-community-operator/controllers/construct/mongodbstatefulset.go`

### Shared Capabilities

- [Users and Roles](https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/mongodbuser_controller.go): `controllers/operator/mongodbuser_controller.go`
- [Authentication](https://github.com/mongodb/mongodb-kubernetes/tree/master/controllers/operator/authentication): `controllers/operator/authentication`
- [Backup Management](https://github.com/mongodb/mongodb-kubernetes/tree/master/controllers/om/backup): `controllers/om/backup`
- [Multi-Cluster Support](https://github.com/mongodb/mongodb-kubernetes/tree/master/pkg/multicluster): `pkg/multicluster`
- [Prometheus Integration](https://github.com/mongodb/mongodb-kubernetes/tree/master/controllers/operator): `controllers/operator`

### User Tools

- [Migration Plugin](https://github.com/mongodb/mongodb-kubernetes/tree/master/cmd/kubectl-mongodb/migrate-to-mck): `cmd/kubectl-mongodb/migrate-to-mck`
- [kubectl-mongodb](https://github.com/mongodb/mongodb-kubernetes/blob/master/cmd/kubectl-mongodb/root/root.go): `cmd/kubectl-mongodb/root/root.go`

### Other components

- **Cluster User**
- **Kubernetes API**
- **MongoDB**
- **Ops Manager / Cloud Manager**
- **Prometheus**

## Connections

- Cluster User → Enterprise Resource Types: declares (evidence: `README.md`)
- Cluster User → Community Resource Types: declares (evidence: `README.md`)
- Enterprise Resource Types → Enterprise Reconcilers: reconciles (evidence: `controllers/operator/mongodbshardedcluster_controller.go`)
- Ops Manager Resource Types → AppDB Reconciler: configures (evidence: `controllers/operator/appdbreplicaset_controller.go`)
- Community Resource Types → Community Replica Sets: reconciles
- Enterprise Reconcilers → Kubernetes API: manages workloads (evidence: `README.md`)
- AppDB Reconciler → Kubernetes API: manages AppDB (evidence: `README.md`)
- Community Replica Sets → Community StatefulSets: builds workloads (evidence: `mongodb-community-operator/controllers/replica_set_controller.go`)
- Community StatefulSets → Kubernetes API: creates StatefulSets
- Enterprise Reconcilers → Ops Manager Client: uses automation API
- Ops Manager Client → Ops Manager / Cloud Manager: calls API (evidence: `controllers/om/omclient.go`)
- Enterprise Reconcilers → Ops Manager Workloads: constructs workloads
- Enterprise Reconcilers → Search Reconciliation: reconciles search
- Users and Roles → MongoDB: manages access (evidence: `README.md`)
- Community Replica Sets → Authentication: configures authentication (evidence: `mongodb-community-operator/controllers/replica_set_controller.go`)
- Enterprise Reconcilers → Backup Management: supports backups (evidence: `README.md`)
- Enterprise Reconcilers → Multi-Cluster Support: supports multi-cluster (evidence: `controllers/operator/mongodbshardedcluster_controller.go`)
- Community Replica Sets → Prometheus: exports metrics (evidence: `README.md`)
- Cluster User → kubectl-mongodb: runs commands
- kubectl-mongodb → Migration Plugin: runs migration
